]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/html/index.html
ncurses 4.1
[ncurses.git] / Ada95 / html / index.html
1 <!DOCTYPE HTML
2  PUBLIC "-//IETF//DTD HTML 3.0//EN">
3 <HTML>
4
5 <HEAD>
6 <TITLE>Ada95 Binding for ncurses</Title>
7 </HEAD>
8 <BODY BGCOLOR="#99ccbb" TEXT="#000000" LINK="#4060b0" VLINK="#000080" ALINK="#ff4040">
9 <H1>Ada95 Binding for ncurses</H1>
10 The ncurses Ada95 binding is &copy; 1996 by 
11 <A HREF="mailto:Juergen.Pfeifer@T-Online.de">J&uuml;rgen Pfeifer</A>.
12 <P>
13                                                                          
14 Permission is hereby granted to reproduce and distribute this
15 binding by any means and for any fee, whether alone or as part 
16 of a larger distribution, in source or in binary form, PROVIDED        
17 this notice is included with any such distribution, and is not    
18 removed from any of its header files. Mention of ncurses and the
19 author of this binding in any applications linked with it is 
20 highly appreciated.<BR>                
21                                                                          
22 This binding comes AS IS with no warranty, implied or expressed.       
23 <P>
24 <HR SIZE=3 NOSHADE>
25 <H2>General Remarks</H2>
26 <UL>
27 <LI>This document describes Version 00.92.00 of the binding.</LI>
28 <LI>The functionality is modelled to be compatible with the ncurses
29 package, a clone of the SVr4 curses model.<BR>
30 I did the development on an Intel box running 
31 <A HREF="http://www.linux.org">Linux</A> 1.3.x and 2.0,
32 ncurses-1.9.9e and the 
33 <A HREF="http://www.gnat.com">GNU Ada Translator</A>
34 gnat-3.05. For any older versions of ncurses and gnat
35 it will not work.</LI>
36 <LI>You must have the m4 macroprocessor to build this package.
37 If you don't have this program, you can get the FSF version
38 <A HREF="ftp://prep.ai.mit.edu/pub/gnu/">here</A>.</LI>
39 <LI>Ada programs are supposed to be readable. One of my
40 favourite methods to make code readable is to use expressive
41 names for the identifiers. You can find a list of a mapping
42 of the cryptic curses names to the Ada names in this <A HREF="table.html">table</A>.</LI>
43 <LI>This is not a typical one-2-one interface mapping. It is 
44 close to one-2-one on the functional level. Each (n)curses function
45 has it's counterpart with a more or less similar formal parameter list
46 in the binding. It is not one-2-one with respect to the datatypes.
47 I tried to make records out of the flat chtype and similar structures,
48 so you don't have to do bit operations to mark an attributed character
49 as bold. Just make the boolean member <STRONG>bold</STRONG> of the record 
50 true. The binding also hides the structures like WINDOW, PANEL, MENU, FORM
51 etc. ! It's a pure functional API.</LI>
52 <LI>I try to do as much error checking as possible and feasible
53 in the binding. I will raise an Ada exception when something
54 went wrong in the low-level curses. This has the effect that - at least
55 first time in my life - (n)curses programs have now a very rigid error
56 checking, but - thanks to Ada - you don't have to code the orgiastic
57 error checking style of C.</LI>
58 <LI>Support for wide characters is currently not in the binding, as it
59 is not really in ncurses at this point in time.</LI>
60 </UL>
61 <P>
62       
63 <H2>Limitations</H2>
64 <UL>
65 <LI>I provide no SCREEN datatype and functions to set a new screen.
66 If you need this (mostly for debugging I guess), write a small
67 C routine doing all this and import it into your Ada program.</LI>
68 <LI>I provide no functions to switch on/off curses tracing options.
69 Same suggestion as above.</LI>
70 <LI>Although Ada95 is an OO Language, this binding doesn't provide
71 an OO abstraction of the (n)curses functionality. As mentioned above
72 it's a thin binding for the (n)curses functions. But without any
73 doubt it would be nice to build on top of this an OO abstraction
74 of (n)curses functionality.</LI>
75 <LI>If you use the user-pointer mechanism for most of the ncurses
76 structures in a mixed language environemt, i.e. Ada95 and C routines
77 operate on the same objects, care must be taken because the Ada
78 binding itself uses the user pointer mechanism for it's own purposes.
79 See the corresponding <A HREF="#userpointer">section</A> in implementention
80 details.</LI>
81 <LI>I currently do not support the link_fieldtype functionality of the
82 forms subsystem.</LI>
83 <LI>The *_IO packages are currently output only.</LI>
84 </UL>
85          
86
87 <H2>Hierarchy of packages</H2>
88 <UL>
89 <LI><A HREF="terminal_interface_s.html">Terminal_Interface</A>
90     <UL><LI><A HREF="terminal_interface-curses_s.html">Curses</A>
91         <UL><LI><A HREF="terminal_interface-curses-mouse_s.html">Mouse</A>
92             <LI><A HREF="terminal_interface-curses-panels_s.html">Panels</A>
93             <UL><LI><A HREF="terminal_interface-curses-panels-user_data_s.html">User_Data</A>
94             </UL>
95             <LI><A HREF="terminal_interface-curses-menus_s.html">Menus</A>
96                 <UL><LI><A HREF="terminal_interface-curses-menus-menu_user_data_s.html">Menu_User_Data</A>
97                     <LI><A HREF="terminal_interface-curses-menus-item_user_data_s.html">Item_User_Data</A>
98                 </UL>    
99             <LI><A HREF="terminal_interface-curses-forms_s.html">Forms</A>
100                 <UL><LI><A HREF="terminal_interface-curses-forms-form_user_data_s.html">Form_User_Data</A>
101                     <LI><A HREF="terminal_interface-curses-forms-field_user_data_s.html">Field_User_Data</A>
102                     <LI><A HREF="terminal_interface-curses-forms-field_types_s.html">Field_Types</A>
103                     <LI><A HREF="terminal_interface-curses-forms-choice_field_types_s.html">Choice_Field_Types</A>
104                 </UL>    
105             <LI><A HREF="terminal_interface-curses-text_io_s.html">Text_IO</A>
106                 <UL><LI><A HREF="terminal_interface-curses-text_io-integer_io_s.html">Integer_IO</A>
107                     <LI><A HREF="terminal_interface-curses-text_io-float_io_s.html">Float_IO</A>
108                     <LI><A HREF="terminal_interface-curses-text_io-fixed_io_s.html">Fixed_IO</A>
109                     <LI><A HREF="terminal_interface-curses-text_io-decimal_io_s.html">Decimal_IO</A>
110                     <LI><A HREF="terminal_interface-curses-text_io-modular_io_s.html">Modular_IO</A>
111                     <LI><A HREF="terminal_interface-curses-text_io-enumeration_io_s.html">Enumeration_IO</A>
112                     <LI><A HREF="terminal_interface-curses-text_io-complex_io_s.html">Complex_IO</A>
113                 </UL>
114          </UL>
115      </UL>        
116 </UL>
117 <H2>Implementation Details</H2>
118 <H4>Behind the abstraction</H4>
119 All the new types like <STRONG>Window</STRONG>, <STRONG>Panel</STRONG>,
120 <STRONG>Menu</STRONG>, <STRONG>Form</STRONG> etc. are just
121 opaque representations of the pointers to the corresponding 
122 low level (n)curses structures like 
123 <STRONG>WINDOW *</STRONG>, <STRONG>PANEL *</STRONG>,
124 <STRONG>MENU *</STRONG> or <STRONG>FORM *</STRONG>.
125 So you can safely pass them to C routines that expect a pointer
126 to one of those structures.
127 <H4>Item and Field Arrays</H4>
128 In C you have to pass the item and field arrays to define menus or forms
129 terminated by a null item or null field. This is not necessary in this
130 binding. The binding routines will construct from an Ada95 style array
131 of Item or Field objects internally the properly terminated array of
132 C structure pointers. See the examples for more details. 
133 <H4>Extended ripoffline() usage</H4>
134 The official documentation of (n)curses says, that the line parameter
135 determines only whether or not exactly <STRONG>one</STRONG> line is
136 stolen from the top or bottom of the screen. So essentially only the
137 sign of the parameter is evaluated. ncurses has internally implemented
138 it in a way, that uses the line parameter also to control the amount of
139 lines to steal. This mechanism is used in the <STRONG>Rip_Off_Lines</STRONG>
140 routine of the binding.
141 <A NAME="userpointer">
142 <H4>User Pointer mechanism</H4>
143 TBD
144 <H4>How user defined field types work</H4>
145 TBD
146 <H4>Enumeration fields handling</H4>
147 The (n)curses documentation says, that the String arrays to be passed to
148 an TYPE_ENUM fieldtype must not be automatic variables. This is not true
149 in this binding, because it is internally arranged to safely copy these
150 values.
151 <A NAME="compiler">
152 <H4>Using other Ada compilers</H4>
153 This should basically not be a problem, but you have to replace a code
154 sequence in package
155 <A HREF="terminal_interface-curses-forms_s.html">Terminal_Interface.Curses.Forms</A>
156 that uses a hashing package supplied with the GNAT runtime, which is not part
157 of the Standard Ada runtimes. This should not be too hard. I intend to remove
158 this dependency in the future.
159 <H4>Port to other curses implementations</H4>
160 Basically it should not be too hard to make all this run on a regular SVr4
161 implementation of curses. The problems are probably these:<BR>
162 <UL>
163 <LI>ncurses has some additional features which are presented in this binding. You
164 have two choices to deal with this:
165 <UL>
166 <LI>Emulate the feature in this binding</LI>
167 <LI>Raise an exception for non implemented features</LI>
168 </UL>
169 Most likely you will follow a mixed approach. Some features are easy to simulate,
170 others will be hard if not impossible.</LI>
171 <LI>For menu items, the name and descriptions are internally copied by ncurses.
172 So the binding doesn't care for the lifetime of the strings passed to the
173 construction routine for items. This assumption is not true in most other implementations
174 of the menu library. In this case you have to modify the binding routine
175 <STRONG>New_Item</STRONG> to safestore the strings.</LI>
176 </UL>
177 I'm quite sure I forgot something.<P>
178 </BODY>
179 </HTML>