]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/Ada95.html
ncurses 5.3
[ncurses.git] / doc / html / Ada95.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
2 <!--
3   $Id: Ada95.html,v 1.3 2002/07/13 16:32:37 tom Exp $
4 -->
5 <HTML>
6 <HEAD>
7 <TITLE>Ada95 Binding for ncurses</Title>
8 </HEAD>
9 <BODY>
10 <H1>Ada95 Binding for ncurses</H1>
11 The ncurses Ada95 binding is &copy; 1996-2000 by 
12 <A HREF="http://www.familiepfeifer.de/Contact.aspx?Lang=en">J&uuml;rgen Pfeifer</A>.
13 <P>
14                                                                          
15 Permission is hereby granted to reproduce and distribute this
16 binding by any means and for any fee, whether alone or as part 
17 of a larger distribution, in source or in binary form, PROVIDED        
18 this notice is included with any such distribution, and is not    
19 removed from any of its header files. Mention of ncurses and the
20 author of this binding in any applications linked with it is 
21 highly appreciated.<BR>                
22                                                                          
23 This binding comes AS IS with no warranty, implied or expressed.       
24 <P>
25 <HR SIZE=3 NOSHADE>
26 <H2>General Remarks</H2>
27 <UL>
28 <LI>This document describes Version 01.00 of the binding.</LI>
29 <LI>The functionality is modeled to be compatible with the ncurses
30 package, a clone of the SVr4 curses model.<BR>
31 I did the development on an Intel box running the latest stable release of
32 <A HREF="http://www.linux.org">Linux</A>, ncurses and the most recent released 
33 <A HREF="http://www.gnat.com">GNU Ada Translator</A>
34 gnat versions. For any older versions of ncurses and gnat
35 it is not guaranteed to 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 favorite 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="ada/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.<BR>
75 The only exception is the method how fieldtypes are represented in
76 this Binding. We provide an abstract tagged type Field_Type from
77 which the various fieldtypes are derived.</LI>
78 <LI>I currently do not support the link_fieldtype functionality of the
79 forms subsystem.</LI>
80 <LI>The *_IO packages are currently output only.</LI>
81 </UL>
82          
83 <H2>Hierarchy of packages</H2>
84 <UL>
85 <LI><A HREF="ada/terminal_interface__ads.htm">Terminal_Interface</A>
86     <UL><LI><A HREF="ada/terminal_interface-curses__ads.htm">Curses</A>
87         <UL><LI><A HREF="ada/terminal_interface-curses-mouse__ads.htm">Mouse</A>
88             <LI><A HREF="ada/terminal_interface-curses-panels__ads.htm">Panels</A>
89             <UL><LI><A HREF="ada/terminal_interface-curses-panels-user_data__ads.htm">User_Data</A>
90             </UL>
91             <LI><A HREF="ada/terminal_interface-curses-menus__ads.htm">Menus</A>
92                 <UL><LI><A HREF="ada/terminal_interface-curses-menus-menu_user_data__ads.htm">Menu_User_Data</A>
93                     <LI><A HREF="ada/terminal_interface-curses-menus-item_user_data__ads.htm">Item_User_Data</A>
94                 </UL>    
95             <LI><A HREF="ada/terminal_interface-curses-forms__ads.htm">Forms</A>
96                 <UL><LI><A HREF="ada/terminal_interface-curses-forms-form_user_data__ads.htm">Form_User_Data</A>
97                     <LI><A HREF="ada/terminal_interface-curses-forms-field_user_data__ads.htm">Field_User_Data</A>
98                     <LI><A HREF="ada/terminal_interface-curses-forms-field_types__ads.htm">Field_Types</A>                   
99                     <UL><LI><A HREF="ada/terminal_interface-curses-forms-field_types-alpha__ads.htm">Alpha</A>
100                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-alphanumeric__ads.htm">AlphaNumeric</A>
101                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-intfield__ads.htm">IntField</A>
102                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-numeric__ads.htm">Numeric</A>
103                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-regexp__ads.htm">RegExp</A>
104                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-ipv4_address__ads.htm">IPV4_Address</A>
105                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-enumeration__ads.htm">Enumeration</A>
106                         <UL><LI><A HREF="ada/terminal_interface-curses-forms-field_types-enumeration-ada__ads.htm">Ada</A>
107                         </UL>
108                         <LI><A HREF="ada/terminal_interface-curses-forms-field_types-user__ads.htm">User</A>
109                         <UL><LI><A HREF="ada/terminal_interface-curses-forms-field_types-user-choice__ads.htm">Choice</A>
110                         </UL>
111                      </UL>   
112                 </UL>   
113             <LI><A HREF="ada/terminal_interface-curses-text_io__ads.htm">Text_IO</A>
114                 <UL><LI><A HREF="ada/terminal_interface-curses-text_io-integer_io__ads.htm">Integer_IO</A>
115                     <LI><A HREF="ada/terminal_interface-curses-text_io-float_io__ads.htm">Float_IO</A>
116                     <LI><A HREF="ada/terminal_interface-curses-text_io-fixed_io__ads.htm">Fixed_IO</A>
117                     <LI><A HREF="ada/terminal_interface-curses-text_io-decimal_io__ads.htm">Decimal_IO</A>
118                     <LI><A HREF="ada/terminal_interface-curses-text_io-modular_io__ads.htm">Modular_IO</A>
119                     <LI><A HREF="ada/terminal_interface-curses-text_io-enumeration_io__ads.htm">Enumeration_IO</A>
120                     <LI><A HREF="ada/terminal_interface-curses-text_io-complex_io__ads.htm">Complex_IO</A>
121                 </UL>
122          </UL>
123      </UL>        
124 </UL>
125 If you want to navigate through the html pages of the package specs, click <A HREF="ada/index.htm">here</A>.
126 <H2>Implementation Details</H2>
127 <H4>Behind the abstraction</H4>
128 All the new types like <STRONG>Window</STRONG>, <STRONG>Panel</STRONG>,
129 <STRONG>Menu</STRONG>, <STRONG>Form</STRONG> etc. are just
130 opaque representations of the pointers to the corresponding 
131 low level (n)curses structures like 
132 <STRONG>WINDOW *</STRONG>, <STRONG>PANEL *</STRONG>,
133 <STRONG>MENU *</STRONG> or <STRONG>FORM *</STRONG>.
134 So you can safely pass them to C routines that expect a pointer
135 to one of those structures.
136 <H4>Extended ripoffline() usage</H4>
137 The official documentation of (n)curses says, that the line parameter
138 determines only whether or not exactly <STRONG>one</STRONG> line is
139 stolen from the top or bottom of the screen. So essentially only the
140 sign of the parameter is evaluated. ncurses has internally implemented
141 it in a way, that uses the line parameter also to control the amount of
142 lines to steal. This mechanism is used in the <STRONG>Rip_Off_Lines</STRONG>
143 routine of the binding.
144 <H4><A NAME="userpointer">How user defined field types work</A></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 <H4><A NAME="compiler">Using other Ada compilers</A></H4>
152 This should basically not be a problem.
153 <H4>Port to other curses implementations</H4>
154 Basically it should not be too hard to make all this run on a regular SVr4
155 implementation of curses. The problems are probably these:<BR>
156 <UL>
157 <LI>ncurses has some additional features which are presented in this binding. You
158 have two choices to deal with this:
159 <UL>
160 <LI>Emulate the feature in this binding</LI>
161 <LI>Raise an exception for non implemented features</LI>
162 </UL>
163 Most likely you will follow a mixed approach. Some features are easy to simulate,
164 others will be hard if not impossible.</LI>
165 </UL>
166 I'm quite sure I forgot something.<P>
167 </BODY>
168 </HTML>