31
31
* and: Eric S. Raymond <[email protected] > *
32
32
* and: Thomas E. Dickey 1996-on *
33
33
****************************************************************************/
34
- /* $Id: curses.h.in,v 1.215 2010/04/29 09:46:38 tom Exp $ */
35
34
35
+ /* $Id: curses.h.in,v 1.215 2010/04/29 09:46:38 tom Exp $ */
36
36
module curses ;
37
37
38
-
39
-
40
38
/*
41
39
* We need FILE, etc. Include this before checking any feature symbols.
42
40
*/
43
- import std.c.stddef ;
44
41
import std.c.stdio ;
45
- import std.c.stdarg ;
46
- // public import unctrl;
42
+ import std.c.stddef ; /* we want wchar_t */
43
+ import std.c.stdarg ; /* we need va_list */
44
+
45
+ // #include <ncursesw/unctrl.h>
46
+ public import unctrl;
47
47
48
48
// TODO check if needed... I don't have a windows machine...
49
49
version (Win32 )
@@ -76,19 +76,58 @@ alias chtype attr_t;
76
76
alias int OPTIONS ;
77
77
alias void SCREEN ;
78
78
79
- /* global variables */
80
- __gshared WINDOW * stdscr;
81
- __gshared WINDOW * curscr;
82
- __gshared WINDOW * newscr;
83
- __gshared char ttytype[];
84
- __gshared int COLORS ;
85
- __gshared int COLOR_PAIRS ;
86
- __gshared int LINES ;
87
- __gshared int COLS ;
88
- __gshared int TABSIZE ;
89
- __gshared int ESCDELAY ;
90
- __gshared chtype acs_map[256 ];
91
79
80
+ /* attributes */
81
+ // Thank you, Dejan Lekic, dejan.lekic @ (gmail.com || kcl.ac.uk)
82
+ immutable ubyte NCURSES_ATTR_SHIFT = 8 ;
83
+
84
+ chtype NCURSES_BITS (uint mask, ubyte shift)
85
+ { return (mask << (shift + NCURSES_ATTR_SHIFT )); }
86
+
87
+ immutable enum :chtype
88
+ {
89
+ A_NORMAL = (1u - 1u ),
90
+ A_ATTRIBUTES = NCURSES_BITS (~ (1u - 1u ),0 ),
91
+ A_CHARTEXT = (NCURSES_BITS (1u ,0 ) - 1u ),
92
+ A_COLOR = NCURSES_BITS (((1u ) << 8 ) - 1u ,0 ),
93
+ A_STANDOUT = NCURSES_BITS (1u ,8 ),
94
+ A_UNDERLINE = NCURSES_BITS (1u ,9 ),
95
+ A_REVERSE = NCURSES_BITS (1u ,10 ),
96
+ A_BLINK = NCURSES_BITS (1u ,11 ),
97
+ A_DIM = NCURSES_BITS (1u ,12 ),
98
+ A_BOLD = NCURSES_BITS (1u ,13 ),
99
+ A_ALTCHARSET = NCURSES_BITS (1u ,14 ),
100
+ A_INVIS = NCURSES_BITS (1u ,15 ),
101
+ A_PROTECT = NCURSES_BITS (1u ,16 ),
102
+ A_HORIZONTAL = NCURSES_BITS (1u ,17 ),
103
+ A_LEFT = NCURSES_BITS (1u ,18 ),
104
+ A_LOW = NCURSES_BITS (1u ,19 ),
105
+ A_RIGHT = NCURSES_BITS (1u ,20 ),
106
+ A_TOP = NCURSES_BITS (1u ,21 ),
107
+ A_VERTICAL = NCURSES_BITS (1u ,22 ),
108
+
109
+ /*
110
+ * X/Open attributes. In the ncurses implementation, they are identical to the
111
+ * A_ attributes.
112
+ */
113
+ WA_ATTRIBUTES = A_ATTRIBUTES ,
114
+ WA_NORMAL = A_NORMAL ,
115
+ WA_STANDOUT = A_STANDOUT ,
116
+ WA_UNDERLINE = A_UNDERLINE ,
117
+ WA_REVERSE = A_REVERSE ,
118
+ WA_BLINK = A_BLINK ,
119
+ WA_DIM = A_DIM ,
120
+ WA_BOLD = A_BOLD ,
121
+ WA_ALTCHARSET = A_ALTCHARSET ,
122
+ WA_INVIS = A_INVIS ,
123
+ WA_PROTECT = A_PROTECT ,
124
+ WA_HORIZONTAL = A_HORIZONTAL ,
125
+ WA_LEFT = A_LEFT ,
126
+ WA_LOW = A_LOW ,
127
+ WA_RIGHT = A_RIGHT ,
128
+ WA_TOP = A_TOP ,
129
+ WA_VERTICAL = A_VERTICAL
130
+ }
92
131
93
132
94
133
immutable enum :chtype
@@ -105,6 +144,21 @@ immutable enum :chtype
105
144
}
106
145
107
146
147
+ /* global variables */
148
+ __gshared WINDOW * stdscr;
149
+ __gshared WINDOW * curscr;
150
+ __gshared WINDOW * newscr;
151
+ __gshared char ttytype[];
152
+ __gshared int COLORS ;
153
+ __gshared int COLOR_PAIRS ;
154
+ __gshared int LINES ;
155
+ __gshared int COLS ;
156
+ __gshared int TABSIZE ;
157
+ __gshared int ESCDELAY ;
158
+ __gshared chtype acs_map[256 ];
159
+
160
+
161
+
108
162
/* acs symbols */
109
163
// /I couldn't make it perfect, this is the best that I have come up with...
110
164
// /Instead of calling ACS_VAR, you use ACS_VAR().
@@ -244,6 +298,20 @@ immutable int _NOCHANGE = -1;
244
298
*/
245
299
immutable int _NEWINDEX = - 1 ;
246
300
301
+ /*
302
+ * cchar_t stores an array of CCHARW_MAX wide characters. The first is
303
+ * normally a spacing character. The others are non-spacing. If those
304
+ * (spacing and nonspacing) do not fill the array, a null L'\0' follows.
305
+ * Otherwise, a null is assumed to follow when extracting via getcchar().
306
+ */
307
+ immutable size_t CCHARW_MAX = 5 ;
308
+
309
+ struct cchar_t
310
+ {
311
+ attr_t attr;
312
+ wchar_t chars[CCHARW_MAX ];
313
+ }
314
+
247
315
struct WINDOW
248
316
{
249
317
short cury, curx;
@@ -282,20 +350,33 @@ struct WINDOW
282
350
cchar_t bkgrnd;
283
351
}
284
352
285
- /*
286
- * cchar_t stores an array of CCHARW_MAX wide characters. The first is
287
- * normally a spacing character. The others are non-spacing. If those
288
- * (spacing and nonspacing) do not fill the array, a null L'\0' follows.
289
- * Otherwise, a null is assumed to follow when extracting via getcchar().
290
- */
291
- immutable size_t CCHARW_MAX = 5 ;
353
+ struct _nc_event
354
+ {
355
+ int type;
356
+ union data
357
+ {
358
+ long timeout_msec; /* _NC_EVENT_TIMEOUT_MSEC */
359
+ struct fev
360
+ {
361
+ uint flags;
362
+ int fd;
363
+ uint result;
364
+ } /* _NC_EVENT_FILE */
365
+ }
366
+ }
292
367
293
- struct cchar_t
368
+
369
+ struct _nc_eventlist
294
370
{
295
- attr_t attr;
296
- wchar_t chars[CCHARW_MAX ];
371
+ int count;
372
+ int result_flags; /* _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE */
373
+ _nc_event* events[1 ];
297
374
}
298
375
376
+ int wgetch_events (WINDOW * win, _nc_eventlist* nc); /* experimental */
377
+ int wgetnstr_events (WINDOW * win, char * str, int one, _nc_eventlist* nc);/* experimental */
378
+
379
+
299
380
/*
300
381
* Function prototypes. This is the complete X/Open Curses list of required
301
382
* functions. Those marked `generated' will have sources generated from the
@@ -922,59 +1003,6 @@ void getbegyx(U:WINDOW*, T: int)(U win, ref T y, ref T x)
922
1003
}
923
1004
924
1005
925
- /* attributes */
926
-
927
- // Thank you, Dejan Lekic, dejan.lekic @ (gmail.com || kcl.ac.uk)
928
- immutable ubyte NCURSES_ATTR_SHIFT = 8 ;
929
-
930
- chtype NCURSES_BITS (uint mask, ubyte shift)
931
- { return (mask << (shift + NCURSES_ATTR_SHIFT )); }
932
-
933
- immutable enum :chtype
934
- {
935
- A_NORMAL = (1u - 1u ),
936
- A_ATTRIBUTES = NCURSES_BITS (~ (1u - 1u ),0 ),
937
- A_CHARTEXT = (NCURSES_BITS (1u ,0 ) - 1u ),
938
- A_COLOR = NCURSES_BITS (((1u ) << 8 ) - 1u ,0 ),
939
- A_STANDOUT = NCURSES_BITS (1u ,8 ),
940
- A_UNDERLINE = NCURSES_BITS (1u ,9 ),
941
- A_REVERSE = NCURSES_BITS (1u ,10 ),
942
- A_BLINK = NCURSES_BITS (1u ,11 ),
943
- A_DIM = NCURSES_BITS (1u ,12 ),
944
- A_BOLD = NCURSES_BITS (1u ,13 ),
945
- A_ALTCHARSET = NCURSES_BITS (1u ,14 ),
946
- A_INVIS = NCURSES_BITS (1u ,15 ),
947
- A_PROTECT = NCURSES_BITS (1u ,16 ),
948
- A_HORIZONTAL = NCURSES_BITS (1u ,17 ),
949
- A_LEFT = NCURSES_BITS (1u ,18 ),
950
- A_LOW = NCURSES_BITS (1u ,19 ),
951
- A_RIGHT = NCURSES_BITS (1u ,20 ),
952
- A_TOP = NCURSES_BITS (1u ,21 ),
953
- A_VERTICAL = NCURSES_BITS (1u ,22 ),
954
-
955
- /*
956
- * X/Open attributes. In the ncurses implementation, they are identical to the
957
- * A_ attributes.
958
- */
959
- WA_ATTRIBUTES = A_ATTRIBUTES ,
960
- WA_NORMAL = A_NORMAL ,
961
- WA_STANDOUT = A_STANDOUT ,
962
- WA_UNDERLINE = A_UNDERLINE ,
963
- WA_REVERSE = A_REVERSE ,
964
- WA_BLINK = A_BLINK ,
965
- WA_DIM = A_DIM ,
966
- WA_BOLD = A_BOLD ,
967
- WA_ALTCHARSET = A_ALTCHARSET ,
968
- WA_INVIS = A_INVIS ,
969
- WA_PROTECT = A_PROTECT ,
970
- WA_HORIZONTAL = A_HORIZONTAL ,
971
- WA_LEFT = A_LEFT ,
972
- WA_LOW = A_LOW ,
973
- WA_RIGHT = A_RIGHT ,
974
- WA_TOP = A_TOP ,
975
- WA_VERTICAL = A_VERTICAL
976
- }
977
-
978
1006
979
1007
/*
980
1008
* Pseudo-character tokens outside ASCII range. The curses wgetch() function
0 commit comments