aboutsummaryrefslogtreecommitdiff
path: root/doc/html/Ada95.html
blob: 8d38806bf37af8e0453bff0d3233dfba700c3d27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!--
  $Id: Ada95.html,v 1.15 2019/03/16 19:39:05 tom Exp $
  ****************************************************************************
  * Copyright (c) 1998-2013,2019 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  * "Software"), to deal in the Software without restriction, including      *
  * without limitation the rights to use, copy, modify, merge, publish,      *
  * distribute, distribute with modifications, sublicense, and/or sell       *
  * copies of the Software, and to permit persons to whom the Software is    *
  * furnished to do so, subject to the following conditions:                 *
  *                                                                          *
  * The above copyright notice and this permission notice shall be included  *
  * in all copies or substantial portions of the Software.                   *
  *                                                                          *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
  *                                                                          *
  * Except as contained in this notice, the name(s) of the above copyright   *
  * holders shall not be used in advertising or otherwise to promote the     *
  * sale, use or other dealings in this Software without prior written       *
  * authorization.                                                           *
  ****************************************************************************
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org">

  <title>Ada95 Binding for ncurses</title>
  <link rel="author" href="mailto:bug-ncurses@gnu.org">
  <meta http-equiv="Content-Type" content=
  "text/html; charset=us-ascii">
</head>

<body>
  <h1>Ada95 Binding for ncurses</h1>

  <p>by J&uuml;rgen Pfeifer.</p>
  <hr>

  <h2>General Remarks</h2>

  <ul>
    <li>This document describes Version 01.00 of the binding.</li>

    <li>The functionality is modeled to be compatible with the
    ncurses package, a clone of the SVr4 curses model.<br>
    I did the development on an Intel box running the latest stable
    release of <a href="http://www.linux.org">Linux</a>, ncurses
    and the most recent released <a href="http://www.gnat.com">GNU
    Ada Translator</a> gnat versions. For any older versions of
    ncurses and gnat it is not guaranteed to work.</li>

    <li>You must have the m4 macroprocessor to build this package.
    If you don't have this program, you can get the FSF version
    <a href="ftp://ftp.gnu.org/pub/gnu/">here</a>.</li>

    <li>Ada programs are supposed to be readable. One of my
    favorite methods to make code readable is to use expressive
    names for the identifiers. You can find a list of a mapping of
    the cryptic curses names to the Ada names in this <a href=
    "ada/table.html">table</a>.</li>

    <li>This is not a typical one-to-one interface mapping. It is
    close to one-to-one on the functional level. Each (n)curses
    function has it's counterpart with a more or less similar
    formal parameter list in the binding. It is not one-to-one with
    respect to the datatypes. I tried to make records out of the
    flat chtype and similar structures, so you don't have to do bit
    operations to mark an attributed character as bold. Just make
    the boolean member <strong>bold</strong> of the record true.
    The binding also hides the structures like WINDOW, PANEL, MENU,
    FORM etc. ! It's a pure functional API.</li>

    <li>I try to do as much error checking as possible and feasible
    in the binding. I will raise an Ada exception when something
    went wrong in the low-level curses. This has the effect that -
    at least first time in my life - (n)curses programs have now a
    very rigid error checking, but - thanks to Ada - you don't have
    to code the orgiastic error checking style of C.</li>

    <li>Support for wide characters is currently not in the
    binding, as it is not really in ncurses at this point in
    time.</li>
  </ul>

  <h2>Limitations</h2>

  <ul>
    <li>I provide no SCREEN datatype and functions to set a new
    screen. If you need this (mostly for debugging I guess), write
    a small C routine doing all this and import it into your Ada
    program.</li>

    <li>I provide no functions to switch on/off curses tracing
    options. Same suggestion as above.</li>

    <li>Although Ada95 is an OO Language, this binding doesn't
    provide an OO abstraction of the (n)curses functionality. As
    mentioned above it's a thin binding for the (n)curses
    functions. But without any doubt it would be nice to build on
    top of this an OO abstraction of (n)curses functionality.<br>
    The only exception is the method how fieldtypes are represented
    in this Binding. We provide an abstract tagged type Field_Type
    from which the various fieldtypes are derived.</li>

    <li>I currently do not support the link_fieldtype functionality
    of the forms subsystem.</li>

    <li>The *_IO packages are currently output only.</li>
  </ul>

  <h2>Hierarchy of packages</h2>

  <ul>
    <li>
      <a href=
      "ada/terminal_interface__ads.htm">Terminal_Interface</a>

      <ul>
        <li>
          <a href=
          "ada/terminal_interface-curses__ads.htm">Curses</a>

          <ul>
            <li><a href=
            "ada/terminal_interface-curses-mouse__ads.htm">Mouse</a></li>

            <li>
              <a href=
              "ada/terminal_interface-curses-panels__ads.htm">Panels</a>

              <ul>
                <li><a href=
                "ada/terminal_interface-curses-panels-user_data__ads.htm">
                User_Data</a></li>
              </ul>
            </li>

            <li>
              <a href=
              "ada/terminal_interface-curses-menus__ads.htm">Menus</a>

              <ul>
                <li><a href=
                "ada/terminal_interface-curses-menus-menu_user_data__ads.htm">
                Menu_User_Data</a></li>

                <li><a href=
                "ada/terminal_interface-curses-menus-item_user_data__ads.htm">
                Item_User_Data</a></li>
              </ul>
            </li>

            <li>
              <a href=
              "ada/terminal_interface-curses-forms__ads.htm">Forms</a>

              <ul>
                <li><a href=
                "ada/terminal_interface-curses-forms-form_user_data__ads.htm">
                Form_User_Data</a></li>

                <li><a href=
                "ada/terminal_interface-curses-forms-field_user_data__ads.htm">
                Field_User_Data</a></li>

                <li>
                  <a href=
                  "ada/terminal_interface-curses-forms-field_types__ads.htm">
                  Field_Types</a>

                  <ul>
                    <li><a href=
                    "ada/terminal_interface-curses-forms-field_types-alpha__ads.htm">
                    Alpha</a></li>

                    <li><a href=
                    "ada/terminal_interface-curses-forms-field_types-alphanumeric__ads.htm">
                    AlphaNumeric</a></li>

                    <li><a href=
                    "ada/terminal_interface-curses-forms-field_types-intfield__ads.htm">
                    IntField</a></li>

                    <li><a href=
                    "ada/terminal_interface-curses-forms-field_types-numeric__ads.htm">
                    Numeric</a></li>

                    <li><a href=
                    "ada/terminal_interface-curses-forms-field_types-regexp__ads.htm">
                    RegExp</a></li>

                    <li><a href=
                    "ada/terminal_interface-curses-forms-field_types-ipv4_address__ads.htm">
                    IPV4_Address</a></li>

                    <li>
                      <a href=
                      "ada/terminal_interface-curses-forms-field_types-enumeration__ads.htm">
                      Enumeration</a>

                      <ul>
                        <li><a href=
                        "ada/terminal_interface-curses-forms-field_types-enumeration-ada__ads.htm">
                        Ada</a></li>
                      </ul>
                    </li>

                    <li>
                      <a href=
                      "ada/terminal_interface-curses-forms-field_types-user__ads.htm">
                      User</a>

                      <ul>
                        <li><a href=
                        "ada/terminal_interface-curses-forms-field_types-user-choice__ads.htm">
                        Choice</a></li>
                      </ul>
                    </li>
                  </ul>
                </li>
              </ul>
            </li>

            <li>
              <a href=
              "ada/terminal_interface-curses-text_io__ads.htm">Text_IO</a>

              <ul>
                <li><a href=
                "ada/terminal_interface-curses-text_io-integer_io__ads.htm">
                Integer_IO</a></li>

                <li><a href=
                "ada/terminal_interface-curses-text_io-float_io__ads.htm">
                Float_IO</a></li>

                <li><a href=
                "ada/terminal_interface-curses-text_io-fixed_io__ads.htm">
                Fixed_IO</a></li>

                <li><a href=
                "ada/terminal_interface-curses-text_io-decimal_io__ads.htm">
                Decimal_IO</a></li>

                <li><a href=
                "ada/terminal_interface-curses-text_io-modular_io__ads.htm">
                Modular_IO</a></li>

                <li><a href=
                "ada/terminal_interface-curses-text_io-enumeration_io__ads.htm">
                Enumeration_IO</a></li>

                <li><a href=
                "ada/terminal_interface-curses-text_io-complex_io__ads.htm">
                Complex_IO</a></li>
              </ul>
            </li>
          </ul>
        </li>
      </ul>
    </li>
  </ul>

  <p>If you want to navigate through the html pages of the package
  specs, click <a href="ada/index.htm">here</a>.</p>

  <h2>Implementation Details</h2>

  <h4>Behind the abstraction</h4>

  <p>All the new types like <strong>Window</strong>,
  <strong>Panel</strong>, <strong>Menu</strong>,
  <strong>Form</strong> etc. are just opaque representations of the
  pointers to the corresponding low level (n)curses structures like
  <strong>WINDOW *</strong>, <strong>PANEL *</strong>, <strong>MENU
  *</strong> or <strong>FORM *</strong>. So you can safely pass
  them to C routines that expect a pointer to one of those
  structures.</p>

  <h4>Extended ripoffline() usage</h4>

  <p>The official documentation of (n)curses says, that the line
  parameter determines only whether or not exactly
  <strong>one</strong> line is stolen from the top or bottom of the
  screen. So essentially only the sign of the parameter is
  evaluated. ncurses has internally implemented it in a way, that
  uses the line parameter also to control the amount of lines to
  steal. This mechanism is used in the
  <strong>Rip_Off_Lines</strong> routine of the binding.</p>

  <h4><a name="userpointer" id="userpointer">How user defined field
  types work</a></h4>

  <p>TBD</p>

  <h4>Enumeration fields handling</h4>

  <p>The (n)curses documentation says, that the String arrays to be
  passed to an TYPE_ENUM fieldtype must not be automatic variables.
  This is not true in this binding, because it is internally
  arranged to safely copy these values.</p>

  <h4><a name="compiler" id="compiler">Using other Ada
  compilers</a></h4>

  <p>This should basically not be a problem.</p>

  <h4>Port to other curses implementations</h4>

  <p>Basically it should not be too hard to make all this run on a
  regular SVr4 implementation of curses. The problems are probably
  these:<br></p>

  <ul>
    <li>ncurses has some additional features which are presented in
    this binding. You have two choices to deal with this:

      <ul>
        <li>Emulate the feature in this binding</li>

        <li>Raise an exception for non implemented features</li>
      </ul>

      <p>Most likely you will follow a mixed approach. Some
      features are easy to simulate, others will be hard if not
      impossible.</p>
    </li>
  </ul>

  <p>I'm quite sure I forgot something.</p>
</body>
</html>