| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|---|
| 2 | <!--
|
|---|
| 3 | $Id: Ada95.html,v 1.6 2004/01/18 00:32:47 tom Exp $
|
|---|
| 4 | ****************************************************************************
|
|---|
| 5 | * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
|
|---|
| 6 | * *
|
|---|
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a *
|
|---|
| 8 | * copy of this software and associated documentation files (the *
|
|---|
| 9 | * "Software"), to deal in the Software without restriction, including *
|
|---|
| 10 | * without limitation the rights to use, copy, modify, merge, publish, *
|
|---|
| 11 | * distribute, distribute with modifications, sublicense, and/or sell *
|
|---|
| 12 | * copies of the Software, and to permit persons to whom the Software is *
|
|---|
| 13 | * furnished to do so, subject to the following conditions: *
|
|---|
| 14 | * *
|
|---|
| 15 | * The above copyright notice and this permission notice shall be included *
|
|---|
| 16 | * in all copies or substantial portions of the Software. *
|
|---|
| 17 | * *
|
|---|
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
|---|
| 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
|---|
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
|---|
| 21 | * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
|---|
| 22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
|---|
| 23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
|---|
| 24 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
|---|
| 25 | * *
|
|---|
| 26 | * Except as contained in this notice, the name(s) of the above copyright *
|
|---|
| 27 | * holders shall not be used in advertising or otherwise to promote the *
|
|---|
| 28 | * sale, use or other dealings in this Software without prior written *
|
|---|
| 29 | * authorization. *
|
|---|
| 30 | ****************************************************************************
|
|---|
| 31 | * @Id: clear.1,v 1.3 2000/07/15 23:59:35 china Exp @
|
|---|
| 32 | -->
|
|---|
| 33 | <HTML>
|
|---|
| 34 | <HEAD>
|
|---|
| 35 | <TITLE>Ada95 Binding for ncurses</Title>
|
|---|
| 36 | </HEAD>
|
|---|
| 37 | <BODY>
|
|---|
| 38 | <H1>Ada95 Binding for ncurses</H1>
|
|---|
| 39 | by Jürgen Pfeifer.
|
|---|
| 40 |
|
|---|
| 41 | <HR SIZE=3 NOSHADE>
|
|---|
| 42 | <H2>General Remarks</H2>
|
|---|
| 43 | <UL>
|
|---|
| 44 | <LI>This document describes Version 01.00 of the binding.</LI>
|
|---|
| 45 | <LI>The functionality is modeled to be compatible with the ncurses
|
|---|
| 46 | package, a clone of the SVr4 curses model.<BR>
|
|---|
| 47 | I did the development on an Intel box running the latest stable release of
|
|---|
| 48 | <A HREF="http://www.linux.org">Linux</A>, ncurses and the most recent released
|
|---|
| 49 | <A HREF="http://www.gnat.com">GNU Ada Translator</A>
|
|---|
| 50 | gnat versions. For any older versions of ncurses and gnat
|
|---|
| 51 | it is not guaranteed to work.</LI>
|
|---|
| 52 | <LI>You must have the m4 macroprocessor to build this package.
|
|---|
| 53 | If you don't have this program, you can get the FSF version
|
|---|
| 54 | <A HREF="ftp://ftp.gnu.org/pub/gnu/">here</A>.</LI>
|
|---|
| 55 | <LI>Ada programs are supposed to be readable. One of my
|
|---|
| 56 | favorite methods to make code readable is to use expressive
|
|---|
| 57 | names for the identifiers. You can find a list of a mapping
|
|---|
| 58 | of the cryptic curses names to the Ada names in this <A HREF="ada/table.html">table</A>.</LI>
|
|---|
| 59 | <LI>This is not a typical one-to-one interface mapping. It is
|
|---|
| 60 | close to one-to-one on the functional level. Each (n)curses function
|
|---|
| 61 | has it's counterpart with a more or less similar formal parameter list
|
|---|
| 62 | in the binding. It is not one-to-one with respect to the datatypes.
|
|---|
| 63 | I tried to make records out of the flat chtype and similar structures,
|
|---|
| 64 | so you don't have to do bit operations to mark an attributed character
|
|---|
| 65 | as bold. Just make the boolean member <STRONG>bold</STRONG> of the record
|
|---|
| 66 | true. The binding also hides the structures like WINDOW, PANEL, MENU, FORM
|
|---|
| 67 | etc. ! It's a pure functional API.</LI>
|
|---|
| 68 | <LI>I try to do as much error checking as possible and feasible
|
|---|
| 69 | in the binding. I will raise an Ada exception when something
|
|---|
| 70 | went wrong in the low-level curses. This has the effect that - at least
|
|---|
| 71 | first time in my life - (n)curses programs have now a very rigid error
|
|---|
| 72 | checking, but - thanks to Ada - you don't have to code the orgiastic
|
|---|
| 73 | error checking style of C.</LI>
|
|---|
| 74 | <LI>Support for wide characters is currently not in the binding, as it
|
|---|
| 75 | is not really in ncurses at this point in time.</LI>
|
|---|
| 76 | </UL>
|
|---|
| 77 |
|
|---|
| 78 | <H2>Limitations</H2>
|
|---|
| 79 | <UL>
|
|---|
| 80 | <LI>I provide no SCREEN datatype and functions to set a new screen.
|
|---|
| 81 | If you need this (mostly for debugging I guess), write a small
|
|---|
| 82 | C routine doing all this and import it into your Ada program.</LI>
|
|---|
| 83 | <LI>I provide no functions to switch on/off curses tracing options.
|
|---|
| 84 | Same suggestion as above.</LI>
|
|---|
| 85 | <LI>Although Ada95 is an OO Language, this binding doesn't provide
|
|---|
| 86 | an OO abstraction of the (n)curses functionality. As mentioned above
|
|---|
| 87 | it's a thin binding for the (n)curses functions. But without any
|
|---|
| 88 | doubt it would be nice to build on top of this an OO abstraction
|
|---|
| 89 | of (n)curses functionality.<BR>
|
|---|
| 90 | The only exception is the method how fieldtypes are represented in
|
|---|
| 91 | this Binding. We provide an abstract tagged type Field_Type from
|
|---|
| 92 | which the various fieldtypes are derived.</LI>
|
|---|
| 93 | <LI>I currently do not support the link_fieldtype functionality of the
|
|---|
| 94 | forms subsystem.</LI>
|
|---|
| 95 | <LI>The *_IO packages are currently output only.</LI>
|
|---|
| 96 | </UL>
|
|---|
| 97 |
|
|---|
| 98 | <H2>Hierarchy of packages</H2>
|
|---|
| 99 | <UL>
|
|---|
| 100 | <LI><A HREF="ada/terminal_interface__ads.htm">Terminal_Interface</A>
|
|---|
| 101 | <UL><LI><A HREF="ada/terminal_interface-curses__ads.htm">Curses</A>
|
|---|
| 102 | <UL><LI><A HREF="ada/terminal_interface-curses-mouse__ads.htm">Mouse</A>
|
|---|
| 103 | <LI><A HREF="ada/terminal_interface-curses-panels__ads.htm">Panels</A>
|
|---|
| 104 | <UL><LI><A HREF="ada/terminal_interface-curses-panels-user_data__ads.htm">User_Data</A>
|
|---|
| 105 | </UL>
|
|---|
| 106 | <LI><A HREF="ada/terminal_interface-curses-menus__ads.htm">Menus</A>
|
|---|
| 107 | <UL><LI><A HREF="ada/terminal_interface-curses-menus-menu_user_data__ads.htm">Menu_User_Data</A>
|
|---|
| 108 | <LI><A HREF="ada/terminal_interface-curses-menus-item_user_data__ads.htm">Item_User_Data</A>
|
|---|
| 109 | </UL>
|
|---|
| 110 | <LI><A HREF="ada/terminal_interface-curses-forms__ads.htm">Forms</A>
|
|---|
| 111 | <UL><LI><A HREF="ada/terminal_interface-curses-forms-form_user_data__ads.htm">Form_User_Data</A>
|
|---|
| 112 | <LI><A HREF="ada/terminal_interface-curses-forms-field_user_data__ads.htm">Field_User_Data</A>
|
|---|
| 113 | <LI><A HREF="ada/terminal_interface-curses-forms-field_types__ads.htm">Field_Types</A>
|
|---|
| 114 | <UL><LI><A HREF="ada/terminal_interface-curses-forms-field_types-alpha__ads.htm">Alpha</A>
|
|---|
| 115 | <LI><A HREF="ada/terminal_interface-curses-forms-field_types-alphanumeric__ads.htm">AlphaNumeric</A>
|
|---|
| 116 | <LI><A HREF="ada/terminal_interface-curses-forms-field_types-intfield__ads.htm">IntField</A>
|
|---|
| 117 | <LI><A HREF="ada/terminal_interface-curses-forms-field_types-numeric__ads.htm">Numeric</A>
|
|---|
| 118 | <LI><A HREF="ada/terminal_interface-curses-forms-field_types-regexp__ads.htm">RegExp</A>
|
|---|
| 119 | <LI><A HREF="ada/terminal_interface-curses-forms-field_types-ipv4_address__ads.htm">IPV4_Address</A>
|
|---|
| 120 | <LI><A HREF="ada/terminal_interface-curses-forms-field_types-enumeration__ads.htm">Enumeration</A>
|
|---|
| 121 | <UL><LI><A HREF="ada/terminal_interface-curses-forms-field_types-enumeration-ada__ads.htm">Ada</A>
|
|---|
| 122 | </UL>
|
|---|
| 123 | <LI><A HREF="ada/terminal_interface-curses-forms-field_types-user__ads.htm">User</A>
|
|---|
| 124 | <UL><LI><A HREF="ada/terminal_interface-curses-forms-field_types-user-choice__ads.htm">Choice</A>
|
|---|
| 125 | </UL>
|
|---|
| 126 | </UL>
|
|---|
| 127 | </UL>
|
|---|
| 128 | <LI><A HREF="ada/terminal_interface-curses-text_io__ads.htm">Text_IO</A>
|
|---|
| 129 | <UL><LI><A HREF="ada/terminal_interface-curses-text_io-integer_io__ads.htm">Integer_IO</A>
|
|---|
| 130 | <LI><A HREF="ada/terminal_interface-curses-text_io-float_io__ads.htm">Float_IO</A>
|
|---|
| 131 | <LI><A HREF="ada/terminal_interface-curses-text_io-fixed_io__ads.htm">Fixed_IO</A>
|
|---|
| 132 | <LI><A HREF="ada/terminal_interface-curses-text_io-decimal_io__ads.htm">Decimal_IO</A>
|
|---|
| 133 | <LI><A HREF="ada/terminal_interface-curses-text_io-modular_io__ads.htm">Modular_IO</A>
|
|---|
| 134 | <LI><A HREF="ada/terminal_interface-curses-text_io-enumeration_io__ads.htm">Enumeration_IO</A>
|
|---|
| 135 | <LI><A HREF="ada/terminal_interface-curses-text_io-complex_io__ads.htm">Complex_IO</A>
|
|---|
| 136 | </UL>
|
|---|
| 137 | </UL>
|
|---|
| 138 | </UL>
|
|---|
| 139 | </UL>
|
|---|
| 140 | If you want to navigate through the html pages of the package specs, click <A HREF="ada/index.htm">here</A>.
|
|---|
| 141 | <H2>Implementation Details</H2>
|
|---|
| 142 | <H4>Behind the abstraction</H4>
|
|---|
| 143 | All the new types like <STRONG>Window</STRONG>, <STRONG>Panel</STRONG>,
|
|---|
| 144 | <STRONG>Menu</STRONG>, <STRONG>Form</STRONG> etc. are just
|
|---|
| 145 | opaque representations of the pointers to the corresponding
|
|---|
| 146 | low level (n)curses structures like
|
|---|
| 147 | <STRONG>WINDOW *</STRONG>, <STRONG>PANEL *</STRONG>,
|
|---|
| 148 | <STRONG>MENU *</STRONG> or <STRONG>FORM *</STRONG>.
|
|---|
| 149 | So you can safely pass them to C routines that expect a pointer
|
|---|
| 150 | to one of those structures.
|
|---|
| 151 | <H4>Extended ripoffline() usage</H4>
|
|---|
| 152 | The official documentation of (n)curses says, that the line parameter
|
|---|
| 153 | determines only whether or not exactly <STRONG>one</STRONG> line is
|
|---|
| 154 | stolen from the top or bottom of the screen. So essentially only the
|
|---|
| 155 | sign of the parameter is evaluated. ncurses has internally implemented
|
|---|
| 156 | it in a way, that uses the line parameter also to control the amount of
|
|---|
| 157 | lines to steal. This mechanism is used in the <STRONG>Rip_Off_Lines</STRONG>
|
|---|
| 158 | routine of the binding.
|
|---|
| 159 | <H4><A NAME="userpointer">How user defined field types work</A></H4>
|
|---|
| 160 | TBD
|
|---|
| 161 | <H4>Enumeration fields handling</H4>
|
|---|
| 162 | The (n)curses documentation says, that the String arrays to be passed to
|
|---|
| 163 | an TYPE_ENUM fieldtype must not be automatic variables. This is not true
|
|---|
| 164 | in this binding, because it is internally arranged to safely copy these
|
|---|
| 165 | values.
|
|---|
| 166 | <H4><A NAME="compiler">Using other Ada compilers</A></H4>
|
|---|
| 167 | This should basically not be a problem.
|
|---|
| 168 | <H4>Port to other curses implementations</H4>
|
|---|
| 169 | Basically it should not be too hard to make all this run on a regular SVr4
|
|---|
| 170 | implementation of curses. The problems are probably these:<BR>
|
|---|
| 171 | <UL>
|
|---|
| 172 | <LI>ncurses has some additional features which are presented in this binding. You
|
|---|
| 173 | have two choices to deal with this:
|
|---|
| 174 | <UL>
|
|---|
| 175 | <LI>Emulate the feature in this binding</LI>
|
|---|
| 176 | <LI>Raise an exception for non implemented features</LI>
|
|---|
| 177 | </UL>
|
|---|
| 178 | Most likely you will follow a mixed approach. Some features are easy to simulate,
|
|---|
| 179 | others will be hard if not impossible.</LI>
|
|---|
| 180 | </UL>
|
|---|
| 181 | I'm quite sure I forgot something.
|
|---|
| 182 | </BODY>
|
|---|
| 183 | </HTML>
|
|---|