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