[ipoib] Simplify test for received broadcast packets
[ipxe.git] / src / include / curses.h
1 #ifndef CURSES_H
2 #define CURSES_H
3
4 #include <stdint.h>
5 #include <stdarg.h>
6 #include <ipxe/console.h>
7
8 /** @file
9 *
10 * MuCurses header file
11 *
12 */
13
14 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
15
16 #undef ERR
17 #define ERR (-1)
18
19 #undef FALSE
20 #define FALSE (0)
21
22 #undef OK
23 #define OK (0)
24
25 #undef TRUE
26 #define TRUE (1)
27
28 typedef int bool;
29 typedef uint32_t chtype;
30 typedef uint32_t attr_t;
31
32 /** Curses SCREEN object */
33 typedef struct _curses_screen {
34 /** Current cursor position */
35 unsigned int curs_x, curs_y;
36 /** Current attribute */
37 attr_t attrs;
38
39 void ( *init ) ( struct _curses_screen *scr );
40 void ( *exit ) ( struct _curses_screen *scr );
41 /**
42 * Erase screen
43 *
44 * @v scr screen on which to operate
45 * @v attrs attributes
46 */
47 void ( * erase ) ( struct _curses_screen *scr, attr_t attrs );
48 /**
49 * Move cursor to position specified by x,y coords
50 *
51 * @v scr screen on which to operate
52 * @v y Y position
53 * @v x X position
54 */
55 void ( * movetoyx ) ( struct _curses_screen *scr,
56 unsigned int y, unsigned int x );
57 /**
58 * Write character to current cursor position
59 *
60 * @v scr screen on which to operate
61 * @v c character to be written
62 */
63 void ( * putc ) ( struct _curses_screen *scr, chtype c );
64 /**
65 * Pop a character from the keyboard input stream
66 *
67 * @v scr screen on which to operate
68 * @ret c popped character
69 */
70 int ( * getc ) ( struct _curses_screen *scr );
71 /**
72 * Checks to see whether a character is waiting in the input stream
73 *
74 * @v scr screen on which to operate
75 * @ret TRUE character waiting in stream
76 * @ret FALSE no character waiting in stream
77 */
78 bool ( *peek ) ( struct _curses_screen *scr );
79 /**
80 * Set cursor visibility
81 *
82 * @v scr screen on which to operate
83 * @v visibility cursor visibility
84 */
85 void ( * cursor ) ( struct _curses_screen *scr, int visibility );
86 } SCREEN;
87
88 /** Curses Window struct */
89 typedef struct _curses_window {
90 /** screen with which window associates */
91 SCREEN *scr;
92 /** window attributes */
93 attr_t attrs;
94 /** window origin coordinates */
95 unsigned int ori_x, ori_y;
96 /** window cursor position */
97 unsigned int curs_x, curs_y;
98 /** window dimensions */
99 unsigned int width, height;
100 /** parent window */
101 struct _curses_window *parent;
102 /** windows that share the same parent as this one */
103 //struct list_head siblings;
104 /** windows der'd or sub'd from this one */
105 //struct list_head children;
106 } WINDOW;
107
108 extern WINDOW _stdscr;
109
110 #define stdscr ( &_stdscr )
111 #define COLS console_width
112 #define LINES console_height
113
114 #define MUCURSES_BITS( mask, shift ) (( mask ) << (shift))
115 #define CPAIR_SHIFT 8
116 #define ATTRS_SHIFT 16
117
118 #define WA_DEFAULT ( 0x0000 << ATTRS_SHIFT )
119 #define WA_ALTCHARSET ( 0x0001 << ATTRS_SHIFT )
120 #define WA_BLINK ( 0x0002 << ATTRS_SHIFT )
121 #define WA_BOLD ( 0x0004 << ATTRS_SHIFT )
122 #define WA_DIM ( 0x0008 << ATTRS_SHIFT )
123 #define WA_INVIS ( 0x0010 << ATTRS_SHIFT )
124 #define WA_PROTECT ( 0x0020 << ATTRS_SHIFT )
125 #define WA_REVERSE ( 0x0040 << ATTRS_SHIFT )
126 #define WA_STANDOUT ( 0x0080 << ATTRS_SHIFT )
127 #define WA_UNDERLINE ( 0x0100 << ATTRS_SHIFT )
128 #define WA_HORIZONTAL ( 0x0200 << ATTRS_SHIFT )
129 #define WA_VERTICAL ( 0x0400 << ATTRS_SHIFT )
130 #define WA_LEFT ( 0x0800 << ATTRS_SHIFT )
131 #define WA_RIGHT ( 0x1000 << ATTRS_SHIFT )
132 #define WA_LOW ( 0x2000 << ATTRS_SHIFT )
133 #define WA_TOP ( 0x4000 << ATTRS_SHIFT )
134
135 #define A_DEFAULT WA_DEFAULT
136 #define A_ALTCHARSET WA_ALTCHARSET
137 #define A_BLINK WA_BLINK
138 #define A_BOLD WA_BOLD
139 #define A_DIM WA_DIM
140 #define A_INVIS WA_INVIS
141 #define A_PROTECT WA_PROTECT
142 #define A_REVERSE WA_REVERSE
143 #define A_STANDOUT WA_STANDOUT
144 #define A_UNDERLINE WA_UNDERLINE
145
146 #define A_ATTRIBUTES ( 0xffff << ATTRS_SHIFT )
147 #define A_CHARTEXT ( 0xff )
148 #define A_COLOUR ( 0xff << CPAIR_SHIFT )
149 #define A_COLOR A_COLOUR
150
151 #define COLOUR_PAIR(n) ( (n) << CPAIR_SHIFT )
152 #define COLOR_PAIR(n) COLOUR_PAIR(n)
153 #define PAIR_NUMBER(attrs) ( ( (attrs) & A_COLOUR ) >> CPAIR_SHIFT )
154
155 #define COLOUR_PAIRS 8 /* Arbitrary limit */
156 #define COLOR_PAIRS COLOUR_PAIRS
157
158 #define ACS_ULCORNER '+'
159 #define ACS_LLCORNER '+'
160 #define ACS_URCORNER '+'
161 #define ACS_LRCORNER '+'
162 #define ACS_RTEE '+'
163 #define ACS_LTEE '+'
164 #define ACS_BTEE '+'
165 #define ACS_TTEE '+'
166 #define ACS_HLINE '-'
167 #define ACS_VLINE '|'
168 #define ACS_PLUS '+'
169 #define ACS_S1 '-'
170 #define ACS_S9 '_'
171 #define ACS_DIAMOND '+'
172 #define ACS_CKBOARD ':'
173 #define ACS_DEGREE '\''
174 #define ACS_PLMINUS '#'
175 #define ACS_BULLET 'o'
176 #define ACS_LARROW '<'
177 #define ACS_RARROW '>'
178 #define ACS_DARROW 'v'
179 #define ACS_UARROW '^'
180 #define ACS_BOARD '#'
181 #define ACS_LANTERN '#'
182 #define ACS_BLOCK '#'
183
184 #define COLOUR_BLACK 0
185 #define COLOUR_RED 1
186 #define COLOUR_GREEN 2
187 #define COLOUR_YELLOW 3
188 #define COLOUR_BLUE 4
189 #define COLOUR_MAGENTA 5
190 #define COLOUR_CYAN 6
191 #define COLOUR_WHITE 7
192 #define COLOURS 7
193
194 #define COLOUR_FG 30
195 #define COLOUR_BG 40
196 #define COLOR_FG COLOUR_FG
197 #define COLOR_BG COLOUR_BG
198
199 #define COLOR_BLACK COLOUR_BLACK
200 #define COLOR_BLUE COLOUR_BLUE
201 #define COLOR_GREEN COLOUR_GREEN
202 #define COLOR_CYAN COLOUR_CYAN
203 #define COLOR_RED COLOUR_RED
204 #define COLOR_MAGENTA COLOUR_MAGENTA
205 #define COLOR_YELLOW COLOUR_YELLOW
206 #define COLOR_WHITE COLOUR_WHITE
207 #define COLORS COLOURS
208
209 /*
210 * KEY code constants are define in ipxe/keys.h
211 */
212 #include <ipxe/keys.h>
213
214 //extern int addch ( const chtype * );
215 //extern int addchnstr ( const chtype *, int );
216 //extern int addchstr ( const chtype * );
217 //extern int addnstr ( const char *, int );
218 //extern int addstr ( const char * );
219 //extern int attroff ( int );
220 //extern int attron ( int );
221 //extern int attrset ( int );
222 //extern int attr_get ( attr_t *, short *, void * );
223 //extern int attr_off ( attr_t, void * );
224 //extern int attr_on ( attr_t, void * );
225 //extern int attr_set ( attr_t, short, void * );
226 extern int baudrate ( void );
227 extern int beep ( void );
228 //extern void bkgdset ( chtype );
229 /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
230 chtype );*/
231 extern int box ( WINDOW *, chtype, chtype ) __nonnull;
232 //extern bool can_change_colour ( void );
233 #define can_change_color() can_change_colour()
234 extern int cbreak ( void );
235 //extern int clrtobot ( void );
236 //extern int clrtoeol ( void );
237 extern int colour_content ( short, short *, short *, short * ) __nonnull;
238 #define color_content( c, r, g, b ) colour_content( (c), (r), (g), (b) )
239 //extern int colour_set ( short, void * );
240 #define color_set( cpno, opts ) colour_set( (cpno), (opts) )
241 extern int copywin ( const WINDOW *, WINDOW *, int, int, int,
242 int, int, int, int );
243 extern int curs_set ( int );
244 extern int def_prog_mode ( void );
245 extern int def_shell_mode ( void );
246 extern int delay_output ( int );
247 //extern int delch ( void );
248 //extern int deleteln ( void );
249 extern void delscreen ( SCREEN * );
250 extern int delwin ( WINDOW * ) __nonnull;
251 extern WINDOW *derwin ( WINDOW *, int, int, int, int ) __nonnull;
252 //extern int doupdate ( void );
253 extern WINDOW *dupwin ( WINDOW * ) __nonnull;
254 extern int echo ( void );
255 extern int echochar ( const chtype );
256 extern int endwin ( void );
257 extern char erasechar ( void );
258 extern int erase ( void );
259 extern void filter ( void );
260 extern int flash ( void );
261 extern int flushinp ( void );
262 extern __pure chtype getbkgd ( WINDOW * ) __nonnull;
263 //extern int getch ( void );
264 //extern int getnstr ( char *, int );
265 //extern int getstr ( char * );
266 extern int halfdelay ( int );
267 //extern bool has_colors ( void );
268 extern bool has_ic ( void );
269 extern bool has_il ( void );
270 //extern int hline ( chtype, int );
271 extern void idcok ( WINDOW *, bool );
272 extern int idlok ( WINDOW *, bool );
273 //extern void immedok ( WINDOW *, bool );
274 //extern chtype inch ( void );
275 //extern int inchnstr ( chtype *, int );
276 //extern int inchstr ( chtype * );
277 extern WINDOW *initscr ( void );
278 extern int init_colour ( short, short, short, short );
279 #define init_color ( c, r, g, b ) init_colour ( (c), (r), (g), (b) )
280 extern int init_pair ( short, short, short );
281 //extern int innstr ( char *, int );
282 //extern int insch ( chtype );
283 //extern int insnstr ( const char *, int );
284 //extern int insstr ( const char * );
285 //extern int instr ( char * );
286 extern int intrflush ( WINDOW *, bool );
287 extern bool isendwin ( void );
288 //extern bool is_linetouched ( WINDOW *, int );
289 //extern bool is_wintouched ( WINDOW * );
290 extern char *keyname ( int );
291 extern int keypad ( WINDOW *, bool );
292 extern char killchar ( void );
293 extern int leaveok ( WINDOW *, bool );
294 extern char *longname ( void );
295 extern int meta ( WINDOW *, bool );
296 //extern int move ( int, int );
297 //extern int mvaddch ( int, int, const chtype );
298 //extern int mvaddchnstr ( int, int, const chtype *, int );
299 //extern int mvaddchstr ( int, int, const chtype * );
300 //extern int mvaddnstr ( int, int, const char *, int );
301 //extern int mvaddstr ( int, int, const char * );
302 extern int mvcur ( int, int, int, int );
303 //extern int mvdelch ( int, int );
304 extern int mvderwin ( WINDOW *, int, int );
305 //extern int mvgetch ( int, int );
306 //extern int mvgetnstr ( int, int, char *, int );
307 //extern int mvgetstr ( int, int, char * );
308 //extern int mvhline ( int, int, chtype, int );
309 //extern chtype mvinch ( int, int );
310 //extern int mvinchnstr ( int, int, chtype *, int );
311 //extern int mvinchstr ( int, int, chtype * );
312 //extern int mvinnstr ( int, int, char *, int );
313 //extern int mvinsch ( int, int, chtype );
314 //extern int mvinsnstr ( int, int, const char *, int );
315 //extern int mvinsstr ( int, int, const char * );
316 //extern int mvinstr ( int, int, char * );
317 //extern int mvprintw ( int, int, char *, ... );
318 //extern int mvscanw ( int, int, char *, ... );
319 //extern int mvvline ( int, int, chtype, int );
320 //extern int mvwaddch ( WINDOW *, int, int, const chtype );
321 //extern int mvwaddchnstr ( WINDOW *, int, int, const chtype *, int );
322 //extern int mvwaddchstr ( WINDOW *, int, int, const chtype * );
323 //extern int mvwaddnstr ( WINDOW *, int, int, const char *, int );
324 //extern int mvwaddstr ( WINDOW *, int, int, const char * );
325 //extern int mvwdelch ( WINDOW *, int, int );
326 //extern int mvwgetch ( WINDOW *, int, int );
327 //extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
328 //extern int mvwgetstr ( WINDOW *, int, int, char * );
329 //extern int mvwhline ( WINDOW *, int, int, chtype, int );
330 extern int mvwin ( WINDOW *, int, int ) __nonnull;
331 //extern chtype mvwinch ( WINDOW *, int, int );
332 //extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int );
333 //extern int mvwinchstr ( WINDOW *, int, int, chtype * );
334 //extern int mvwinnstr ( WINDOW *, int, int, char *, int );
335 //extern int mvwinsch ( WINDOW *, int, int, chtype );
336 //extern int mvwinsnstr ( WINDOW *, int, int, const char *, int );
337 //extern int mvwinsstr ( WINDOW *, int, int, const char * );
338 //extern int mvwinstr ( WINDOW *, int, int, char * );
339 //extern int mvwprintw ( WINDOW *, int, int, char *, ... );
340 //extern int mvwscanw ( WINDOW *, int, int, char *, ... );
341 //extern int mvwvline ( WINDOW *, int, int, chtype, int );
342 extern int napms ( int );
343 //extern WINDOW *newpad ( int, int );
344 extern WINDOW *newwin ( int, int, int, int );
345 extern int nl ( void );
346 extern int nocbreak ( void );
347 extern int nodelay ( WINDOW *, bool );
348 extern int noecho ( void );
349 extern int nonl ( void );
350 extern void noqiflush ( void );
351 extern int noraw ( void );
352 extern int notimeout ( WINDOW *, bool );
353 extern int overlay ( const WINDOW *, WINDOW * );
354 extern int overwrite ( const WINDOW *, WINDOW * );
355 extern int pair_content ( short, short *, short * ) __nonnull;
356 //extern int pechochar ( WINDOW *, chtype );
357 //extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
358 //extern int prefresh ( WINDOW *, int, int, int, int, int, int );
359 extern int printw ( char *, ... );
360 extern int putp ( const char * );
361 extern void qiflush ( void );
362 extern int raw ( void );
363 //extern int redrawwin ( WINDOW * );
364 //extern int refresh ( void );
365 extern int reset_prog_mode ( void );
366 extern int reset_shell_mode ( void );
367 extern int resetty ( void );
368 extern int ripoffline ( int, int (*) ( WINDOW *, int) );
369 extern int savetty ( void );
370 //extern int scanw ( char *, ... );
371 //extern int scrl ( int );
372 //extern int scroll ( WINDOW * );
373 //extern int scrollok ( WINDOW *, bool );
374 //extern int setscrreg ( int, int );
375 extern SCREEN *set_term ( SCREEN * );
376 extern int setupterm ( char *, int, int * );
377 extern int slk_attr_off ( const attr_t, void * );
378 extern int slk_attroff ( const chtype );
379 extern int slk_attr_on ( const attr_t, void * );
380 extern int slk_attron ( const chtype );
381 extern int slk_attr_set ( const attr_t, short, void * );
382 extern int slk_attrset ( const chtype );
383 extern int slk_clear ( void );
384 extern int slk_colour ( short );
385 #define slk_color( c ) slk_colour( (c) )
386 extern int slk_init ( int );
387 extern char *slk_label ( int );
388 extern int slk_noutrefresh ( void );
389 //extern int slk_refresh ( void );
390 extern int slk_restore ( void );
391 extern int slk_set ( int, const char *, int ) __nonnull;
392 extern int slk_touch ( void );
393 extern int standend ( void );
394 extern int standout ( void );
395 //extern int start_colour ( void );
396 #define start_color() start_colour()
397 //extern WINDOW *subpad ( WINDOW *, int, int, int, int );
398 extern WINDOW *subwin ( WINDOW *, int, int, int, int ) __nonnull;
399 extern int syncok ( WINDOW *, bool );
400 extern chtype termattrs ( void );
401 extern attr_t term_attrs ( void );
402 extern char *termname ( void );
403 extern int tigetflag ( char * );
404 extern int tigetnum ( char * );
405 extern char *tigetstr ( char * );
406 extern void timeout ( int );
407 //extern int touchline ( WINDOW *, int, int );
408 //extern int touchwin ( WINDOW * );
409 extern char *tparm ( char *, long, long, long, long, long, long, long, long,
410 long );
411 extern int typeahead ( int );
412 //extern int ungetch ( int );
413 //extern int untouchwin ( WINDOW * );
414 extern void use_env ( bool );
415 extern int vid_attr ( attr_t, short, void * );
416 extern int vidattr ( chtype );
417 extern int vid_puts ( attr_t, short, void *, int ( *) ( int) );
418 extern int vidputs ( chtype, int ( *) ( int) );
419 //extern int vline ( chtype, int );
420 //extern int vwprintw ( WINDOW *, const char *, va_list );
421 extern int vw_printw ( WINDOW *, const char *, va_list ) __nonnull;
422 //extern int vwscanw ( WINDOW *, char *, va_list );
423 //extern int vw_scanw ( WINDOW *, char *, va_list );
424 extern int waddch ( WINDOW *, const chtype ) __nonnull;
425 extern int waddchnstr ( WINDOW *, const chtype *, int ) __nonnull;
426 //extern int waddchstr ( WINDOW *, const chtype * );
427 extern int waddnstr ( WINDOW *, const char *, int ) __nonnull;
428 //extern int waddstr ( WINDOW *, const char * );
429 extern int wattroff ( WINDOW *, int ) __nonnull;
430 extern int wattron ( WINDOW *, int ) __nonnull;
431 extern int wattrset ( WINDOW *, int ) __nonnull;
432 extern int wattr_get ( WINDOW *, attr_t *, short *, void * )
433 __attribute__ (( nonnull (1, 2, 3)));
434 extern int wattr_off ( WINDOW *, attr_t, void * )
435 __attribute__ (( nonnull (1)));
436 extern int wattr_on ( WINDOW *, attr_t, void * )
437 __attribute__ (( nonnull (1)));
438 extern int wattr_set ( WINDOW *, attr_t, short, void * )
439 __attribute__ (( nonnull (1)));
440 //extern void wbkgdset ( WINDOW *, chtype );
441 extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
442 chtype, chtype ) __nonnull;
443 extern int wclrtobot ( WINDOW * ) __nonnull;
444 extern int wclrtoeol ( WINDOW * ) __nonnull;
445 extern void wcursyncup ( WINDOW * );
446 extern int wcolour_set ( WINDOW *, short, void * ) __nonnull;
447 #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
448 extern int wdelch ( WINDOW * ) __nonnull;
449 extern int wdeleteln ( WINDOW * ) __nonnull;
450 extern int wechochar ( WINDOW *, const chtype );
451 extern int werase ( WINDOW * ) __nonnull;
452 extern int wgetch ( WINDOW * );
453 extern int wgetnstr ( WINDOW *, char *, int );
454 //extern int wgetstr ( WINDOW *, char * );
455 extern int whline ( WINDOW *, chtype, int ) __nonnull;
456 //extern chtype winch ( WINDOW * );
457 //extern int winchnstr ( WINDOW *, chtype *, int );
458 //extern int winchstr ( WINDOW *, chtype * );
459 //extern int winnstr ( WINDOW *, char *, int );
460 //extern int winsch ( WINDOW *, chtype );
461 //extern int winsnstr ( WINDOW *, const char *, int );
462 //extern int winsstr ( WINDOW *, const char * );
463 //extern int winstr ( WINDOW *, char * );
464 extern int wmove ( WINDOW *, int, int );
465 //extern int wnoutrefresh ( WINDOW * );
466 extern int wprintw ( WINDOW *, const char *, ... ) __nonnull;
467 //extern int wredrawln ( WINDOW *, int, int );
468 //extern int wrefresh ( WINDOW * );
469 //extern int wscanw ( WINDOW *, char *, ... );
470 //extern int wscrl ( WINDOW *, int );
471 //extern int wsetscrreg ( WINDOW *, int, int );
472 //extern int wstandend ( WINDOW * );
473 //extern int wstandout ( WINDOW * );
474 extern void wsyncup ( WINDOW * );
475 extern void wsyncdown ( WINDOW * );
476 extern void wtimeout ( WINDOW *, int );
477 //extern int wtouchln ( WINDOW *, int, int, int );
478 extern int wvline ( WINDOW *, chtype, int ) __nonnull;
479
480 /*
481 * There is frankly a ridiculous amount of redundancy within the
482 * curses API - ncurses decided to get around this by using #define
483 * macros, but I've decided to be type-safe and implement them all as
484 * static inlines instead...
485 */
486
487 static inline int addch ( const chtype ch ) {
488 return waddch( stdscr, ch );
489 }
490
491 static inline int addchnstr ( const chtype *chstr, int n ) {
492 return waddchnstr ( stdscr, chstr, n );
493 }
494
495 static inline int addchstr ( const chtype *chstr ) {
496 return waddchnstr ( stdscr, chstr, -1 );
497 }
498
499 static inline int addnstr ( const char *str, int n ) {
500 return waddnstr ( stdscr, str, n );
501 }
502
503 static inline int addstr ( const char *str ) {
504 return waddnstr ( stdscr, str, -1 );
505 }
506
507 static inline int attroff ( int attrs ) {
508 return wattroff ( stdscr, attrs );
509 }
510
511 static inline int attron ( int attrs ) {
512 return wattron ( stdscr, attrs );
513 }
514
515 static inline int attrset ( int attrs ) {
516 return wattrset ( stdscr, attrs );
517 }
518
519 static inline int attr_get ( attr_t *attrs, short *pair, void *opts ) {
520 return wattr_get ( stdscr, attrs, pair, opts );
521 }
522
523 static inline int attr_off ( attr_t attrs, void *opts ) {
524 return wattr_off ( stdscr, attrs, opts );
525 }
526
527 static inline int attr_on ( attr_t attrs, void *opts ) {
528 return wattr_on ( stdscr, attrs, opts );
529 }
530
531 static inline int attr_set ( attr_t attrs, short cpair, void *opts ) {
532 return wattr_set ( stdscr, attrs, cpair, opts );
533 }
534
535 static inline void bkgdset ( chtype ch ) {
536 wattrset ( stdscr, ch );
537 }
538
539 static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
540 chtype tl, chtype tr, chtype bl, chtype br ) {
541 return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
542 }
543
544 static inline bool can_change_colour ( void ) {
545 return FALSE;
546 }
547
548 static inline int clrtobot ( void ) {
549 return wclrtobot( stdscr );
550 }
551
552 static inline int clrtoeol ( void ) {
553 return wclrtoeol( stdscr );
554 }
555
556 static inline int colour_set ( short colour_pair_number, void *opts ) {
557 return wcolour_set ( stdscr, colour_pair_number, opts );
558 }
559
560 static inline int delch ( void ) {
561 return wdelch ( stdscr );
562 }
563
564 static inline int deleteln ( void ) {
565 return wdeleteln( stdscr );
566 }
567
568 static inline int getch ( void ) {
569 return wgetch ( stdscr );
570 }
571
572 static inline int getnstr ( char *str, int n ) {
573 return wgetnstr ( stdscr, str, n );
574 }
575
576 static inline int getstr ( char *str ) {
577 return wgetnstr ( stdscr, str, -1 );
578 }
579
580 static inline bool has_colors ( void ) {
581 return TRUE;
582 }
583
584 static inline int has_key ( int kc __unused ) {
585 return TRUE;
586 }
587
588 static inline int hline ( chtype ch, int n ) {
589 return whline ( stdscr, ch, n );
590 }
591
592 static inline int move ( int y, int x ) {
593 return wmove ( stdscr, y, x );
594 }
595
596 static inline int mvaddch ( int y, int x, const chtype ch ) {
597 return ( wmove ( stdscr, y, x ) == OK
598 ? waddch( stdscr, ch ) : ERR );
599 }
600
601 static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
602 return ( wmove ( stdscr, y, x ) == OK
603 ? waddchnstr ( stdscr, chstr, n ) : ERR );
604 }
605
606 static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
607 return ( wmove ( stdscr, y, x ) == OK
608 ? waddchnstr ( stdscr, chstr, -1 ) : ERR );
609 }
610
611 static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
612 return ( wmove ( stdscr, y, x ) == OK
613 ? waddnstr ( stdscr, str, n ) : ERR );
614 }
615
616 static inline int mvaddstr ( int y, int x, const char *str ) {
617 return ( wmove ( stdscr, y, x ) == OK
618 ? waddnstr ( stdscr, str, -1 ) : ERR );
619 }
620
621 static inline int mvdelch ( int y, int x ) {
622 return ( wmove ( stdscr, y, x ) == OK
623 ? wdelch ( stdscr ) : ERR );
624 }
625
626 static inline int mvgetch ( int y, int x ) {
627 return ( wmove ( stdscr, y, x ) == OK
628 ? wgetch ( stdscr ) : ERR );
629 }
630
631 static inline int mvgetnstr ( int y, int x, char *str, int n ) {
632 return ( wmove ( stdscr, y, x ) == OK
633 ? wgetnstr ( stdscr, str, n ) : ERR );
634 }
635
636 static inline int mvgetstr ( int y, int x, char *str ) {
637 return ( wmove ( stdscr, y, x ) == OK
638 ? wgetnstr ( stdscr, str, -1 ) : ERR );
639 }
640
641 static inline int mvhline ( int y, int x, chtype ch, int n ) {
642 return ( wmove ( stdscr, y, x ) == OK
643 ? whline ( stdscr, ch, n ) : ERR );
644 }
645
646 // OK, so maybe a few I did with macros...
647 #define mvprintw( y, x, fmt, ... ) \
648 ( wmove(stdscr,(y),(x)) == OK \
649 ? wprintw( stdscr,(fmt), ## __VA_ARGS__ ) : ERR )
650
651 static inline int mvvline ( int y, int x, chtype ch, int n ) {
652 return ( wmove ( stdscr, y, x ) == OK
653 ? wvline ( stdscr, ch, n ) : ERR );
654 }
655
656 static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
657 return ( wmove( win, y, x ) == OK
658 ? waddch ( win, ch ) : ERR );
659 }
660
661 static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
662 return ( wmove ( win, y, x ) == OK
663 ? waddchnstr ( win, chstr, n ) : ERR );
664 }
665
666 static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
667 return ( wmove ( win, y, x ) == OK
668 ? waddchnstr ( win, chstr, -1 ) : ERR );
669 }
670
671 static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
672 return ( wmove ( win, y, x ) == OK
673 ? waddnstr ( win, str, n ) : ERR );
674 }
675
676 static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
677 return ( wmove ( win, y, x ) == OK
678 ? waddnstr ( win, str, -1 ) : ERR );
679 }
680
681 static inline int mvwdelch ( WINDOW *win, int y, int x ) {
682 return ( wmove ( win, y, x ) == OK
683 ? wdelch ( win ) : ERR );
684 }
685
686 static inline int mvwgetch ( WINDOW *win, int y, int x ) {
687 return ( wmove ( win, y, x ) == OK
688 ? wgetch ( win ) : ERR );
689 }
690
691 static inline int mvwgetnstr ( WINDOW *win, int y, int x, char *str, int n ) {
692 return ( wmove ( win, y, x ) == OK
693 ? wgetnstr ( win, str, n ) : ERR );
694 }
695
696 static inline int mvwgetstr ( WINDOW *win, int y, int x, char *str ) {
697 return ( wmove ( win, y, x ) == OK
698 ? wgetnstr ( win, str, -1 ) : ERR );
699 }
700
701 static inline int mvwhline ( WINDOW *win, int y, int x, chtype ch, int n ) {
702 return ( wmove ( win, y, x ) == OK
703 ? whline ( win, ch, n ) : ERR );
704 }
705
706 #define mvwprintw( win, y, x, fmt, ... ) \
707 ( wmove((win),(y),(x)) == OK \
708 ? wprintw((win),(fmt), ## __VA_ARGS__) : ERR )
709
710 static inline int mvwvline ( WINDOW *win, int y, int x, chtype ch, int n ) {
711 return ( wmove ( win, y, x ) == OK
712 ? wvline ( win, ch, n ) : ERR );
713 }
714
715 #define printw( fmt, ... ) wprintw(stdscr,(fmt), ## __VA_ARGS__ )
716
717 static inline int slk_refresh ( void ) {
718 if ( slk_clear() == OK )
719 return slk_restore();
720 else
721 return ERR;
722 }
723
724 #define standend() wstandend( stdscr )
725 #define standout() wstandout( stdscr )
726
727 static inline int start_colour ( void ) {
728 return OK;
729 }
730
731 static inline int vline ( chtype ch, int n ) {
732 return wvline ( stdscr, ch, n );
733 }
734
735 // marked for removal
736 static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
737 return vw_printw ( win, fmt, varglist );
738 }
739
740 static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
741 return waddchnstr ( win, chstr, -1 );
742 }
743
744 static inline int waddstr ( WINDOW *win, const char *str ) {
745 return waddnstr ( win, str, -1 );
746 }
747
748 static inline int wbkgdset ( WINDOW *win, chtype ch ) {
749 return wattrset( win, ch );
750 }
751
752 static inline int wgetstr ( WINDOW *win, char *str ) {
753 return wgetnstr ( win, str, -1 );
754 }
755
756 static inline int wstandend ( WINDOW *win ) {
757 return wattrset ( win, A_DEFAULT );
758 }
759
760 static inline int wstandout ( WINDOW *win ) {
761 return wattrset ( win, A_STANDOUT );
762 }
763
764 #endif /* CURSES_H */