|
@@ -28,6 +28,9 @@ typedef uint32_t attr_t;
|
28
|
28
|
|
29
|
29
|
/** Curses SCREEN object */
|
30
|
30
|
typedef struct _curses_screen {
|
|
31
|
+ /** Current attribute */
|
|
32
|
+ attr_t attrs;
|
|
33
|
+
|
31
|
34
|
void ( *init ) ( struct _curses_screen *scr );
|
32
|
35
|
void ( *exit ) ( struct _curses_screen *scr );
|
33
|
36
|
/**
|
|
@@ -46,6 +49,21 @@ typedef struct _curses_screen {
|
46
|
49
|
* @v c character to be written
|
47
|
50
|
*/
|
48
|
51
|
void ( * putc ) ( struct _curses_screen *scr, chtype c );
|
|
52
|
+ /**
|
|
53
|
+ * Pop a character from the keyboard input stream
|
|
54
|
+ *
|
|
55
|
+ * @v scr screen on which to operate
|
|
56
|
+ * @ret c popped character
|
|
57
|
+ */
|
|
58
|
+ int ( * getc ) ( struct _curses_screen *scr );
|
|
59
|
+ /**
|
|
60
|
+ * Checks to see whether a character is waiting in the input stream
|
|
61
|
+ *
|
|
62
|
+ * @v scr screen on which to operate
|
|
63
|
+ * @ret TRUE character waiting in stream
|
|
64
|
+ * @ret FALSE no character waiting in stream
|
|
65
|
+ */
|
|
66
|
+ bool ( *peek ) ( struct _curses_screen *scr );
|
49
|
67
|
} SCREEN;
|
50
|
68
|
|
51
|
69
|
/** Curses Window struct */
|
|
@@ -69,55 +87,57 @@ typedef struct _curses_window {
|
69
|
87
|
} WINDOW;
|
70
|
88
|
|
71
|
89
|
extern WINDOW _stdscr;
|
72
|
|
-extern SCREEN _curscr;
|
73
|
90
|
extern unsigned short _COLS;
|
74
|
91
|
extern unsigned short _LINES;
|
75
|
|
-extern unsigned int _COLOURS;
|
76
|
|
-extern unsigned int _COLOUR_PAIRS;
|
77
|
92
|
|
78
|
93
|
#define stdscr ( &_stdscr )
|
79
|
|
-#define curscr ( &_curscr )
|
80
|
94
|
#define COLS _COLS
|
81
|
95
|
#define LINES _LINES
|
82
|
|
-#define COLORS _COLOURS
|
83
|
|
-#define COLOR_PAIRS _COLOUR_PAIRS
|
84
|
96
|
|
85
|
97
|
#define MUCURSES_BITS( mask, shift ) (( mask ) << (shift))
|
86
|
98
|
#define CPAIR_SHIFT 8
|
87
|
99
|
#define ATTRS_SHIFT 16
|
88
|
100
|
|
89
|
|
-#define A_DEFAULT ( 1UL - 1UL )
|
90
|
|
-#define A_ALTCHARSET MUCURSES_BITS( 1UL, ATTRS_SHIFT + 0 )
|
91
|
|
-#define A_BLINK MUCURSES_BITS( 1UL, ATTRS_SHIFT + 1 )
|
92
|
|
-#define A_BOLD MUCURSES_BITS( 1UL, ATTRS_SHIFT + 2 )
|
93
|
|
-#define A_DIM MUCURSES_BITS( 1UL, ATTRS_SHIFT + 3 )
|
94
|
|
-#define A_INVIS MUCURSES_BITS( 1UL, ATTRS_SHIFT + 4 )
|
95
|
|
-#define A_PROTECT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 5 )
|
96
|
|
-#define A_REVERSE MUCURSES_BITS( 1UL, ATTRS_SHIFT + 6 )
|
97
|
|
-#define A_STANDOUT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 7 )
|
98
|
|
-#define A_UNDERLINE MUCURSES_BITS( 1UL, ATTRS_SHIFT + 8 )
|
99
|
|
-
|
100
|
|
-#define WA_ALTCHARSET A_ALTCHARSET
|
101
|
|
-#define WA_BLINK A_BLINK
|
102
|
|
-#define WA_BOLD A_BOLD
|
103
|
|
-#define WA_DIM A_DIM
|
104
|
|
-#define WA_INVIS A_INVIS
|
105
|
|
-#define WA_PROTECT A_PROTECT
|
106
|
|
-#define WA_REVERSE A_REVERSE
|
107
|
|
-#define WA_STANDOUT A_STANDOUT
|
108
|
|
-#define WA_UNDERLINE A_UNDERLINE
|
109
|
|
-#define WA_HORIZONTAL MUCURSES_BITS( 1UL, ATTRS_SHIFT + 9 )
|
110
|
|
-#define WA_VERTICAL MUCURSES_BITS( 1UL, ATTRS_SHIFT + 10 )
|
111
|
|
-#define WA_LEFT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 11 )
|
112
|
|
-#define WA_RIGHT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 12 )
|
113
|
|
-#define WA_LOW MUCURSES_BITS( 1UL, ATTRS_SHIFT + 13 )
|
114
|
|
-#define WA_TOP MUCURSES_BITS( 1UL, ATTRS_SHIFT + 14 )
|
115
|
|
-
|
116
|
|
-#define A_ATTRIBUTES ( MUCURSES_BITS( 1UL, ATTRS_SHIFT ) - 1UL )
|
117
|
|
-#define A_CHARTEXT ( MUCURSES_BITS( 1UL, 0 ) - 1UL )
|
118
|
|
-#define A_COLOUR MUCURSES_BITS( ( 1UL << 8 ) - 1UL, CPAIR_SHIFT )
|
|
101
|
+#define WA_DEFAULT ( 0x0000 << ATTRS_SHIFT )
|
|
102
|
+#define WA_ALTCHARSET ( 0x0001 << ATTRS_SHIFT )
|
|
103
|
+#define WA_BLINK ( 0x0002 << ATTRS_SHIFT )
|
|
104
|
+#define WA_BOLD ( 0x0004 << ATTRS_SHIFT )
|
|
105
|
+#define WA_DIM ( 0x0008 << ATTRS_SHIFT )
|
|
106
|
+#define WA_INVIS ( 0x0010 << ATTRS_SHIFT )
|
|
107
|
+#define WA_PROTECT ( 0x0020 << ATTRS_SHIFT )
|
|
108
|
+#define WA_REVERSE ( 0x0040 << ATTRS_SHIFT )
|
|
109
|
+#define WA_STANDOUT ( 0x0080 << ATTRS_SHIFT )
|
|
110
|
+#define WA_UNDERLINE ( 0x0100 << ATTRS_SHIFT )
|
|
111
|
+#define WA_HORIZONTAL ( 0x0200 << ATTRS_SHIFT )
|
|
112
|
+#define WA_VERTICAL ( 0x0400 << ATTRS_SHIFT )
|
|
113
|
+#define WA_LEFT ( 0x0800 << ATTRS_SHIFT )
|
|
114
|
+#define WA_RIGHT ( 0x1000 << ATTRS_SHIFT )
|
|
115
|
+#define WA_LOW ( 0x2000 << ATTRS_SHIFT )
|
|
116
|
+#define WA_TOP ( 0x4000 << ATTRS_SHIFT )
|
|
117
|
+
|
|
118
|
+#define A_DEFAULT WA_DEFAULT
|
|
119
|
+#define A_ALTCHARSET WA_ALTCHARSET
|
|
120
|
+#define A_BLINK WA_BLINK
|
|
121
|
+#define A_BOLD WA_BOLD
|
|
122
|
+#define A_DIM WA_DIM
|
|
123
|
+#define A_INVIS WA_INVIS
|
|
124
|
+#define A_PROTECT WA_PROTECT
|
|
125
|
+#define A_REVERSE WA_REVERSE
|
|
126
|
+#define A_STANDOUT WA_STANDOUT
|
|
127
|
+#define A_UNDERLINE WA_UNDERLINE
|
|
128
|
+
|
|
129
|
+#define A_ATTRIBUTES ( 0xffff << ATTRS_SHIFT )
|
|
130
|
+#define A_CHARTEXT ( 0xff )
|
|
131
|
+#define A_COLOUR ( 0xff << CPAIR_SHIFT )
|
119
|
132
|
#define A_COLOR A_COLOUR
|
120
|
133
|
|
|
134
|
+#define COLOUR_PAIR(n) ( (n) << CPAIR_SHIFT )
|
|
135
|
+#define COLOR_PAIR(n) COLOUR_PAIR(n)
|
|
136
|
+#define PAIR_NUMBER(attrs) ( ( (attrs) & A_COLOUR ) >> CPAIR_SHIFT )
|
|
137
|
+
|
|
138
|
+#define COLOUR_PAIRS 4 /* Arbitrary limit */
|
|
139
|
+#define COLOR_PAIRS COLOUR_PAIRS
|
|
140
|
+
|
121
|
141
|
#define ACS_ULCORNER '+'
|
122
|
142
|
#define ACS_LLCORNER '+'
|
123
|
143
|
#define ACS_URCORNER '+'
|
|
@@ -152,6 +172,7 @@ extern unsigned int _COLOUR_PAIRS;
|
152
|
172
|
#define COLOUR_MAGENTA 5
|
153
|
173
|
#define COLOUR_CYAN 6
|
154
|
174
|
#define COLOUR_WHITE 7
|
|
175
|
+#define COLOURS 7
|
155
|
176
|
|
156
|
177
|
#define COLOUR_FG 30
|
157
|
178
|
#define COLOUR_BG 40
|
|
@@ -166,6 +187,7 @@ extern unsigned int _COLOUR_PAIRS;
|
166
|
187
|
#define COLOR_MAGENTA COLOUR_MAGENTA
|
167
|
188
|
#define COLOR_YELLOW COLOUR_YELLOW
|
168
|
189
|
#define COLOR_WHITE COLOUR_WHITE
|
|
190
|
+#define COLORS COLOURS
|
169
|
191
|
|
170
|
192
|
/*
|
171
|
193
|
* KEY code constants
|
|
@@ -281,7 +303,7 @@ extern int beep ( void );
|
281
|
303
|
/*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
|
282
|
304
|
chtype );*/
|
283
|
305
|
extern int box ( WINDOW *, chtype, chtype );
|
284
|
|
-extern bool can_change_colour ( void );
|
|
306
|
+//extern bool can_change_colour ( void );
|
285
|
307
|
#define can_change_color() can_change_colour()
|
286
|
308
|
extern int cbreak ( void );
|
287
|
309
|
//extern int clrtobot ( void );
|
|
@@ -289,7 +311,7 @@ extern int cbreak ( void );
|
289
|
311
|
extern int colour_content ( short, short *, short *, short * );
|
290
|
312
|
#define color_content( c, r, g, b ) colour_content( (c), (r), (g), (b) )
|
291
|
313
|
//extern int colour_set ( short, void * );
|
292
|
|
-//#define color_set( cpno, opts ) colour_set( (cpno), (opts) )
|
|
314
|
+#define color_set( cpno, opts ) colour_set( (cpno), (opts) )
|
293
|
315
|
extern int copywin ( const WINDOW *, WINDOW *, int, int, int,
|
294
|
316
|
int, int, int, int );
|
295
|
317
|
extern int curs_set ( int );
|
|
@@ -316,7 +338,7 @@ extern chtype getbkgd ( WINDOW * );
|
316
|
338
|
//extern int getnstr ( char *, int );
|
317
|
339
|
//extern int getstr ( char * );
|
318
|
340
|
extern int halfdelay ( int );
|
319
|
|
-extern bool has_colors ( void );
|
|
341
|
+//extern bool has_colors ( void );
|
320
|
342
|
extern bool has_ic ( void );
|
321
|
343
|
extern bool has_il ( void );
|
322
|
344
|
//extern int hline ( chtype, int );
|
|
@@ -405,7 +427,6 @@ extern int notimeout ( WINDOW *, bool );
|
405
|
427
|
extern int overlay ( const WINDOW *, WINDOW * );
|
406
|
428
|
extern int overwrite ( const WINDOW *, WINDOW * );
|
407
|
429
|
extern int pair_content ( short, short *, short * );
|
408
|
|
-extern int PAIR_NUMBER ( int );
|
409
|
430
|
//extern int pechochar ( WINDOW *, chtype );
|
410
|
431
|
//extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
|
411
|
432
|
//extern int prefresh ( WINDOW *, int, int, int, int, int, int );
|
|
@@ -445,7 +466,7 @@ extern int slk_set ( int, const char *, int );
|
445
|
466
|
extern int slk_touch ( void );
|
446
|
467
|
extern int standend ( void );
|
447
|
468
|
extern int standout ( void );
|
448
|
|
-extern int start_colour ( void );
|
|
469
|
+//extern int start_colour ( void );
|
449
|
470
|
#define start_color() start_colour()
|
450
|
471
|
//extern WINDOW *subpad ( WINDOW *, int, int, int, int );
|
451
|
472
|
extern WINDOW *subwin ( WINDOW *, int, int, int, int );
|
|
@@ -492,7 +513,7 @@ extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
|
492
|
513
|
extern int wclrtobot ( WINDOW * );
|
493
|
514
|
extern int wclrtoeol ( WINDOW * );
|
494
|
515
|
extern void wcursyncup ( WINDOW * );
|
495
|
|
-//extern int wcolor_set ( WINDOW *, short, void * );
|
|
516
|
+extern int wcolour_set ( WINDOW *, short, void * );
|
496
|
517
|
#define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
|
497
|
518
|
extern int wdelch ( WINDOW * );
|
498
|
519
|
extern int wdeleteln ( WINDOW * );
|
|
@@ -574,6 +595,10 @@ static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
|
574
|
595
|
return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
|
575
|
596
|
}
|
576
|
597
|
|
|
598
|
+static inline bool can_change_colour ( void ) {
|
|
599
|
+ return FALSE;
|
|
600
|
+}
|
|
601
|
+
|
577
|
602
|
static inline int clrtobot ( void ) {
|
578
|
603
|
return wclrtobot( stdscr );
|
579
|
604
|
}
|
|
@@ -582,6 +607,10 @@ static inline int clrtoeol ( void ) {
|
582
|
607
|
return wclrtoeol( stdscr );
|
583
|
608
|
}
|
584
|
609
|
|
|
610
|
+static inline int colour_set ( short colour_pair_number, void *opts ) {
|
|
611
|
+ return wcolour_set ( stdscr, colour_pair_number, opts );
|
|
612
|
+}
|
|
613
|
+
|
585
|
614
|
static inline int delch ( void ) {
|
586
|
615
|
return wdelch ( stdscr );
|
587
|
616
|
}
|
|
@@ -606,6 +635,10 @@ static inline int getstr ( char *str ) {
|
606
|
635
|
return wgetnstr ( stdscr, str, -1 );
|
607
|
636
|
}
|
608
|
637
|
|
|
638
|
+static inline bool has_colors ( void ) {
|
|
639
|
+ return TRUE;
|
|
640
|
+}
|
|
641
|
+
|
609
|
642
|
static inline int hline ( chtype ch, int n ) {
|
610
|
643
|
return whline ( stdscr, ch, n );
|
611
|
644
|
}
|
|
@@ -745,6 +778,10 @@ static inline int slk_refresh ( void ) {
|
745
|
778
|
#define standend() wstandend( stdscr )
|
746
|
779
|
#define standout() wstandout( stdscr )
|
747
|
780
|
|
|
781
|
+static inline int start_colour ( void ) {
|
|
782
|
+ return OK;
|
|
783
|
+}
|
|
784
|
+
|
748
|
785
|
static inline int vline ( chtype ch, int n ) {
|
749
|
786
|
return wvline ( stdscr, ch, n );
|
750
|
787
|
}
|