ncurses 6.2 - patch 20200222
[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.72 2020/02/22 21:01:00 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   if ((strlen(argv[0]) + strlen(__FILE__)) > 25)
184     {
185       printf("--  Generated by the C program %.40s.\n",
186              my_program_invocation_name);
187     }
188   else
189     {
190       printf("--  Generated by the C program %s (source %s).\n",
191              my_program_invocation_name,
192              __FILE__);
193     }
194   printf("--  Do not edit this file directly.\n");
195   printf("--  The values provided here may vary on your system.\n");
196   printf("\n");
197   printf("with System;\n");
198   printf("package Terminal_Interface.Curses_Constants is\n");
199   printf("   pragma Pure;\n");
200   printf("\n");
201
202   printf("   DFT_ARG_SUFFIX : constant String := \"%s\";\n", argv[1]);
203   printf("   Bit_Order : constant System.Bit_Order := System.%s_Order_First;\n",
204          little_endian ? "Low" : "High");
205   print_constant("Sizeof_Bool", 8 * sizeof(bool));
206
207   PRINT_NAMED_CONSTANT(OK);
208   PRINT_NAMED_CONSTANT(ERR);
209   printf("   pragma Warnings (Off); -- redefinition of Standard.True and False\n");
210   PRINT_NAMED_CONSTANT(TRUE);
211   PRINT_NAMED_CONSTANT(FALSE);
212   printf("   pragma Warnings (On);\n");
213
214   print_comment("Version of the ncurses library from extensions(3NCURSES)");
215   PRINT_NAMED_CONSTANT(NCURSES_VERSION_MAJOR);
216   PRINT_NAMED_CONSTANT(NCURSES_VERSION_MINOR);
217   printf("   Version : constant String := \"%d.%d\";\n",
218          NCURSES_VERSION_MAJOR, NCURSES_VERSION_MINOR);
219
220   print_comment("Character non-color attributes from attr(3NCURSES)");
221   printf("   --  attr_t and chtype may be signed in C.\n");
222   printf("   type attr_t is mod 2 ** %lu;\n", (long unsigned)(8 * sizeof(attr_t)));
223   PRINT_NAMED_BITMASK(attr_t, A_CHARTEXT);
224   PRINT_NAMED_BITMASK(attr_t, A_COLOR);
225   PRINT_BITMASK(attr_t, "Attr", A_ATTRIBUTES & ~A_COLOR);
226   PRINT_NAMED_BITMASK(attr_t, A_STANDOUT);
227   PRINT_NAMED_BITMASK(attr_t, A_UNDERLINE);
228   PRINT_NAMED_BITMASK(attr_t, A_REVERSE);
229   PRINT_NAMED_BITMASK(attr_t, A_BLINK);
230   PRINT_NAMED_BITMASK(attr_t, A_DIM);
231   PRINT_NAMED_BITMASK(attr_t, A_BOLD);
232   PRINT_NAMED_BITMASK(attr_t, A_PROTECT);
233   PRINT_NAMED_BITMASK(attr_t, A_INVIS);
234   PRINT_NAMED_BITMASK(attr_t, A_ALTCHARSET);
235   PRINT_NAMED_BITMASK(attr_t, A_HORIZONTAL);
236   PRINT_NAMED_BITMASK(attr_t, A_LEFT);
237   PRINT_NAMED_BITMASK(attr_t, A_LOW);
238   PRINT_NAMED_BITMASK(attr_t, A_RIGHT);
239   PRINT_NAMED_BITMASK(attr_t, A_TOP);
240   PRINT_NAMED_BITMASK(attr_t, A_VERTICAL);
241   print_constant("chtype_Size", 8 * sizeof(chtype));
242
243   print_comment("predefined color numbers from color(3NCURSES)");
244   PRINT_NAMED_CONSTANT(COLOR_BLACK);
245   PRINT_NAMED_CONSTANT(COLOR_RED);
246   PRINT_NAMED_CONSTANT(COLOR_GREEN);
247   PRINT_NAMED_CONSTANT(COLOR_YELLOW);
248   PRINT_NAMED_CONSTANT(COLOR_BLUE);
249   PRINT_NAMED_CONSTANT(COLOR_MAGENTA);
250   PRINT_NAMED_CONSTANT(COLOR_CYAN);
251   PRINT_NAMED_CONSTANT(COLOR_WHITE);
252
253   print_comment("ETI return codes from ncurses.h");
254   PRINT_NAMED_CONSTANT(E_OK);
255   PRINT_NAMED_CONSTANT(E_SYSTEM_ERROR);
256   PRINT_NAMED_CONSTANT(E_BAD_ARGUMENT);
257   PRINT_NAMED_CONSTANT(E_POSTED);
258   PRINT_NAMED_CONSTANT(E_CONNECTED);
259   PRINT_NAMED_CONSTANT(E_BAD_STATE);
260   PRINT_NAMED_CONSTANT(E_NO_ROOM);
261   PRINT_NAMED_CONSTANT(E_NOT_POSTED);
262   PRINT_NAMED_CONSTANT(E_UNKNOWN_COMMAND);
263   PRINT_NAMED_CONSTANT(E_NO_MATCH);
264   PRINT_NAMED_CONSTANT(E_NOT_SELECTABLE);
265   PRINT_NAMED_CONSTANT(E_NOT_CONNECTED);
266   PRINT_NAMED_CONSTANT(E_REQUEST_DENIED);
267   PRINT_NAMED_CONSTANT(E_INVALID_FIELD);
268   PRINT_NAMED_CONSTANT(E_CURRENT);
269
270   print_comment("Input key codes not defined in any ncurses manpage");
271   PRINT_NAMED_CONSTANT(KEY_MIN);
272   PRINT_NAMED_CONSTANT(KEY_MAX);
273 #ifdef KEY_CODE_YES
274   PRINT_NAMED_CONSTANT(KEY_CODE_YES);
275 #endif
276
277   print_comment("Input key codes from getch(3NCURSES)");
278   PRINT_NAMED_CONSTANT(KEY_BREAK);
279   PRINT_NAMED_CONSTANT(KEY_DOWN);
280   PRINT_NAMED_CONSTANT(KEY_UP);
281   PRINT_NAMED_CONSTANT(KEY_LEFT);
282   PRINT_NAMED_CONSTANT(KEY_RIGHT);
283   PRINT_NAMED_CONSTANT(KEY_HOME);
284   PRINT_NAMED_CONSTANT(KEY_BACKSPACE);
285   PRINT_NAMED_CONSTANT(KEY_F0);
286   print_constant("KEY_F1", KEY_F(1));
287   print_constant("KEY_F2", KEY_F(2));
288   print_constant("KEY_F3", KEY_F(3));
289   print_constant("KEY_F4", KEY_F(4));
290   print_constant("KEY_F5", KEY_F(5));
291   print_constant("KEY_F6", KEY_F(6));
292   print_constant("KEY_F7", KEY_F(7));
293   print_constant("KEY_F8", KEY_F(8));
294   print_constant("KEY_F9", KEY_F(9));
295   print_constant("KEY_F10", KEY_F(10));
296   print_constant("KEY_F11", KEY_F(11));
297   print_constant("KEY_F12", KEY_F(12));
298   print_constant("KEY_F13", KEY_F(13));
299   print_constant("KEY_F14", KEY_F(14));
300   print_constant("KEY_F15", KEY_F(15));
301   print_constant("KEY_F16", KEY_F(16));
302   print_constant("KEY_F17", KEY_F(17));
303   print_constant("KEY_F18", KEY_F(18));
304   print_constant("KEY_F19", KEY_F(19));
305   print_constant("KEY_F20", KEY_F(20));
306   print_constant("KEY_F21", KEY_F(21));
307   print_constant("KEY_F22", KEY_F(22));
308   print_constant("KEY_F23", KEY_F(23));
309   print_constant("KEY_F24", KEY_F(24));
310   PRINT_NAMED_CONSTANT(KEY_DL);
311   PRINT_NAMED_CONSTANT(KEY_IL);
312   PRINT_NAMED_CONSTANT(KEY_DC);
313   PRINT_NAMED_CONSTANT(KEY_IC);
314   PRINT_NAMED_CONSTANT(KEY_EIC);
315   PRINT_NAMED_CONSTANT(KEY_CLEAR);
316   PRINT_NAMED_CONSTANT(KEY_EOS);
317   PRINT_NAMED_CONSTANT(KEY_EOL);
318   PRINT_NAMED_CONSTANT(KEY_SF);
319   PRINT_NAMED_CONSTANT(KEY_SR);
320   PRINT_NAMED_CONSTANT(KEY_NPAGE);
321   PRINT_NAMED_CONSTANT(KEY_PPAGE);
322   PRINT_NAMED_CONSTANT(KEY_STAB);
323   PRINT_NAMED_CONSTANT(KEY_CTAB);
324   PRINT_NAMED_CONSTANT(KEY_CATAB);
325   PRINT_NAMED_CONSTANT(KEY_ENTER);
326   PRINT_NAMED_CONSTANT(KEY_SRESET);
327   PRINT_NAMED_CONSTANT(KEY_RESET);
328   PRINT_NAMED_CONSTANT(KEY_PRINT);
329   PRINT_NAMED_CONSTANT(KEY_LL);
330   PRINT_NAMED_CONSTANT(KEY_A1);
331   PRINT_NAMED_CONSTANT(KEY_A3);
332   PRINT_NAMED_CONSTANT(KEY_B2);
333   PRINT_NAMED_CONSTANT(KEY_C1);
334   PRINT_NAMED_CONSTANT(KEY_C3);
335   PRINT_NAMED_CONSTANT(KEY_BTAB);
336   PRINT_NAMED_CONSTANT(KEY_BEG);
337   PRINT_NAMED_CONSTANT(KEY_CANCEL);
338   PRINT_NAMED_CONSTANT(KEY_CLOSE);
339   PRINT_NAMED_CONSTANT(KEY_COMMAND);
340   PRINT_NAMED_CONSTANT(KEY_COPY);
341   PRINT_NAMED_CONSTANT(KEY_CREATE);
342   PRINT_NAMED_CONSTANT(KEY_END);
343   PRINT_NAMED_CONSTANT(KEY_EXIT);
344   PRINT_NAMED_CONSTANT(KEY_FIND);
345   PRINT_NAMED_CONSTANT(KEY_HELP);
346   PRINT_NAMED_CONSTANT(KEY_MARK);
347   PRINT_NAMED_CONSTANT(KEY_MESSAGE);
348   PRINT_NAMED_CONSTANT(KEY_MOVE);
349   PRINT_NAMED_CONSTANT(KEY_NEXT);
350   PRINT_NAMED_CONSTANT(KEY_OPEN);
351   PRINT_NAMED_CONSTANT(KEY_OPTIONS);
352   PRINT_NAMED_CONSTANT(KEY_PREVIOUS);
353   PRINT_NAMED_CONSTANT(KEY_REDO);
354   PRINT_NAMED_CONSTANT(KEY_REFERENCE);
355   PRINT_NAMED_CONSTANT(KEY_REFRESH);
356   PRINT_NAMED_CONSTANT(KEY_REPLACE);
357   PRINT_NAMED_CONSTANT(KEY_RESTART);
358   PRINT_NAMED_CONSTANT(KEY_RESUME);
359   PRINT_NAMED_CONSTANT(KEY_SAVE);
360   PRINT_NAMED_CONSTANT(KEY_SBEG);
361   PRINT_NAMED_CONSTANT(KEY_SCANCEL);
362   PRINT_NAMED_CONSTANT(KEY_SCOMMAND);
363   PRINT_NAMED_CONSTANT(KEY_SCOPY);
364   PRINT_NAMED_CONSTANT(KEY_SCREATE);
365   PRINT_NAMED_CONSTANT(KEY_SDC);
366   PRINT_NAMED_CONSTANT(KEY_SDL);
367   PRINT_NAMED_CONSTANT(KEY_SELECT);
368   PRINT_NAMED_CONSTANT(KEY_SEND);
369   PRINT_NAMED_CONSTANT(KEY_SEOL);
370   PRINT_NAMED_CONSTANT(KEY_SEXIT);
371   PRINT_NAMED_CONSTANT(KEY_SFIND);
372   PRINT_NAMED_CONSTANT(KEY_SHELP);
373   PRINT_NAMED_CONSTANT(KEY_SHOME);
374   PRINT_NAMED_CONSTANT(KEY_SIC);
375   PRINT_NAMED_CONSTANT(KEY_SLEFT);
376   PRINT_NAMED_CONSTANT(KEY_SMESSAGE);
377   PRINT_NAMED_CONSTANT(KEY_SMOVE);
378   PRINT_NAMED_CONSTANT(KEY_SNEXT);
379   PRINT_NAMED_CONSTANT(KEY_SOPTIONS);
380   PRINT_NAMED_CONSTANT(KEY_SPREVIOUS);
381   PRINT_NAMED_CONSTANT(KEY_SPRINT);
382   PRINT_NAMED_CONSTANT(KEY_SREDO);
383   PRINT_NAMED_CONSTANT(KEY_SREPLACE);
384   PRINT_NAMED_CONSTANT(KEY_SRIGHT);
385   PRINT_NAMED_CONSTANT(KEY_SRSUME);
386   PRINT_NAMED_CONSTANT(KEY_SSAVE);
387   PRINT_NAMED_CONSTANT(KEY_SSUSPEND);
388   PRINT_NAMED_CONSTANT(KEY_SUNDO);
389   PRINT_NAMED_CONSTANT(KEY_SUSPEND);
390   PRINT_NAMED_CONSTANT(KEY_UNDO);
391   PRINT_NAMED_CONSTANT(KEY_MOUSE);
392   PRINT_NAMED_CONSTANT(KEY_RESIZE);
393
394   print_comment("alternate character codes (ACS) from addch(3NCURSES)");
395 #define PRINT_ACS(name) print_constant (#name, &name - &acs_map[0])
396   PRINT_ACS(ACS_ULCORNER);
397   PRINT_ACS(ACS_LLCORNER);
398   PRINT_ACS(ACS_URCORNER);
399   PRINT_ACS(ACS_LRCORNER);
400   PRINT_ACS(ACS_LTEE);
401   PRINT_ACS(ACS_RTEE);
402   PRINT_ACS(ACS_BTEE);
403   PRINT_ACS(ACS_TTEE);
404   PRINT_ACS(ACS_HLINE);
405   PRINT_ACS(ACS_VLINE);
406   PRINT_ACS(ACS_PLUS);
407   PRINT_ACS(ACS_S1);
408   PRINT_ACS(ACS_S9);
409   PRINT_ACS(ACS_DIAMOND);
410   PRINT_ACS(ACS_CKBOARD);
411   PRINT_ACS(ACS_DEGREE);
412   PRINT_ACS(ACS_PLMINUS);
413   PRINT_ACS(ACS_BULLET);
414   PRINT_ACS(ACS_LARROW);
415   PRINT_ACS(ACS_RARROW);
416   PRINT_ACS(ACS_DARROW);
417   PRINT_ACS(ACS_UARROW);
418   PRINT_ACS(ACS_BOARD);
419   PRINT_ACS(ACS_LANTERN);
420   PRINT_ACS(ACS_BLOCK);
421   PRINT_ACS(ACS_S3);
422   PRINT_ACS(ACS_S7);
423   PRINT_ACS(ACS_LEQUAL);
424   PRINT_ACS(ACS_GEQUAL);
425   PRINT_ACS(ACS_PI);
426   PRINT_ACS(ACS_NEQUAL);
427   PRINT_ACS(ACS_STERLING);
428
429   print_comment("Menu_Options from opts(3MENU)");
430   PRINT_NAMED_BITMASK(Menu_Options, O_ONEVALUE);
431   PRINT_NAMED_BITMASK(Menu_Options, O_SHOWDESC);
432   PRINT_NAMED_BITMASK(Menu_Options, O_ROWMAJOR);
433   PRINT_NAMED_BITMASK(Menu_Options, O_IGNORECASE);
434   PRINT_NAMED_BITMASK(Menu_Options, O_SHOWMATCH);
435   PRINT_NAMED_BITMASK(Menu_Options, O_NONCYCLIC);
436   print_constant("Menu_Options_Size", 8 * sizeof(Menu_Options));
437
438   print_comment("Item_Options from menu_opts(3MENU)");
439   PRINT_NAMED_BITMASK(Item_Options, O_SELECTABLE);
440   print_constant("Item_Options_Size", 8 * sizeof(Item_Options));
441
442   print_comment("Field_Options from field_opts(3FORM)");
443   PRINT_NAMED_BITMASK(Field_Options, O_VISIBLE);
444   PRINT_NAMED_BITMASK(Field_Options, O_ACTIVE);
445   PRINT_NAMED_BITMASK(Field_Options, O_PUBLIC);
446   PRINT_NAMED_BITMASK(Field_Options, O_EDIT);
447   PRINT_NAMED_BITMASK(Field_Options, O_WRAP);
448   PRINT_NAMED_BITMASK(Field_Options, O_BLANK);
449   PRINT_NAMED_BITMASK(Field_Options, O_AUTOSKIP);
450   PRINT_NAMED_BITMASK(Field_Options, O_NULLOK);
451   PRINT_NAMED_BITMASK(Field_Options, O_PASSOK);
452   PRINT_NAMED_BITMASK(Field_Options, O_STATIC);
453   print_constant("Field_Options_Size", 8 * sizeof(Field_Options));
454
455   print_comment("Field_Options from opts(3FORM)");
456   PRINT_NAMED_BITMASK(Field_Options, O_NL_OVERLOAD);
457   PRINT_NAMED_BITMASK(Field_Options, O_BS_OVERLOAD);
458   /*  Field_Options_Size is defined below */
459
460   print_comment("MEVENT structure from mouse(3NCURSES)");
461   STRUCT_OFFSET(MEVENT, id);
462   STRUCT_OFFSET(MEVENT, x);
463   STRUCT_OFFSET(MEVENT, y);
464   STRUCT_OFFSET(MEVENT, z);
465   STRUCT_OFFSET(MEVENT, bstate);
466   print_constant("MEVENT_Size", 8 * sizeof(MEVENT));
467
468   print_comment("mouse events from mouse(3NCURSES)");
469   {
470     mmask_t all_events;
471
472 #define PRINT_MOUSE_EVENT(event)                \
473     print_constant (#event, event);             \
474     all_events |= event
475
476     all_events = 0;
477     PRINT_MOUSE_EVENT(BUTTON1_RELEASED);
478     PRINT_MOUSE_EVENT(BUTTON1_PRESSED);
479     PRINT_MOUSE_EVENT(BUTTON1_CLICKED);
480     PRINT_MOUSE_EVENT(BUTTON1_DOUBLE_CLICKED);
481     PRINT_MOUSE_EVENT(BUTTON1_TRIPLE_CLICKED);
482 #ifdef BUTTON1_RESERVED_EVENT
483     PRINT_MOUSE_EVENT(BUTTON1_RESERVED_EVENT);
484 #endif
485     print_constant("all_events_button_1", (long)all_events);
486
487     all_events = 0;
488     PRINT_MOUSE_EVENT(BUTTON2_RELEASED);
489     PRINT_MOUSE_EVENT(BUTTON2_PRESSED);
490     PRINT_MOUSE_EVENT(BUTTON2_CLICKED);
491     PRINT_MOUSE_EVENT(BUTTON2_DOUBLE_CLICKED);
492     PRINT_MOUSE_EVENT(BUTTON2_TRIPLE_CLICKED);
493 #ifdef BUTTON2_RESERVED_EVENT
494     PRINT_MOUSE_EVENT(BUTTON2_RESERVED_EVENT);
495 #endif
496     print_constant("all_events_button_2", (long)all_events);
497
498     all_events = 0;
499     PRINT_MOUSE_EVENT(BUTTON3_RELEASED);
500     PRINT_MOUSE_EVENT(BUTTON3_PRESSED);
501     PRINT_MOUSE_EVENT(BUTTON3_CLICKED);
502     PRINT_MOUSE_EVENT(BUTTON3_DOUBLE_CLICKED);
503     PRINT_MOUSE_EVENT(BUTTON3_TRIPLE_CLICKED);
504 #ifdef BUTTON3_RESERVED_EVENT
505     PRINT_MOUSE_EVENT(BUTTON3_RESERVED_EVENT);
506 #endif
507     print_constant("all_events_button_3", (long)all_events);
508
509     all_events = 0;
510     PRINT_MOUSE_EVENT(BUTTON4_RELEASED);
511     PRINT_MOUSE_EVENT(BUTTON4_PRESSED);
512     PRINT_MOUSE_EVENT(BUTTON4_CLICKED);
513     PRINT_MOUSE_EVENT(BUTTON4_DOUBLE_CLICKED);
514     PRINT_MOUSE_EVENT(BUTTON4_TRIPLE_CLICKED);
515 #ifdef BUTTON4_RESERVED_EVENT
516     PRINT_MOUSE_EVENT(BUTTON4_RESERVED_EVENT);
517 #endif
518     print_constant("all_events_button_4", (long)all_events);
519   }
520   PRINT_NAMED_CONSTANT(BUTTON_CTRL);
521   PRINT_NAMED_CONSTANT(BUTTON_SHIFT);
522   PRINT_NAMED_CONSTANT(BUTTON_ALT);
523   PRINT_NAMED_CONSTANT(REPORT_MOUSE_POSITION);
524   PRINT_NAMED_CONSTANT(ALL_MOUSE_EVENTS);
525
526   print_comment("trace selection from trace(3NCURSES)");
527   PRINT_NAMED_BITMASK(UINT, TRACE_TIMES);
528   PRINT_NAMED_BITMASK(UINT, TRACE_TPUTS);
529   PRINT_NAMED_BITMASK(UINT, TRACE_UPDATE);
530   PRINT_NAMED_BITMASK(UINT, TRACE_MOVE);
531   PRINT_NAMED_BITMASK(UINT, TRACE_CHARPUT);
532   PRINT_NAMED_BITMASK(UINT, TRACE_CALLS);
533   PRINT_NAMED_BITMASK(UINT, TRACE_VIRTPUT);
534   PRINT_NAMED_BITMASK(UINT, TRACE_IEVENT);
535   PRINT_NAMED_BITMASK(UINT, TRACE_BITS);
536   PRINT_NAMED_BITMASK(UINT, TRACE_ICALLS);
537   PRINT_NAMED_BITMASK(UINT, TRACE_CCALLS);
538   PRINT_NAMED_BITMASK(UINT, TRACE_DATABASE);
539   PRINT_NAMED_BITMASK(UINT, TRACE_ATTRS);
540   print_constant("Trace_Size", 8 * sizeof(UINT));
541
542   printf("end Terminal_Interface.Curses_Constants;\n");
543   exit(EXIT_SUCCESS);
544 }