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> 39by 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 46package, a clone of the SVr4 curses model.<BR> 47I 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> 50gnat versions. For any older versions of ncurses and gnat 51it is not guaranteed to work.</LI> 52<LI>You must have the m4 macroprocessor to build this package. 53If 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 56favorite methods to make code readable is to use expressive 57names for the identifiers. You can find a list of a mapping 58of 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 60close to one-to-one on the functional level. Each (n)curses function 61has it's counterpart with a more or less similar formal parameter list 62in the binding. It is not one-to-one with respect to the datatypes. 63I tried to make records out of the flat chtype and similar structures, 64so you don't have to do bit operations to mark an attributed character 65as bold. Just make the boolean member <STRONG>bold</STRONG> of the record 66true. The binding also hides the structures like WINDOW, PANEL, MENU, FORM 67etc. ! It's a pure functional API.</LI> 68<LI>I try to do as much error checking as possible and feasible 69in the binding. I will raise an Ada exception when something 70went wrong in the low-level curses. This has the effect that - at least 71first time in my life - (n)curses programs have now a very rigid error 72checking, but - thanks to Ada - you don't have to code the orgiastic 73error checking style of C.</LI> 74<LI>Support for wide characters is currently not in the binding, as it 75is 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. 81If you need this (mostly for debugging I guess), write a small 82C 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. 84Same suggestion as above.</LI> 85<LI>Although Ada95 is an OO Language, this binding doesn't provide 86an OO abstraction of the (n)curses functionality. As mentioned above 87it's a thin binding for the (n)curses functions. But without any 88doubt it would be nice to build on top of this an OO abstraction 89of (n)curses functionality.<BR> 90The only exception is the method how fieldtypes are represented in 91this Binding. We provide an abstract tagged type Field_Type from 92which the various fieldtypes are derived.</LI> 93<LI>I currently do not support the link_fieldtype functionality of the 94forms 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> 140If 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> 143All the new types like <STRONG>Window</STRONG>, <STRONG>Panel</STRONG>, 144<STRONG>Menu</STRONG>, <STRONG>Form</STRONG> etc. are just 145opaque representations of the pointers to the corresponding 146low level (n)curses structures like 147<STRONG>WINDOW *</STRONG>, <STRONG>PANEL *</STRONG>, 148<STRONG>MENU *</STRONG> or <STRONG>FORM *</STRONG>. 149So you can safely pass them to C routines that expect a pointer 150to one of those structures. 151<H4>Extended ripoffline() usage</H4> 152The official documentation of (n)curses says, that the line parameter 153determines only whether or not exactly <STRONG>one</STRONG> line is 154stolen from the top or bottom of the screen. So essentially only the 155sign of the parameter is evaluated. ncurses has internally implemented 156it in a way, that uses the line parameter also to control the amount of 157lines to steal. This mechanism is used in the <STRONG>Rip_Off_Lines</STRONG> 158routine of the binding. 159<H4><A NAME="userpointer">How user defined field types work</A></H4> 160TBD 161<H4>Enumeration fields handling</H4> 162The (n)curses documentation says, that the String arrays to be passed to 163an TYPE_ENUM fieldtype must not be automatic variables. This is not true 164in this binding, because it is internally arranged to safely copy these 165values. 166<H4><A NAME="compiler">Using other Ada compilers</A></H4> 167This should basically not be a problem. 168<H4>Port to other curses implementations</H4> 169Basically it should not be too hard to make all this run on a regular SVr4 170implementation of curses. The problems are probably these:<BR> 171<UL> 172<LI>ncurses has some additional features which are presented in this binding. You 173have 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> 178Most likely you will follow a mixed approach. Some features are easy to simulate, 179others will be hard if not impossible.</LI> 180</UL> 181I'm quite sure I forgot something. 182</BODY> 183</HTML> 184