ncurses 6.2 - patch 20200212
[ncurses.git] / Ada95 / gen / gen.c
1 /****************************************************************************
2  * Copyright 2020 Thomas E. Dickey                                          *
3  * Copyright 1998-2014,2016 Free Software Foundation, Inc.                  *
4  *                                                                          *
5  * Permission is hereby granted, free of charge, to any person obtaining a  *
6  * copy of this software and associated documentation files (the            *
7  * "Software"), to deal in the Software without restriction, including      *
8  * without limitation the rights to use, copy, modify, merge, publish,      *
9  * distribute, distribute with modifications, sublicense, and/or sell       *
10  * copies of the Software, and to permit persons to whom the Software is    *
11  * furnished to do so, subject to the following conditions:                 *
12  *                                                                          *
13  * The above copyright notice and this permission notice shall be included  *
14  * in all copies or substantial portions of the Software.                   *
15  *                                                                          *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23  *                                                                          *
24  * Except as contained in this notice, the name(s) of the above copyright   *
25  * holders shall not be used in advertising or otherwise to promote the     *
26  * sale, use or other dealings in this Software without prior written       *
27  * authorization.                                                           *
28  ****************************************************************************/
29
30 /****************************************************************************
31  *   Author:  Juergen Pfeifer, 1996                                         *
32  ****************************************************************************/
33
34 /*
35     Version Control
36     $Id: gen.c,v 1.71 2020/02/02 23:34:34 tom Exp $
37   --------------------------------------------------------------------------*/
38 /*
39   This program prints on its standard output the source for the
40   Terminal_Interface.Curses_Constants Ada package specification. This pure
41   package only exports C constants to the Ada compiler.
42  */
43
44 #ifdef HAVE_CONFIG_H
45 #include <ncurses_cfg.h>
46 #else
47 #include <ncurses.h>
48 #endif
49
50 #include <stdlib.h>
51 #include <string.h>
52
53 #include <menu.h>
54 #include <form.h>
55
56 #undef UCHAR
57 #undef UINT
58
59 typedef unsigned char UCHAR;
60 typedef unsigned int UINT;
61
62 /* These global variables will be set by main () */
63 static int little_endian;
64 static const char *my_program_invocation_name = NULL;
65
66 static void
67 my_error(const char *message)
68 {
69   fprintf(stderr, "%s: %s\n", my_program_invocation_name, message);
70   exit(EXIT_FAILURE);
71 }
72
73 static void
74 print_constant(const char *name,
75                long value)
76 {
77   printf("   %-28s : constant := %ld;\n", name, value);
78 }
79
80 #define PRINT_NAMED_CONSTANT(name) \
81   print_constant (#name, name)
82
83 static void
84 print_comment(const char *message)
85 {
86   printf("\n   --  %s\n\n", message);
87 }
88
89 /*
90  * Make sure that KEY_MIN and KEY_MAX are defined.
91  * main () will protest if KEY_MIN == 256
92  */
93 #ifndef KEY_MAX
94 #  define KEY_MAX 0777
95 #endif
96 #ifndef KEY_MIN
97 #  define KEY_MIN 0401
98 #endif
99
100 static UCHAR
101 bit_is_set(const UCHAR * const data,
102            const UINT offset)
103 {
104   const UCHAR byte = data[offset >> 3];
105   UINT bit;
106
107   if (little_endian)
108     bit = offset;               /* offset */
109   else                          /* or */
110     bit = ~offset;              /* 7 - offset */
111   bit &= 7;                     /* modulo 8 */
112   return (UCHAR) (byte & (1 << bit));
113 }
114
115 /* Find lowest and highest used offset in a byte array. */
116 /* Returns 0 if and only if all bits are unset. */
117 static int
118 find_pos(const UCHAR * const data,
119          const UINT sizeof_data,
120          UINT * const low,
121          UINT * const high)
122 {
123   const UINT last = (sizeof_data << 3) - 1;
124   UINT offset;
125
126   for (offset = last; !bit_is_set(data, offset); offset--)
127     if (!offset)                /* All bits are 0. */
128       return 0;
129   *high = offset;
130
131   for (offset = 0; !bit_is_set(data, offset); offset++)
132     {
133     }
134   *low = offset;
135
136   return -1;
137 }
138
139 #define PRINT_BITMASK(c_type, ada_name, mask_macro)                     \
140   {                                                                     \
141     UINT first, last;                                                   \
142     c_type mask = (mask_macro);                                         \
143     if (!find_pos ((UCHAR *)&mask, sizeof (mask), &first, &last))       \
144       my_error ("failed to locate " ada_name);                          \
145     print_constant (ada_name "_First", first);                          \
146     print_constant (ada_name "_Last", last);                            \
147   }
148
149 #define PRINT_NAMED_BITMASK(c_type, mask_macro)         \
150   PRINT_BITMASK (c_type, #mask_macro, mask_macro)
151
152 #define STRUCT_OFFSET(record, field)                                    \
153   {                                                                     \
154     UINT first, last;                                                   \
155     record mask;                                                        \
156     memset (&mask, 0, sizeof (mask));                                   \
157     memset (&mask.field, 0xff, sizeof(mask.field));                     \
158     if (!find_pos ((UCHAR *)&mask, sizeof (mask), &first, &last))       \
159       my_error ("failed to locate" #record "_" #field);                 \
160     print_constant (#record "_" #field "_First", first);                \
161     print_constant (#record "_" #field "_Last", last);                  \
162   }
163
164 /*--------------------*/
165 /*  Start of main (). */
166 /*--------------------*/
167
168 int
169 main(int argc, const char *argv[])
170 {
171   const int x = 0x12345678;
172
173   little_endian = (*((const char *)&x) == 0x78);
174
175   my_program_invocation_name = argv[0];
176
177   if (KEY_MIN == 256)
178     my_error("unexpected value for KEY_MIN: 256");
179
180   if (argc != 2)
181     my_error("Only one argument expected (DFT_ARG_SUFFIX)");
182
183   printf("--  Generated by the C program %s (source " __FILE__ ").\n",
184          my_program_invocation_name);
185   printf("--  Do not edit this file directly.\n");
186   printf("--  The values provided here may vary on your system.\n");
187   printf("\n");
188   printf("with System;\n");
189   printf("package Terminal_Interface.Curses_Constants is\n");
190   printf("   pragma Pure;\n");
191   printf("\n");
192
193   printf("   DFT_ARG_SUFFIX : constant String := \"%s\";\n", argv[1]);
194   printf("   Bit_Order : constant System.Bit_Order := System.%s_Order_First;\n",
195          little_endian ? "Low" : "High");
196   print_constant("Sizeof_Bool", 8 * sizeof(bool));
197
198   PRINT_NAMED_CONSTANT(OK);
199   PRINT_NAMED_CONSTANT(ERR);
200   printf("   pragma Warnings (Off); -- redefinition of Standard.True and False\n");
201   PRINT_NAMED_CONSTANT(TRUE);
202   PRINT_NAMED_CONSTANT(FALSE);
203   printf("   pragma Warnings (On);\n");
204
205   print_comment("Version of the ncurses library from extensions(3NCURSES)");
206   PRINT_NAMED_CONSTANT(NCURSES_VERSION_MAJOR);
207   PRINT_NAMED_CONSTANT(NCURSES_VERSION_MINOR);
208   printf("   Version : constant String := \"%d.%d\";\n",
209          NCURSES_VERSION_MAJOR, NCURSES_VERSION_MINOR);
210
211   print_comment("Character non-color attributes from attr(3NCURSES)");
212   printf("   --  attr_t and chtype may be signed in C.\n");
213   printf("   type attr_t is mod 2 ** %lu;\n", (long unsigned)(8 * sizeof(attr_t)));
214   PRINT_NAMED_BITMASK(attr_t, A_CHARTEXT);
215   PRINT_NAMED_BITMASK(attr_t, A_COLOR);
216   PRINT_BITMASK(attr_t, "Attr", A_ATTRIBUTES & ~A_COLOR);
217   PRINT_NAMED_BITMASK(attr_t, A_STANDOUT);
218   PRINT_NAMED_BITMASK(attr_t, A_UNDERLINE);
219   PRINT_NAMED_BITMASK(attr_t, A_REVERSE);
220   PRINT_NAMED_BITMASK(attr_t, A_BLINK);
221   PRINT_NAMED_BITMASK(attr_t, A_DIM);
222   PRINT_NAMED_BITMASK(attr_t, A_BOLD);
223   PRINT_NAMED_BITMASK(attr_t, A_PROTECT);
224   PRINT_NAMED_BITMASK(attr_t, A_INVIS);
225   PRINT_NAMED_BITMASK(attr_t, A_ALTCHARSET);
226   PRINT_NAMED_BITMASK(attr_t, A_HORIZONTAL);
227   PRINT_NAMED_BITMASK(attr_t, A_LEFT);
228   PRINT_NAMED_BITMASK(attr_t, A_LOW);
229   PRINT_NAMED_BITMASK(attr_t, A_RIGHT);
230   PRINT_NAMED_BITMASK(attr_t, A_TOP);
231   PRINT_NAMED_BITMASK(attr_t, A_VERTICAL);
232   print_constant("chtype_Size", 8 * sizeof(chtype));
233
234   print_comment("predefined color numbers from color(3NCURSES)");
235   PRINT_NAMED_CONSTANT(COLOR_BLACK);
236   PRINT_NAMED_CONSTANT(COLOR_RED);
237   PRINT_NAMED_CONSTANT(COLOR_GREEN);
238   PRINT_NAMED_CONSTANT(COLOR_YELLOW);
239   PRINT_NAMED_CONSTANT(COLOR_BLUE);
240   PRINT_NAMED_CONSTANT(COLOR_MAGENTA);
241   PRINT_NAMED_CONSTANT(COLOR_CYAN);
242   PRINT_NAMED_CONSTANT(COLOR_WHITE);
243
244   print_comment("ETI return codes from ncurses.h");
245   PRINT_NAMED_CONSTANT(E_OK);
246   PRINT_NAMED_CONSTANT(E_SYSTEM_ERROR);
247   PRINT_NAMED_CONSTANT(E_BAD_ARGUMENT);
248   PRINT_NAMED_CONSTANT(E_POSTED);
249   PRINT_NAMED_CONSTANT(E_CONNECTED);
250   PRINT_NAMED_CONSTANT(E_BAD_STATE);
251   PRINT_NAMED_CONSTANT(E_NO_ROOM);
252   PRINT_NAMED_CONSTANT(E_NOT_POSTED);
253   PRINT_NAMED_CONSTANT(E_UNKNOWN_COMMAND);
254   PRINT_NAMED_CONSTANT(E_NO_MATCH);
255   PRINT_NAMED_CONSTANT(E_NOT_SELECTABLE);
256   PRINT_NAMED_CONSTANT(E_NOT_CONNECTED);
257   PRINT_NAMED_CONSTANT(E_REQUEST_DENIED);
258   PRINT_NAMED_CONSTANT(E_INVALID_FIELD);
259   PRINT_NAMED_CONSTANT(E_CURRENT);
260
261   print_comment("Input key codes not defined in any ncurses manpage");
262   PRINT_NAMED_CONSTANT(KEY_MIN);
263   PRINT_NAMED_CONSTANT(KEY_MAX);
264 #ifdef KEY_CODE_YES
265   PRINT_NAMED_CONSTANT(KEY_CODE_YES);
266 #endif
267
268   print_comment("Input key codes from getch(3NCURSES)");
269   PRINT_NAMED_CONSTANT(KEY_BREAK);
270   PRINT_NAMED_CONSTANT(KEY_DOWN);
271   PRINT_NAMED_CONSTANT(KEY_UP);
272   PRINT_NAMED_CONSTANT(KEY_LEFT);
273   PRINT_NAMED_CONSTANT(KEY_RIGHT);
274   PRINT_NAMED_CONSTANT(KEY_HOME);
275   PRINT_NAMED_CONSTANT(KEY_BACKSPACE);
276   PRINT_NAMED_CONSTANT(KEY_F0);
277   print_constant("KEY_F1", KEY_F(1));
278   print_constant("KEY_F2", KEY_F(2));
279   print_constant("KEY_F3", KEY_F(3));
280   print_constant("KEY_F4", KEY_F(4));
281   print_constant("KEY_F5", KEY_F(5));
282   print_constant("KEY_F6", KEY_F(6));
283   print_constant("KEY_F7", KEY_F(7));
284   print_constant("KEY_F8", KEY_F(8));
285   print_constant("KEY_F9", KEY_F(9));
286   print_constant("KEY_F10", KEY_F(10));
287   print_constant("KEY_F11", KEY_F(11));
288   print_constant("KEY_F12", KEY_F(12));
289   print_constant("KEY_F13", KEY_F(13));
290   print_constant("KEY_F14", KEY_F(14));
291   print_constant("KEY_F15", KEY_F(15));
292   print_constant("KEY_F16", KEY_F(16));
293   print_constant("KEY_F17", KEY_F(17));
294   print_constant("KEY_F18", KEY_F(18));
295   print_constant("KEY_F19", KEY_F(19));
296   print_constant("KEY_F20", KEY_F(20));
297   print_constant("KEY_F21", KEY_F(21));
298   print_constant("KEY_F22", KEY_F(22));
299   print_constant("KEY_F23", KEY_F(23));
300   print_constant("KEY_F24", KEY_F(24));
301   PRINT_NAMED_CONSTANT(KEY_DL);
302   PRINT_NAMED_CONSTANT(KEY_IL);
303   PRINT_NAMED_CONSTANT(KEY_DC);
304   PRINT_NAMED_CONSTANT(KEY_IC);
305   PRINT_NAMED_CONSTANT(KEY_EIC);
306   PRINT_NAMED_CONSTANT(KEY_CLEAR);
307   PRINT_NAMED_CONSTANT(KEY_EOS);
308   PRINT_NAMED_CONSTANT(KEY_EOL);
309   PRINT_NAMED_CONSTANT(KEY_SF);
310   PRINT_NAMED_CONSTANT(KEY_SR);
311   PRINT_NAMED_CONSTANT(KEY_NPAGE);
312   PRINT_NAMED_CONSTANT(KEY_PPAGE);
313   PRINT_NAMED_CONSTANT(KEY_STAB);
314   PRINT_NAMED_CONSTANT(KEY_CTAB);
315   PRINT_NAMED_CONSTANT(KEY_CATAB);
316   PRINT_NAMED_CONSTANT(KEY_ENTER);
317   PRINT_NAMED_CONSTANT(KEY_SRESET);
318   PRINT_NAMED_CONSTANT(KEY_RESET);
319   PRINT_NAMED_CONSTANT(KEY_PRINT);
320   PRINT_NAMED_CONSTANT(KEY_LL);
321   PRINT_NAMED_CONSTANT(KEY_A1);
322   PRINT_NAMED_CONSTANT(KEY_A3);
323   PRINT_NAMED_CONSTANT(KEY_B2);
324   PRINT_NAMED_CONSTANT(KEY_C1);
325   PRINT_NAMED_CONSTANT(KEY_C3);
326   PRINT_NAMED_CONSTANT(KEY_BTAB);
327   PRINT_NAMED_CONSTANT(KEY_BEG);
328   PRINT_NAMED_CONSTANT(KEY_CANCEL);
329   PRINT_NAMED_CONSTANT(KEY_CLOSE);
330   PRINT_NAMED_CONSTANT(KEY_COMMAND);
331   PRINT_NAMED_CONSTANT(KEY_COPY);
332   PRINT_NAMED_CONSTANT(KEY_CREATE);
333   PRINT_NAMED_CONSTANT(KEY_END);
334   PRINT_NAMED_CONSTANT(KEY_EXIT);
335   PRINT_NAMED_CONSTANT(KEY_FIND);
336   PRINT_NAMED_CONSTANT(KEY_HELP);
337   PRINT_NAMED_CONSTANT(KEY_MARK);
338   PRINT_NAMED_CONSTANT(KEY_MESSAGE);
339   PRINT_NAMED_CONSTANT(KEY_MOVE);
340   PRINT_NAMED_CONSTANT(KEY_NEXT);
341   PRINT_NAMED_CONSTANT(KEY_OPEN);
342   PRINT_NAMED_CONSTANT(KEY_OPTIONS);
343   PRINT_NAMED_CONSTANT(KEY_PREVIOUS);
344   PRINT_NAMED_CONSTANT(KEY_REDO);
345   PRINT_NAMED_CONSTANT(KEY_REFERENCE);
346   PRINT_NAMED_CONSTANT(KEY_REFRESH);
347   PRINT_NAMED_CONSTANT(KEY_REPLACE);
348   PRINT_NAMED_CONSTANT(KEY_RESTART);
349   PRINT_NAMED_CONSTANT(KEY_RESUME);
350   PRINT_NAMED_CONSTANT(KEY_SAVE);
351   PRINT_NAMED_CONSTANT(KEY_SBEG);
352   PRINT_NAMED_CONSTANT(KEY_SCANCEL);
353   PRINT_NAMED_CONSTANT(KEY_SCOMMAND);
354   PRINT_NAMED_CONSTANT(KEY_SCOPY);
355   PRINT_NAMED_CONSTANT(KEY_SCREATE);
356   PRINT_NAMED_CONSTANT(KEY_SDC);
357   PRINT_NAMED_CONSTANT(KEY_SDL);
358   PRINT_NAMED_CONSTANT(KEY_SELECT);
359   PRINT_NAMED_CONSTANT(KEY_SEND);
360   PRINT_NAMED_CONSTANT(KEY_SEOL);
361   PRINT_NAMED_CONSTANT(KEY_SEXIT);
362   PRINT_NAMED_CONSTANT(KEY_SFIND);
363   PRINT_NAMED_CONSTANT(KEY_SHELP);
364   PRINT_NAMED_CONSTANT(KEY_SHOME);
365   PRINT_NAMED_CONSTANT(KEY_SIC);
366   PRINT_NAMED_CONSTANT(KEY_SLEFT);
367   PRINT_NAMED_CONSTANT(KEY_SMESSAGE);
368   PRINT_NAMED_CONSTANT(KEY_SMOVE);
369   PRINT_NAMED_CONSTANT(KEY_SNEXT);
370   PRINT_NAMED_CONSTANT(KEY_SOPTIONS);
371   PRINT_NAMED_CONSTANT(KEY_SPREVIOUS);
372   PRINT_NAMED_CONSTANT(KEY_SPRINT);
373   PRINT_NAMED_CONSTANT(KEY_SREDO);
374   PRINT_NAMED_CONSTANT(KEY_SREPLACE);
375   PRINT_NAMED_CONSTANT(KEY_SRIGHT);
376   PRINT_NAMED_CONSTANT(KEY_SRSUME);
377   PRINT_NAMED_CONSTANT(KEY_SSAVE);
378   PRINT_NAMED_CONSTANT(KEY_SSUSPEND);
379   PRINT_NAMED_CONSTANT(KEY_SUNDO);
380   PRINT_NAMED_CONSTANT(KEY_SUSPEND);
381   PRINT_NAMED_CONSTANT(KEY_UNDO);
382   PRINT_NAMED_CONSTANT(KEY_MOUSE);
383   PRINT_NAMED_CONSTANT(KEY_RESIZE);
384
385   print_comment("alternate character codes (ACS) from addch(3NCURSES)");
386 #define PRINT_ACS(name) print_constant (#name, &name - &acs_map[0])
387   PRINT_ACS(ACS_ULCORNER);
388   PRINT_ACS(ACS_LLCORNER);
389   PRINT_ACS(ACS_URCORNER);
390   PRINT_ACS(ACS_LRCORNER);
391   PRINT_ACS(ACS_LTEE);
392   PRINT_ACS(ACS_RTEE);
393   PRINT_ACS(ACS_BTEE);
394   PRINT_ACS(ACS_TTEE);
395   PRINT_ACS(ACS_HLINE);
396   PRINT_ACS(ACS_VLINE);
397   PRINT_ACS(ACS_PLUS);
398   PRINT_ACS(ACS_S1);
399   PRINT_ACS(ACS_S9);
400   PRINT_ACS(ACS_DIAMOND);
401   PRINT_ACS(ACS_CKBOARD);
402   PRINT_ACS(ACS_DEGREE);
403   PRINT_ACS(ACS_PLMINUS);
404   PRINT_ACS(ACS_BULLET);
405   PRINT_ACS(ACS_LARROW);
406   PRINT_ACS(ACS_RARROW);
407   PRINT_ACS(ACS_DARROW);
408   PRINT_ACS(ACS_UARROW);
409   PRINT_ACS(ACS_BOARD);
410   PRINT_ACS(ACS_LANTERN);
411   PRINT_ACS(ACS_BLOCK);
412   PRINT_ACS(ACS_S3);
413   PRINT_ACS(ACS_S7);
414   PRINT_ACS(ACS_LEQUAL);
415   PRINT_ACS(ACS_GEQUAL);
416   PRINT_ACS(ACS_PI);
417   PRINT_ACS(ACS_NEQUAL);
418   PRINT_ACS(ACS_STERLING);
419
420   print_comment("Menu_Options from opts(3MENU)");
421   PRINT_NAMED_BITMASK(Menu_Options, O_ONEVALUE);
422   PRINT_NAMED_BITMASK(Menu_Options, O_SHOWDESC);
423   PRINT_NAMED_BITMASK(Menu_Options, O_ROWMAJOR);
424   PRINT_NAMED_BITMASK(Menu_Options, O_IGNORECASE);
425   PRINT_NAMED_BITMASK(Menu_Options, O_SHOWMATCH);
426   PRINT_NAMED_BITMASK(Menu_Options, O_NONCYCLIC);
427   print_constant("Menu_Options_Size", 8 * sizeof(Menu_Options));
428
429   print_comment("Item_Options from menu_opts(3MENU)");
430   PRINT_NAMED_BITMASK(Item_Options, O_SELECTABLE);
431   print_constant("Item_Options_Size", 8 * sizeof(Item_Options));
432
433   print_comment("Field_Options from field_opts(3FORM)");
434   PRINT_NAMED_BITMASK(Field_Options, O_VISIBLE);
435   PRINT_NAMED_BITMASK(Field_Options, O_ACTIVE);
436   PRINT_NAMED_BITMASK(Field_Options, O_PUBLIC);
437   PRINT_NAMED_BITMASK(Field_Options, O_EDIT);
438   PRINT_NAMED_BITMASK(Field_Options, O_WRAP);
439   PRINT_NAMED_BITMASK(Field_Options, O_BLANK);
440   PRINT_NAMED_BITMASK(Field_Options, O_AUTOSKIP);
441   PRINT_NAMED_BITMASK(Field_Options, O_NULLOK);
442   PRINT_NAMED_BITMASK(Field_Options, O_PASSOK);
443   PRINT_NAMED_BITMASK(Field_Options, O_STATIC);
444   print_constant("Field_Options_Size", 8 * sizeof(Field_Options));
445
446   print_comment("Field_Options from opts(3FORM)");
447   PRINT_NAMED_BITMASK(Field_Options, O_NL_OVERLOAD);
448   PRINT_NAMED_BITMASK(Field_Options, O_BS_OVERLOAD);
449   /*  Field_Options_Size is defined below */
450
451   print_comment("MEVENT structure from mouse(3NCURSES)");
452   STRUCT_OFFSET(MEVENT, id);
453   STRUCT_OFFSET(MEVENT, x);
454   STRUCT_OFFSET(MEVENT, y);
455   STRUCT_OFFSET(MEVENT, z);
456   STRUCT_OFFSET(MEVENT, bstate);
457   print_constant("MEVENT_Size", 8 * sizeof(MEVENT));
458
459   print_comment("mouse events from mouse(3NCURSES)");
460   {
461     mmask_t all_events;
462
463 #define PRINT_MOUSE_EVENT(event)                \
464     print_constant (#event, event);             \
465     all_events |= event
466
467     all_events = 0;
468     PRINT_MOUSE_EVENT(BUTTON1_RELEASED);
469     PRINT_MOUSE_EVENT(BUTTON1_PRESSED);
470     PRINT_MOUSE_EVENT(BUTTON1_CLICKED);
471     PRINT_MOUSE_EVENT(BUTTON1_DOUBLE_CLICKED);
472     PRINT_MOUSE_EVENT(BUTTON1_TRIPLE_CLICKED);
473 #ifdef BUTTON1_RESERVED_EVENT
474     PRINT_MOUSE_EVENT(BUTTON1_RESERVED_EVENT);
475 #endif
476     print_constant("all_events_button_1", (long)all_events);
477
478     all_events = 0;
479     PRINT_MOUSE_EVENT(BUTTON2_RELEASED);
480     PRINT_MOUSE_EVENT(BUTTON2_PRESSED);
481     PRINT_MOUSE_EVENT(BUTTON2_CLICKED);
482     PRINT_MOUSE_EVENT(BUTTON2_DOUBLE_CLICKED);
483     PRINT_MOUSE_EVENT(BUTTON2_TRIPLE_CLICKED);
484 #ifdef BUTTON2_RESERVED_EVENT
485     PRINT_MOUSE_EVENT(BUTTON2_RESERVED_EVENT);
486 #endif
487     print_constant("all_events_button_2", (long)all_events);
488
489     all_events = 0;
490     PRINT_MOUSE_EVENT(BUTTON3_RELEASED);
491     PRINT_MOUSE_EVENT(BUTTON3_PRESSED);
492     PRINT_MOUSE_EVENT(BUTTON3_CLICKED);
493     PRINT_MOUSE_EVENT(BUTTON3_DOUBLE_CLICKED);
494     PRINT_MOUSE_EVENT(BUTTON3_TRIPLE_CLICKED);
495 #ifdef BUTTON3_RESERVED_EVENT
496     PRINT_MOUSE_EVENT(BUTTON3_RESERVED_EVENT);
497 #endif
498     print_constant("all_events_button_3", (long)all_events);
499
500     all_events = 0;
501     PRINT_MOUSE_EVENT(BUTTON4_RELEASED);
502     PRINT_MOUSE_EVENT(BUTTON4_PRESSED);
503     PRINT_MOUSE_EVENT(BUTTON4_CLICKED);
504     PRINT_MOUSE_EVENT(BUTTON4_DOUBLE_CLICKED);
505     PRINT_MOUSE_EVENT(BUTTON4_TRIPLE_CLICKED);
506 #ifdef BUTTON4_RESERVED_EVENT
507     PRINT_MOUSE_EVENT(BUTTON4_RESERVED_EVENT);
508 #endif
509     print_constant("all_events_button_4", (long)all_events);
510   }
511   PRINT_NAMED_CONSTANT(BUTTON_CTRL);
512   PRINT_NAMED_CONSTANT(BUTTON_SHIFT);
513   PRINT_NAMED_CONSTANT(BUTTON_ALT);
514   PRINT_NAMED_CONSTANT(REPORT_MOUSE_POSITION);
515   PRINT_NAMED_CONSTANT(ALL_MOUSE_EVENTS);
516
517   print_comment("trace selection from trace(3NCURSES)");
518   PRINT_NAMED_BITMASK(UINT, TRACE_TIMES);
519   PRINT_NAMED_BITMASK(UINT, TRACE_TPUTS);
520   PRINT_NAMED_BITMASK(UINT, TRACE_UPDATE);
521   PRINT_NAMED_BITMASK(UINT, TRACE_MOVE);
522   PRINT_NAMED_BITMASK(UINT, TRACE_CHARPUT);
523   PRINT_NAMED_BITMASK(UINT, TRACE_CALLS);
524   PRINT_NAMED_BITMASK(UINT, TRACE_VIRTPUT);
525   PRINT_NAMED_BITMASK(UINT, TRACE_IEVENT);
526   PRINT_NAMED_BITMASK(UINT, TRACE_BITS);
527   PRINT_NAMED_BITMASK(UINT, TRACE_ICALLS);
528   PRINT_NAMED_BITMASK(UINT, TRACE_CCALLS);
529   PRINT_NAMED_BITMASK(UINT, TRACE_DATABASE);
530   PRINT_NAMED_BITMASK(UINT, TRACE_ATTRS);
531   print_constant("Trace_Size", 8 * sizeof(UINT));
532
533   printf("end Terminal_Interface.Curses_Constants;\n");
534   exit(EXIT_SUCCESS);
535 }