[smsc75xx] Expose functionality shared with LAN78xx devices
[ipxe.git] / src / include / curses.h
1 #ifndef CURSES_H
2 #define CURSES_H
3
4 #include <stdint.h>
5 #include <stdbool.h>
6 #include <stdarg.h>
7 #include <ipxe/console.h>
8
9 /** @file
10 *
11 * MuCurses header file
12 *
13 */
14
15 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
16
17 #undef ERR
18 #define ERR (-1)
19
20 #undef FALSE
21 #define FALSE (0)
22
23 #undef OK
24 #define OK (0)
25
26 #undef TRUE
27 #define TRUE (1)
28
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 * )
447 __attribute__ (( nonnull (1)));
448 #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
449 extern int wdelch ( WINDOW * ) __nonnull;
450 extern int wdeleteln ( WINDOW * ) __nonnull;
451 extern int wechochar ( WINDOW *, const chtype );
452 extern int werase ( WINDOW * ) __nonnull;
453 extern int wgetch ( WINDOW * );
454 extern int wgetnstr ( WINDOW *, char *, int );
455 //extern int wgetstr ( WINDOW *, char * );
456 extern int whline ( WINDOW *, chtype, int ) __nonnull;
457 //extern chtype winch ( WINDOW * );
458 //extern int winchnstr ( WINDOW *, chtype *, int );
459 //extern int winchstr ( WINDOW *, chtype * );
460 //extern int winnstr ( WINDOW *, char *, int );
461 //extern int winsch ( WINDOW *, chtype );
462 //extern int winsnstr ( WINDOW *, const char *, int );
463 //extern int winsstr ( WINDOW *, const char * );
464 //extern int winstr ( WINDOW *, char * );
465 extern int wmove ( WINDOW *, int, int );
466 //extern int wnoutrefresh ( WINDOW * );
467 extern int wprintw ( WINDOW *, const char *, ... ) __nonnull;
468 //extern int wredrawln ( WINDOW *, int, int );
469 //extern int wrefresh ( WINDOW * );
470 //extern int wscanw ( WINDOW *, char *, ... );
471 //extern int wscrl ( WINDOW *, int );
472 //extern int wsetscrreg ( WINDOW *, int, int );
473 //extern int wstandend ( WINDOW * );
474 //extern int wstandout ( WINDOW * );
475 extern void wsyncup ( WINDOW * );
476 extern void wsyncdown ( WINDOW * );
477 extern void wtimeout ( WINDOW *, int );
478 //extern int wtouchln ( WINDOW *, int, int, int );
479 extern int wvline ( WINDOW *, chtype, int ) __nonnull;
480
481 /*
482 * There is frankly a ridiculous amount of redundancy within the
483 * curses API - ncurses decided to get around this by using #define
484 * macros, but I've decided to be type-safe and implement them all as
485 * static inlines instead...
486 */
487
488 static inline int addch ( const chtype ch ) {
489 return waddch( stdscr, ch );
490 }
491
492 static inline int addchnstr ( const chtype *chstr, int n ) {
493 return waddchnstr ( stdscr, chstr, n );
494 }
495
496 static inline int addchstr ( const chtype *chstr ) {
497 return waddchnstr ( stdscr, chstr, -1 );
498 }
499
500 static inline int addnstr ( const char *str, int n ) {
501 return waddnstr ( stdscr, str, n );
502 }
503
504 static inline int addstr ( const char *str ) {
505 return waddnstr ( stdscr, str, -1 );
506 }
507
508 static inline int attroff ( int attrs ) {
509 return wattroff ( stdscr, attrs );
510 }
511
512 static inline int attron ( int attrs ) {
513 return wattron ( stdscr, attrs );
514 }
515
516 static inline int attrset ( int attrs ) {
517 return wattrset ( stdscr, attrs );
518 }
519
520 static inline int attr_get ( attr_t *attrs, short *pair, void *opts ) {
521 return wattr_get ( stdscr, attrs, pair, opts );
522 }
523
524 static inline int attr_off ( attr_t attrs, void *opts ) {
525 return wattr_off ( stdscr, attrs, opts );
526 }
527
528 static inline int attr_on ( attr_t attrs, void *opts ) {
529 return wattr_on ( stdscr, attrs, opts );
530 }
531
532 static inline int attr_set ( attr_t attrs, short cpair, void *opts ) {
533 return wattr_set ( stdscr, attrs, cpair, opts );
534 }
535
536 static inline void bkgdset ( chtype ch ) {
537 wattrset ( stdscr, ch );
538 }
539
540 static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
541 chtype tl, chtype tr, chtype bl, chtype br ) {
542 return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
543 }
544
545 static inline bool can_change_colour ( void ) {
546 return FALSE;
547 }
548
549 static inline int clrtobot ( void ) {
550 return wclrtobot( stdscr );
551 }
552
553 static inline int clrtoeol ( void ) {
554 return wclrtoeol( stdscr );
555 }
556
557 static inline int colour_set ( short colour_pair_number, void *opts ) {
558 return wcolour_set ( stdscr, colour_pair_number, opts );
559 }
560
561 static inline int delch ( void ) {
562 return wdelch ( stdscr );
563 }
564
565 static inline int deleteln ( void ) {
566 return wdeleteln( stdscr );
567 }
568
569 static inline int getch ( void ) {
570 return wgetch ( stdscr );
571 }
572
573 static inline int getnstr ( char *str, int n ) {
574 return wgetnstr ( stdscr, str, n );
575 }
576
577 static inline int getstr ( char *str ) {
578 return wgetnstr ( stdscr, str, -1 );
579 }
580
581 static inline bool has_colors ( void ) {
582 return TRUE;
583 }
584
585 static inline int has_key ( int kc __unused ) {
586 return TRUE;
587 }
588
589 static inline int hline ( chtype ch, int n ) {
590 return whline ( stdscr, ch, n );
591 }
592
593 static inline int move ( int y, int x ) {
594 return wmove ( stdscr, y, x );
595 }
596
597 static inline int mvaddch ( int y, int x, const chtype ch ) {
598 return ( wmove ( stdscr, y, x ) == OK
599 ? waddch( stdscr, ch ) : ERR );
600 }
601
602 static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
603 return ( wmove ( stdscr, y, x ) == OK
604 ? waddchnstr ( stdscr, chstr, n ) : ERR );
605 }
606
607 static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
608 return ( wmove ( stdscr, y, x ) == OK
609 ? waddchnstr ( stdscr, chstr, -1 ) : ERR );
610 }
611
612 static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
613 return ( wmove ( stdscr, y, x ) == OK
614 ? waddnstr ( stdscr, str, n ) : ERR );
615 }
616
617 static inline int mvaddstr ( int y, int x, const char *str ) {
618 return ( wmove ( stdscr, y, x ) == OK
619 ? waddnstr ( stdscr, str, -1 ) : ERR );
620 }
621
622 static inline int mvdelch ( int y, int x ) {
623 return ( wmove ( stdscr, y, x ) == OK
624 ? wdelch ( stdscr ) : ERR );
625 }
626
627 static inline int mvgetch ( int y, int x ) {
628 return ( wmove ( stdscr, y, x ) == OK
629 ? wgetch ( stdscr ) : ERR );
630 }
631
632 static inline int mvgetnstr ( int y, int x, char *str, int n ) {
633 return ( wmove ( stdscr, y, x ) == OK
634 ? wgetnstr ( stdscr, str, n ) : ERR );
635 }
636
637 static inline int mvgetstr ( int y, int x, char *str ) {
638 return ( wmove ( stdscr, y, x ) == OK
639 ? wgetnstr ( stdscr, str, -1 ) : ERR );
640 }
641
642 static inline int mvhline ( int y, int x, chtype ch, int n ) {
643 return ( wmove ( stdscr, y, x ) == OK
644 ? whline ( stdscr, ch, n ) : ERR );
645 }
646
647 // OK, so maybe a few I did with macros...
648 #define mvprintw( y, x, fmt, ... ) \
649 ( wmove(stdscr,(y),(x)) == OK \
650 ? wprintw( stdscr,(fmt), ## __VA_ARGS__ ) : ERR )
651
652 static inline int mvvline ( int y, int x, chtype ch, int n ) {
653 return ( wmove ( stdscr, y, x ) == OK
654 ? wvline ( stdscr, ch, n ) : ERR );
655 }
656
657 static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
658 return ( wmove( win, y, x ) == OK
659 ? waddch ( win, ch ) : ERR );
660 }
661
662 static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
663 return ( wmove ( win, y, x ) == OK
664 ? waddchnstr ( win, chstr, n ) : ERR );
665 }
666
667 static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
668 return ( wmove ( win, y, x ) == OK
669 ? waddchnstr ( win, chstr, -1 ) : ERR );
670 }
671
672 static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
673 return ( wmove ( win, y, x ) == OK
674 ? waddnstr ( win, str, n ) : ERR );
675 }
676
677 static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
678 return ( wmove ( win, y, x ) == OK
679 ? waddnstr ( win, str, -1 ) : ERR );
680 }
681
682 static inline int mvwdelch ( WINDOW *win, int y, int x ) {
683 return ( wmove ( win, y, x ) == OK
684 ? wdelch ( win ) : ERR );
685 }
686
687 static inline int mvwgetch ( WINDOW *win, int y, int x ) {
688 return ( wmove ( win, y, x ) == OK
689 ? wgetch ( win ) : ERR );
690 }
691
692 static inline int mvwgetnstr ( WINDOW *win, int y, int x, char *str, int n ) {
693 return ( wmove ( win, y, x ) == OK
694 ? wgetnstr ( win, str, n ) : ERR );
695 }
696
697 static inline int mvwgetstr ( WINDOW *win, int y, int x, char *str ) {
698 return ( wmove ( win, y, x ) == OK
699 ? wgetnstr ( win, str, -1 ) : ERR );
700 }
701
702 static inline int mvwhline ( WINDOW *win, int y, int x, chtype ch, int n ) {
703 return ( wmove ( win, y, x ) == OK
704 ? whline ( win, ch, n ) : ERR );
705 }
706
707 #define mvwprintw( win, y, x, fmt, ... ) \
708 ( wmove((win),(y),(x)) == OK \
709 ? wprintw((win),(fmt), ## __VA_ARGS__) : ERR )
710
711 static inline int mvwvline ( WINDOW *win, int y, int x, chtype ch, int n ) {
712 return ( wmove ( win, y, x ) == OK
713 ? wvline ( win, ch, n ) : ERR );
714 }
715
716 #define printw( fmt, ... ) wprintw(stdscr,(fmt), ## __VA_ARGS__ )
717
718 static inline int slk_refresh ( void ) {
719 if ( slk_clear() == OK )
720 return slk_restore();
721 else
722 return ERR;
723 }
724
725 #define standend() wstandend( stdscr )
726 #define standout() wstandout( stdscr )
727
728 static inline int start_colour ( void ) {
729 return OK;
730 }
731
732 static inline int vline ( chtype ch, int n ) {
733 return wvline ( stdscr, ch, n );
734 }
735
736 // marked for removal
737 static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
738 return vw_printw ( win, fmt, varglist );
739 }
740
741 static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
742 return waddchnstr ( win, chstr, -1 );
743 }
744
745 static inline int waddstr ( WINDOW *win, const char *str ) {
746 return waddnstr ( win, str, -1 );
747 }
748
749 static inline int wbkgdset ( WINDOW *win, chtype ch ) {
750 return wattrset( win, ch );
751 }
752
753 static inline int wgetstr ( WINDOW *win, char *str ) {
754 return wgetnstr ( win, str, -1 );
755 }
756
757 static inline int wstandend ( WINDOW *win ) {
758 return wattrset ( win, A_DEFAULT );
759 }
760
761 static inline int wstandout ( WINDOW *win ) {
762 return wattrset ( win, A_STANDOUT );
763 }
764
765 #endif /* CURSES_H */