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