]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/Ada95.html
ncurses 5.2
[ncurses.git] / doc / html / Ada95.html
1 <!DOCTYPE HTML
2  PUBLIC "-//IETF//DTD HTML 3.0//EN">
3 <!--
4   $Id: Ada95.html,v 1.1 2000/03/05 18:21:59 juergen Exp $
5 -->
6 <HTML>
7
8 <HEAD>
9 <TITLE>Ada95 Binding for ncurses</Title>
10 </HEAD>
11 <BODY>
12 <H1>Ada95 Binding for ncurses</H1>
13 The ncurses Ada95 binding is &copy; 1996-2000 by 
14 <A HREF="mailto:juergen.pfeifer@gmx.net">J&uuml;rgen Pfeifer</A>.
15 <P>
16                                                                          
17 Permission is hereby granted to reproduce and distribute this
18 binding by any means and for any fee, whether alone or as part 
19 of a larger distribution, in source or in binary form, PROVIDED        
20 this notice is included with any such distribution, and is not    
21 removed from any of its header files. Mention of ncurses and the
22 author of this binding in any applications linked with it is 
23 highly appreciated.<BR>                
24                                                                          
25 This binding comes AS IS with no warranty, implied or expressed.       
26 <P>
27 <HR SIZE=3 NOSHADE>
28 <H2>General Remarks</H2>
29 <UL>
30 <LI>This document describes Version 01.00 of the binding.</LI>
31 <LI>The functionality is modelled to be compatible with the ncurses
32 package, a clone of the SVr4 curses model.<BR>
33 I did the development on an Intel box running the latest stable release of
34 <A HREF="http://www.linux.org">Linux</A>, ncurses and the most recent released 
35 <A HREF="http://www.gnat.com">GNU Ada Translator</A>
36 gnat versions. For any older versions of ncurses and gnat
37 it is not guaranteed to work.</LI>
38 <LI>You must have the m4 macroprocessor to build this package.
39 If you don't have this program, you can get the FSF version
40 <A HREF="ftp://prep.ai.mit.edu/pub/gnu/">here</A>.</LI>
41 <LI>Ada programs are supposed to be readable. One of my
42 favourite methods to make code readable is to use expressive
43 names for the identifiers. You can find a list of a mapping
44 of the cryptic curses names to the Ada names in this <A HREF="ada/table.html">table</A>.</LI>
45 <LI>This is not a typical one-2-one interface mapping. It is 
46 close to one-2-one on the functional level. Each (n)curses function
47 has it's counterpart with a more or less similar formal parameter list
48 in the binding. It is not one-2-one with respect to the datatypes.
49 I tried to make records out of the flat chtype and similar structures,
50 so you don't have to do bit operations to mark an attributed character
51 as bold. Just make the boolean member <STRONG>bold</STRONG> of the record 
52 true. The binding also hides the structures like WINDOW, PANEL, MENU, FORM
53 etc. ! It's a pure functional API.</LI>
54 <LI>I try to do as much error checking as possible and feasible
55 in the binding. I will raise an Ada exception when something
56 went wrong in the low-level curses. This has the effect that - at least
57 first time in my life - (n)curses programs have now a very rigid error
58 checking, but - thanks to Ada - you don't have to code the orgiastic
59 error checking style of C.</LI>
60 <LI>Support for wide characters is currently not in the binding, as it
61 is not really in ncurses at this point in time.</LI>
62 </UL>
63 <P>
64       
65 <H2>Limitations</H2>
66 <UL>
67 <LI>I provide no SCREEN datatype and functions to set a new screen.
68 If you need this (mostly for debugging I guess), write a small
69 C routine doing all this and import it into your Ada program.</LI>
70 <LI>I provide no functions to switch on/off curses tracing options.
71 Same suggestion as above.</LI>
72 <LI>Although Ada95 is an OO Language, this binding doesn't provide
73 an OO abstraction of the (n)curses functionality. As mentioned above
74 it's a thin binding for the (n)curses functions. But without any
75 doubt it would be nice to build on top of this an OO abstraction
76 of (n)curses functionality.<BR>
77 The only exception is the method how fieldtypes are represented in
78 this Binding. We provide an abstract tagged type Field_Type from
79 which the various fieldtypes are derived.</LI>
80 <LI>I currently do not support the link_fieldtype functionality of the
81 forms subsystem.</LI>
82 <LI>The *_IO packages are currently output only.</LI>
83 </UL>
84          
85 <H2>Hierarchy of packages</H2>
86 <UL>
87 <LI><A HREF="ada/terminal_interface__ads.htm">Terminal_Interface</A>
88     <UL><LI><A HREF="ada/terminal_interface-curses__ads.htm">Curses</A>
89         <UL><LI><A HREF="ada/terminal_interface-curses-mouse__ads.htm">Mouse</A>
90             <LI><A HREF="ada/terminal_interface-curses-panels__ads.htm">Panels</A>
91             <UL><LI><A HREF="ada/terminal_interface-curses-panels-user_data__ads.htm">User_Data</A>
92             </UL>
93             <LI><A HREF="ada/terminal_interface-curses-menus__ads.htm">Menus</A>
94                 <UL><LI><A HREF="ada/terminal_interface-curses-menus-menu_user_data__ads.htm">Menu_User_Data</A>
95                     <LI><A HREF="ada/terminal_interface-curses-menus-item_user_data__ads.htm">Item_User_Data</A>
96                 </UL>    
97             <LI><A HREF="ada/terminal_interface-curses-forms__ads.htm">Forms</A>
98                 <UL><LI><A HREF="ada/terminal_interface-curses-forms-form_user_data__ads.htm">Form_User_Data</A>
99                     <LI><A HREF="ada/terminal_interface-curses-forms-field_user_data__ads.htm">Field_User_Data</A>
100                     <LI><A HREF="ada/terminal_interface-curses-forms-field_types__ads.htm">Field_Types</A>                   
101                     <UL><LI><A HREF="ada/terminal_interface-curses-forms-field_types-alpha__ads.htm">Alpha</A>
102                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-alphanumeric__ads.htm">AlphaNumeric</A>
103                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-intfield__ads.htm">IntField</A>
104                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-numeric__ads.htm">Numeric</A>
105                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-regexp__ads.htm">RegExp</A>
106                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-ipv4_address__ads.htm">IPV4_Address</A>
107                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-enumeration__ads.htm">Enumeration</A>
108                         <UL><LI><A HREF="ada/terminal_interface-curses-forms-field_types-enumeration-ada__ads.htm">Ada</A>
109                         </UL>
110                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-user__ads.htm">User</A>
111                         <UL><LI><A HREF="ada/terminal_interface-curses-forms-field_types-user-choice__ads.htm">Choice</A>
112                         </UL>
113                      </UL>   
114                 </UL>   
115             <LI><A HREF="ada/terminal_interface-curses-text_io__ads.htm">Text_IO</A>
116                 <UL><LI><A HREF="ada/terminal_interface-curses-text_io-integer_io__ads.htm">Integer_IO</A>
117                     <LI><A HREF="ada/terminal_interface-curses-text_io-float_io__ads.htm">Float_IO</A>
118                     <LI><A HREF="ada/terminal_interface-curses-text_io-fixed_io__ads.htm">Fixed_IO</A>
119                     <LI><A HREF="ada/terminal_interface-curses-text_io-decimal_io__ads.htm">Decimal_IO</A>
120                     <LI><A HREF="ada/terminal_interface-curses-text_io-modular_io__ads.htm">Modular_IO</A>
121                     <LI><A HREF="ada/terminal_interface-curses-text_io-enumeration_io__ads.htm">Enumeration_IO</A>
122                     <LI><A HREF="ada/terminal_interface-curses-text_io-complex_io__ads.htm">Complex_IO</A>
123                 </UL>
124          </UL>
125      </UL>        
126 </UL>
127 If you want to navigate through the html pages of the package specs, click <A HREF="ada/index.htm">here</A>.
128 <H2>Implementation Details</H2>
129 <H4>Behind the abstraction</H4>
130 All the new types like <STRONG>Window</STRONG>, <STRONG>Panel</STRONG>,
131 <STRONG>Menu</STRONG>, <STRONG>Form</STRONG> etc. are just
132 opaque representations of the pointers to the corresponding 
133 low level (n)curses structures like 
134 <STRONG>WINDOW *</STRONG>, <STRONG>PANEL *</STRONG>,
135 <STRONG>MENU *</STRONG> or <STRONG>FORM *</STRONG>.
136 So you can safely pass them to C routines that expect a pointer
137 to one of those structures.
138 <H4>Extended ripoffline() usage</H4>
139 The official documentation of (n)curses says, that the line parameter
140 determines only whether or not exactly <STRONG>one</STRONG> line is
141 stolen from the top or bottom of the screen. So essentially only the
142 sign of the parameter is evaluated. ncurses has internally implemented
143 it in a way, that uses the line parameter also to control the amount of
144 lines to steal. This mechanism is used in the <STRONG>Rip_Off_Lines</STRONG>
145 routine of the binding.
146 <A NAME="userpointer">
147 <H4>How user defined field types work</H4>
148 TBD
149 <H4>Enumeration fields handling</H4>
150 The (n)curses documentation says, that the String arrays to be passed to
151 an TYPE_ENUM fieldtype must not be automatic variables. This is not true
152 in this binding, because it is internally arranged to safely copy these
153 values.
154 <A NAME="compiler">
155 <H4>Using other Ada compilers</H4>
156 This should basically not be a problem.
157 <H4>Port to other curses implementations</H4>
158 Basically it should not be too hard to make all this run on a regular SVr4
159 implementation of curses. The problems are probably these:<BR>
160 <UL>
161 <LI>ncurses has some additional features which are presented in this binding. You
162 have two choices to deal with this:
163 <UL>
164 <LI>Emulate the feature in this binding</LI>
165 <LI>Raise an exception for non implemented features</LI>
166 </UL>
167 Most likely you will follow a mixed approach. Some features are easy to simulate,
168 others will be hard if not impossible.</LI>
169 </UL>
170 I'm quite sure I forgot something.<P>
171 </BODY>
172 </HTML>