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