Ada95.html 10 KB

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