Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | <!-- |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 2 | $Id: Ada95.html,v 1.14 2013/05/18 21:34:34 tom Exp $ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 3 | **************************************************************************** |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 4 | * Copyright (c) 1998-2010,2013 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 5 | * * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a * |
| 7 | * copy of this software and associated documentation files (the * |
| 8 | * "Software"), to deal in the Software without restriction, including * |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, * |
| 10 | * distribute, distribute with modifications, sublicense, and/or sell * |
| 11 | * copies of the Software, and to permit persons to whom the Software is * |
| 12 | * furnished to do so, subject to the following conditions: * |
| 13 | * * |
| 14 | * The above copyright notice and this permission notice shall be included * |
| 15 | * in all copies or substantial portions of the Software. * |
| 16 | * * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 20 | * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 21 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 23 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 24 | * * |
| 25 | * Except as contained in this notice, the name(s) of the above copyright * |
| 26 | * holders shall not be used in advertising or otherwise to promote the * |
| 27 | * sale, use or other dealings in this Software without prior written * |
| 28 | * authorization. * |
| 29 | **************************************************************************** |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 30 | --> |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 31 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 32 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 33 | <html> |
| 34 | <head> |
| 35 | <meta name="generator" content= |
| 36 | "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org"> |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 37 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 38 | <title>Ada95 Binding for ncurses</title> |
| 39 | <link rev="made" href="mailto:bug-ncurses@gnu.org"> |
| 40 | <meta http-equiv="Content-Type" content= |
| 41 | "text/html; charset=us-ascii"> |
| 42 | </head> |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 43 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 44 | <body> |
| 45 | <h1>Ada95 Binding for ncurses</h1> |
| 46 | |
| 47 | <p>by Jürgen Pfeifer.</p> |
| 48 | <hr> |
| 49 | |
| 50 | <h2>General Remarks</h2> |
| 51 | |
| 52 | <ul> |
| 53 | <li>This document describes Version 01.00 of the binding.</li> |
| 54 | |
| 55 | <li>The functionality is modeled to be compatible with the |
| 56 | ncurses package, a clone of the SVr4 curses model.<br> |
| 57 | I did the development on an Intel box running the latest stable |
| 58 | release of <a href="http://www.linux.org">Linux</a>, ncurses |
| 59 | and the most recent released <a href="http://www.gnat.com">GNU |
| 60 | Ada Translator</a> gnat versions. For any older versions of |
| 61 | ncurses and gnat it is not guaranteed to work.</li> |
| 62 | |
| 63 | <li>You must have the m4 macroprocessor to build this package. |
| 64 | If you don't have this program, you can get the FSF version |
| 65 | <a href="ftp://ftp.gnu.org/pub/gnu/">here</a>.</li> |
| 66 | |
| 67 | <li>Ada programs are supposed to be readable. One of my |
| 68 | favorite methods to make code readable is to use expressive |
| 69 | names for the identifiers. You can find a list of a mapping of |
| 70 | the cryptic curses names to the Ada names in this <a href= |
| 71 | "ada/table.html">table</a>.</li> |
| 72 | |
| 73 | <li>This is not a typical one-to-one interface mapping. It is |
| 74 | close to one-to-one on the functional level. Each (n)curses |
| 75 | function has it's counterpart with a more or less similar |
| 76 | formal parameter list in the binding. It is not one-to-one with |
| 77 | respect to the datatypes. I tried to make records out of the |
| 78 | flat chtype and similar structures, so you don't have to do bit |
| 79 | operations to mark an attributed character as bold. Just make |
| 80 | the boolean member <strong>bold</strong> of the record true. |
| 81 | The binding also hides the structures like WINDOW, PANEL, MENU, |
| 82 | FORM etc. ! It's a pure functional API.</li> |
| 83 | |
| 84 | <li>I try to do as much error checking as possible and feasible |
| 85 | in the binding. I will raise an Ada exception when something |
| 86 | went wrong in the low-level curses. This has the effect that - |
| 87 | at least first time in my life - (n)curses programs have now a |
| 88 | very rigid error checking, but - thanks to Ada - you don't have |
| 89 | to code the orgiastic error checking style of C.</li> |
| 90 | |
| 91 | <li>Support for wide characters is currently not in the |
| 92 | binding, as it is not really in ncurses at this point in |
| 93 | time.</li> |
| 94 | </ul> |
| 95 | |
| 96 | <h2>Limitations</h2> |
| 97 | |
| 98 | <ul> |
| 99 | <li>I provide no SCREEN datatype and functions to set a new |
| 100 | screen. If you need this (mostly for debugging I guess), write |
| 101 | a small C routine doing all this and import it into your Ada |
| 102 | program.</li> |
| 103 | |
| 104 | <li>I provide no functions to switch on/off curses tracing |
| 105 | options. Same suggestion as above.</li> |
| 106 | |
| 107 | <li>Although Ada95 is an OO Language, this binding doesn't |
| 108 | provide an OO abstraction of the (n)curses functionality. As |
| 109 | mentioned above it's a thin binding for the (n)curses |
| 110 | functions. But without any doubt it would be nice to build on |
| 111 | top of this an OO abstraction of (n)curses functionality.<br> |
| 112 | The only exception is the method how fieldtypes are represented |
| 113 | in this Binding. We provide an abstract tagged type Field_Type |
| 114 | from which the various fieldtypes are derived.</li> |
| 115 | |
| 116 | <li>I currently do not support the link_fieldtype functionality |
| 117 | of the forms subsystem.</li> |
| 118 | |
| 119 | <li>The *_IO packages are currently output only.</li> |
| 120 | </ul> |
| 121 | |
| 122 | <h2>Hierarchy of packages</h2> |
| 123 | |
| 124 | <ul> |
| 125 | <li> |
| 126 | <a href= |
| 127 | "ada/terminal_interface__ads.htm">Terminal_Interface</a> |
| 128 | |
| 129 | <ul> |
| 130 | <li> |
| 131 | <a href= |
| 132 | "ada/terminal_interface-curses__ads.htm">Curses</a> |
| 133 | |
| 134 | <ul> |
| 135 | <li><a href= |
| 136 | "ada/terminal_interface-curses-mouse__ads.htm">Mouse</a></li> |
| 137 | |
| 138 | <li> |
| 139 | <a href= |
| 140 | "ada/terminal_interface-curses-panels__ads.htm">Panels</a> |
| 141 | |
| 142 | <ul> |
| 143 | <li><a href= |
| 144 | "ada/terminal_interface-curses-panels-user_data__ads.htm"> |
| 145 | User_Data</a></li> |
| 146 | </ul> |
| 147 | </li> |
| 148 | |
| 149 | <li> |
| 150 | <a href= |
| 151 | "ada/terminal_interface-curses-menus__ads.htm">Menus</a> |
| 152 | |
| 153 | <ul> |
| 154 | <li><a href= |
| 155 | "ada/terminal_interface-curses-menus-menu_user_data__ads.htm"> |
| 156 | Menu_User_Data</a></li> |
| 157 | |
| 158 | <li><a href= |
| 159 | "ada/terminal_interface-curses-menus-item_user_data__ads.htm"> |
| 160 | Item_User_Data</a></li> |
| 161 | </ul> |
| 162 | </li> |
| 163 | |
| 164 | <li> |
| 165 | <a href= |
| 166 | "ada/terminal_interface-curses-forms__ads.htm">Forms</a> |
| 167 | |
| 168 | <ul> |
| 169 | <li><a href= |
| 170 | "ada/terminal_interface-curses-forms-form_user_data__ads.htm"> |
| 171 | Form_User_Data</a></li> |
| 172 | |
| 173 | <li><a href= |
| 174 | "ada/terminal_interface-curses-forms-field_user_data__ads.htm"> |
| 175 | Field_User_Data</a></li> |
| 176 | |
| 177 | <li> |
| 178 | <a href= |
| 179 | "ada/terminal_interface-curses-forms-field_types__ads.htm"> |
| 180 | Field_Types</a> |
| 181 | |
| 182 | <ul> |
| 183 | <li><a href= |
| 184 | "ada/terminal_interface-curses-forms-field_types-alpha__ads.htm"> |
| 185 | Alpha</a></li> |
| 186 | |
| 187 | <li><a href= |
| 188 | "ada/terminal_interface-curses-forms-field_types-alphanumeric__ads.htm"> |
| 189 | AlphaNumeric</a></li> |
| 190 | |
| 191 | <li><a href= |
| 192 | "ada/terminal_interface-curses-forms-field_types-intfield__ads.htm"> |
| 193 | IntField</a></li> |
| 194 | |
| 195 | <li><a href= |
| 196 | "ada/terminal_interface-curses-forms-field_types-numeric__ads.htm"> |
| 197 | Numeric</a></li> |
| 198 | |
| 199 | <li><a href= |
| 200 | "ada/terminal_interface-curses-forms-field_types-regexp__ads.htm"> |
| 201 | RegExp</a></li> |
| 202 | |
| 203 | <li><a href= |
| 204 | "ada/terminal_interface-curses-forms-field_types-ipv4_address__ads.htm"> |
| 205 | IPV4_Address</a></li> |
| 206 | |
| 207 | <li> |
| 208 | <a href= |
| 209 | "ada/terminal_interface-curses-forms-field_types-enumeration__ads.htm"> |
| 210 | Enumeration</a> |
| 211 | |
| 212 | <ul> |
| 213 | <li><a href= |
| 214 | "ada/terminal_interface-curses-forms-field_types-enumeration-ada__ads.htm"> |
| 215 | Ada</a></li> |
| 216 | </ul> |
| 217 | </li> |
| 218 | |
| 219 | <li> |
| 220 | <a href= |
| 221 | "ada/terminal_interface-curses-forms-field_types-user__ads.htm"> |
| 222 | User</a> |
| 223 | |
| 224 | <ul> |
| 225 | <li><a href= |
| 226 | "ada/terminal_interface-curses-forms-field_types-user-choice__ads.htm"> |
| 227 | Choice</a></li> |
| 228 | </ul> |
| 229 | </li> |
| 230 | </ul> |
| 231 | </li> |
| 232 | </ul> |
| 233 | </li> |
| 234 | |
| 235 | <li> |
| 236 | <a href= |
| 237 | "ada/terminal_interface-curses-text_io__ads.htm">Text_IO</a> |
| 238 | |
| 239 | <ul> |
| 240 | <li><a href= |
| 241 | "ada/terminal_interface-curses-text_io-integer_io__ads.htm"> |
| 242 | Integer_IO</a></li> |
| 243 | |
| 244 | <li><a href= |
| 245 | "ada/terminal_interface-curses-text_io-float_io__ads.htm"> |
| 246 | Float_IO</a></li> |
| 247 | |
| 248 | <li><a href= |
| 249 | "ada/terminal_interface-curses-text_io-fixed_io__ads.htm"> |
| 250 | Fixed_IO</a></li> |
| 251 | |
| 252 | <li><a href= |
| 253 | "ada/terminal_interface-curses-text_io-decimal_io__ads.htm"> |
| 254 | Decimal_IO</a></li> |
| 255 | |
| 256 | <li><a href= |
| 257 | "ada/terminal_interface-curses-text_io-modular_io__ads.htm"> |
| 258 | Modular_IO</a></li> |
| 259 | |
| 260 | <li><a href= |
| 261 | "ada/terminal_interface-curses-text_io-enumeration_io__ads.htm"> |
| 262 | Enumeration_IO</a></li> |
| 263 | |
| 264 | <li><a href= |
| 265 | "ada/terminal_interface-curses-text_io-complex_io__ads.htm"> |
| 266 | Complex_IO</a></li> |
| 267 | </ul> |
| 268 | </li> |
| 269 | </ul> |
| 270 | </li> |
| 271 | </ul> |
| 272 | </li> |
| 273 | </ul> |
| 274 | |
| 275 | <p>If you want to navigate through the html pages of the package |
| 276 | specs, click <a href="ada/index.htm">here</a>.</p> |
| 277 | |
| 278 | <h2>Implementation Details</h2> |
| 279 | |
| 280 | <h4>Behind the abstraction</h4> |
| 281 | |
| 282 | <p>All the new types like <strong>Window</strong>, |
| 283 | <strong>Panel</strong>, <strong>Menu</strong>, |
| 284 | <strong>Form</strong> etc. are just opaque representations of the |
| 285 | pointers to the corresponding low level (n)curses structures like |
| 286 | <strong>WINDOW *</strong>, <strong>PANEL *</strong>, <strong>MENU |
| 287 | *</strong> or <strong>FORM *</strong>. So you can safely pass |
| 288 | them to C routines that expect a pointer to one of those |
| 289 | structures.</p> |
| 290 | |
| 291 | <h4>Extended ripoffline() usage</h4> |
| 292 | |
| 293 | <p>The official documentation of (n)curses says, that the line |
| 294 | parameter determines only whether or not exactly |
| 295 | <strong>one</strong> line is stolen from the top or bottom of the |
| 296 | screen. So essentially only the sign of the parameter is |
| 297 | evaluated. ncurses has internally implemented it in a way, that |
| 298 | uses the line parameter also to control the amount of lines to |
| 299 | steal. This mechanism is used in the |
| 300 | <strong>Rip_Off_Lines</strong> routine of the binding.</p> |
| 301 | |
| 302 | <h4><a name="userpointer" id="userpointer">How user defined field |
| 303 | types work</a></h4> |
| 304 | |
| 305 | <p>TBD</p> |
| 306 | |
| 307 | <h4>Enumeration fields handling</h4> |
| 308 | |
| 309 | <p>The (n)curses documentation says, that the String arrays to be |
| 310 | passed to an TYPE_ENUM fieldtype must not be automatic variables. |
| 311 | This is not true in this binding, because it is internally |
| 312 | arranged to safely copy these values.</p> |
| 313 | |
| 314 | <h4><a name="compiler" id="compiler">Using other Ada |
| 315 | compilers</a></h4> |
| 316 | |
| 317 | <p>This should basically not be a problem.</p> |
| 318 | |
| 319 | <h4>Port to other curses implementations</h4> |
| 320 | |
| 321 | <p>Basically it should not be too hard to make all this run on a |
| 322 | regular SVr4 implementation of curses. The problems are probably |
| 323 | these:<br></p> |
| 324 | |
| 325 | <ul> |
| 326 | <li>ncurses has some additional features which are presented in |
| 327 | this binding. You have two choices to deal with this: |
| 328 | |
| 329 | <ul> |
| 330 | <li>Emulate the feature in this binding</li> |
| 331 | |
| 332 | <li>Raise an exception for non implemented features</li> |
| 333 | </ul> |
| 334 | |
| 335 | <p>Most likely you will follow a mixed approach. Some |
| 336 | features are easy to simulate, others will be hard if not |
| 337 | impossible.</p> |
| 338 | </li> |
| 339 | </ul> |
| 340 | |
| 341 | <p>I'm quite sure I forgot something.</p> |
| 342 | </body> |
| 343 | </html> |