iPXE
curses.h
Go to the documentation of this file.
00001 #ifndef CURSES_H
00002 #define CURSES_H
00003 
00004 #include <stdint.h>
00005 #include <stdbool.h>
00006 #include <stdarg.h>
00007 #include <ipxe/console.h>
00008 
00009 /** @file
00010  *
00011  * MuCurses header file
00012  *
00013  */
00014 
00015 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00016 
00017 #undef  ERR
00018 #define ERR     (-1)
00019 
00020 #undef  FALSE
00021 #define FALSE   (0)
00022 
00023 #undef  OK
00024 #define OK      (0)
00025 
00026 #undef  TRUE
00027 #define TRUE    (1)
00028 
00029 typedef uint32_t chtype;
00030 typedef uint32_t attr_t;
00031 
00032 /** Curses SCREEN object */
00033 typedef struct _curses_screen {
00034         /** Current cursor position */
00035         unsigned int curs_x, curs_y;
00036         /** Current attribute */
00037         attr_t attrs;
00038 
00039         void ( *init ) ( struct _curses_screen *scr );
00040         void ( *exit ) ( struct _curses_screen *scr );
00041         /**
00042          * Erase screen
00043          *
00044          * @v scr       screen on which to operate
00045          * @v attrs     attributes
00046          */
00047         void ( * erase ) ( struct _curses_screen *scr, attr_t attrs );
00048         /**
00049          * Move cursor to position specified by x,y coords
00050          *
00051          * @v scr       screen on which to operate
00052          * @v y         Y position
00053          * @v x         X position
00054          */
00055         void ( * movetoyx ) ( struct _curses_screen *scr,
00056                               unsigned int y, unsigned int x );
00057         /**
00058          * Write character to current cursor position
00059          *
00060          * @v scr       screen on which to operate
00061          * @v c         character to be written
00062          */
00063         void ( * putc ) ( struct _curses_screen *scr, chtype c );
00064         /**
00065          * Pop a character from the keyboard input stream
00066          *
00067          * @v scr       screen on which to operate
00068          * @ret c       popped character
00069          */
00070         int ( * getc ) ( struct _curses_screen *scr );
00071         /**
00072          * Checks to see whether a character is waiting in the input stream
00073          *
00074          * @v scr       screen on which to operate
00075          * @ret TRUE    character waiting in stream
00076          * @ret FALSE   no character waiting in stream
00077          */
00078         bool ( *peek ) ( struct _curses_screen *scr );
00079         /**
00080          * Set cursor visibility
00081          *
00082          * @v scr       screen on which to operate
00083          * @v visibility cursor visibility
00084          */
00085         void ( * cursor ) ( struct _curses_screen *scr, int visibility );
00086 } SCREEN;
00087 
00088 /** Curses Window struct */
00089 typedef struct _curses_window {
00090         /** screen with which window associates */
00091         SCREEN *scr;
00092         /** window attributes */
00093         attr_t attrs;
00094         /** window origin coordinates */
00095         unsigned int ori_x, ori_y;
00096         /** window cursor position */
00097         unsigned int curs_x, curs_y;
00098         /** window dimensions */
00099         unsigned int width, height;
00100         /** parent window */
00101         struct _curses_window *parent;
00102         /** windows that share the same parent as this one */
00103         //struct list_head siblings;
00104         /** windows der'd or sub'd from this one */
00105         //struct list_head children;
00106 } WINDOW;
00107 
00108 extern WINDOW _stdscr;
00109 
00110 #define stdscr ( &_stdscr )
00111 #define COLS console_width
00112 #define LINES console_height
00113 
00114 #define MUCURSES_BITS( mask, shift ) (( mask ) << (shift))
00115 #define CPAIR_SHIFT     8
00116 #define ATTRS_SHIFT     16
00117 
00118 #define WA_DEFAULT      ( 0x0000 << ATTRS_SHIFT )
00119 #define WA_ALTCHARSET   ( 0x0001 << ATTRS_SHIFT )
00120 #define WA_BLINK        ( 0x0002 << ATTRS_SHIFT )
00121 #define WA_BOLD         ( 0x0004 << ATTRS_SHIFT )
00122 #define WA_DIM          ( 0x0008 << ATTRS_SHIFT )
00123 #define WA_INVIS        ( 0x0010 << ATTRS_SHIFT )
00124 #define WA_PROTECT      ( 0x0020 << ATTRS_SHIFT )
00125 #define WA_REVERSE      ( 0x0040 << ATTRS_SHIFT )
00126 #define WA_STANDOUT     ( 0x0080 << ATTRS_SHIFT )
00127 #define WA_UNDERLINE    ( 0x0100 << ATTRS_SHIFT )
00128 #define WA_HORIZONTAL   ( 0x0200 << ATTRS_SHIFT )
00129 #define WA_VERTICAL     ( 0x0400 << ATTRS_SHIFT )
00130 #define WA_LEFT         ( 0x0800 << ATTRS_SHIFT )
00131 #define WA_RIGHT        ( 0x1000 << ATTRS_SHIFT )
00132 #define WA_LOW          ( 0x2000 << ATTRS_SHIFT )
00133 #define WA_TOP          ( 0x4000 << ATTRS_SHIFT )
00134 
00135 #define A_DEFAULT       WA_DEFAULT
00136 #define A_ALTCHARSET    WA_ALTCHARSET
00137 #define A_BLINK         WA_BLINK
00138 #define A_BOLD          WA_BOLD
00139 #define A_DIM           WA_DIM
00140 #define A_INVIS         WA_INVIS
00141 #define A_PROTECT       WA_PROTECT
00142 #define A_REVERSE       WA_REVERSE
00143 #define A_STANDOUT      WA_STANDOUT
00144 #define A_UNDERLINE     WA_UNDERLINE
00145 
00146 #define A_ATTRIBUTES    ( 0xffff << ATTRS_SHIFT )
00147 #define A_CHARTEXT      ( 0xff )
00148 #define A_COLOUR        ( 0xff << CPAIR_SHIFT )
00149 #define A_COLOR         A_COLOUR
00150 
00151 #define COLOUR_PAIR(n)  ( (n) << CPAIR_SHIFT )
00152 #define COLOR_PAIR(n)   COLOUR_PAIR(n)
00153 #define PAIR_NUMBER(attrs) ( ( (attrs) & A_COLOUR ) >> CPAIR_SHIFT )
00154 
00155 #define COLOUR_PAIRS    8 /* Arbitrary limit */
00156 #define COLOR_PAIRS     COLOUR_PAIRS
00157 
00158 #define ACS_ULCORNER    '+'
00159 #define ACS_LLCORNER    '+'
00160 #define ACS_URCORNER    '+'
00161 #define ACS_LRCORNER    '+'
00162 #define ACS_RTEE        '+'
00163 #define ACS_LTEE        '+'
00164 #define ACS_BTEE        '+'
00165 #define ACS_TTEE        '+'
00166 #define ACS_HLINE       '-'
00167 #define ACS_VLINE       '|'
00168 #define ACS_PLUS        '+'
00169 #define ACS_S1          '-'
00170 #define ACS_S9          '_'
00171 #define ACS_DIAMOND     '+'
00172 #define ACS_CKBOARD     ':'
00173 #define ACS_DEGREE      '\''
00174 #define ACS_PLMINUS     '#'
00175 #define ACS_BULLET      'o'
00176 #define ACS_LARROW      '<'
00177 #define ACS_RARROW      '>'
00178 #define ACS_DARROW      'v'
00179 #define ACS_UARROW      '^'
00180 #define ACS_BOARD       '#'
00181 #define ACS_LANTERN     '#'
00182 #define ACS_BLOCK       '#'
00183 
00184 #define COLOUR_BLACK    0
00185 #define COLOUR_RED      1
00186 #define COLOUR_GREEN    2
00187 #define COLOUR_YELLOW   3
00188 #define COLOUR_BLUE     4
00189 #define COLOUR_MAGENTA  5
00190 #define COLOUR_CYAN     6
00191 #define COLOUR_WHITE    7
00192 #define COLOURS         7
00193 
00194 #define COLOUR_FG       30
00195 #define COLOUR_BG       40
00196 #define COLOR_FG        COLOUR_FG
00197 #define COLOR_BG        COLOUR_BG
00198 
00199 #define COLOR_BLACK     COLOUR_BLACK
00200 #define COLOR_BLUE      COLOUR_BLUE
00201 #define COLOR_GREEN     COLOUR_GREEN
00202 #define COLOR_CYAN      COLOUR_CYAN
00203 #define COLOR_RED       COLOUR_RED
00204 #define COLOR_MAGENTA   COLOUR_MAGENTA
00205 #define COLOR_YELLOW    COLOUR_YELLOW
00206 #define COLOR_WHITE     COLOUR_WHITE
00207 #define COLORS          COLOURS
00208 
00209 /*
00210  * KEY code constants are define in ipxe/keys.h
00211  */
00212 #include <ipxe/keys.h>
00213 
00214 //extern int addch ( const chtype * );
00215 //extern int addchnstr ( const chtype *, int );
00216 //extern int addchstr ( const chtype * );
00217 //extern int addnstr ( const char *, int );
00218 //extern int addstr ( const char * );
00219 //extern int attroff ( int );
00220 //extern int attron ( int );
00221 //extern int attrset ( int );
00222 //extern int attr_get ( attr_t *, short *, void * );
00223 //extern int attr_off ( attr_t, void * );
00224 //extern int attr_on ( attr_t, void * );
00225 //extern int attr_set ( attr_t, short, void * );
00226 extern int baudrate ( void );
00227 extern int beep ( void );
00228 //extern void bkgdset ( chtype );
00229 /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
00230   chtype );*/
00231 extern int box ( WINDOW *, chtype, chtype ) __nonnull;
00232 //extern bool can_change_colour ( void );
00233 #define can_change_color() can_change_colour()
00234 extern int cbreak ( void ); 
00235 //extern int clrtobot ( void );
00236 //extern int clrtoeol ( void );
00237 extern int colour_content ( short, short *, short *, short * ) __nonnull;
00238 #define color_content( c, r, g, b ) colour_content( (c), (r), (g), (b) )
00239 //extern int colour_set ( short, void * );
00240 #define color_set( cpno, opts ) colour_set( (cpno), (opts) )
00241 extern int copywin ( const WINDOW *, WINDOW *, int, int, int, 
00242                      int, int, int, int );
00243 extern int curs_set ( int );
00244 extern int def_prog_mode ( void );
00245 extern int def_shell_mode ( void );
00246 extern int delay_output ( int );
00247 //extern int delch ( void );
00248 //extern int deleteln ( void );
00249 extern void delscreen ( SCREEN * );
00250 extern int delwin ( WINDOW * ) __nonnull;
00251 extern WINDOW *derwin ( WINDOW *, int, int, int, int ) __nonnull;
00252 //extern int doupdate ( void );
00253 extern WINDOW *dupwin ( WINDOW * ) __nonnull;
00254 extern int echo ( void );
00255 extern int echochar ( const chtype );
00256 extern int endwin ( void );
00257 extern char erasechar ( void );
00258 extern int erase ( void );
00259 extern void filter ( void );
00260 extern int flash ( void );
00261 extern int flushinp ( void );
00262 extern __pure chtype getbkgd ( WINDOW * ) __nonnull;
00263 //extern int getch ( void );
00264 //extern int getnstr ( char *, int );
00265 //extern int getstr ( char * );
00266 extern int halfdelay ( int );
00267 //extern bool has_colors ( void );
00268 extern bool has_ic ( void );
00269 extern bool has_il ( void );
00270 //extern int hline ( chtype, int );
00271 extern void idcok ( WINDOW *, bool );
00272 extern int idlok ( WINDOW *, bool );
00273 //extern void immedok ( WINDOW *, bool );
00274 //extern chtype inch ( void );
00275 //extern int inchnstr ( chtype *, int );
00276 //extern int inchstr ( chtype * );
00277 extern WINDOW *initscr ( void );
00278 extern int init_colour ( short, short, short, short );
00279 #define init_color ( c, r, g, b ) init_colour ( (c), (r), (g), (b) )
00280 extern int init_pair ( short, short, short );
00281 //extern int innstr ( char *, int );
00282 //extern int insch ( chtype );
00283 //extern int insnstr ( const char *, int );
00284 //extern int insstr ( const char * );
00285 //extern int instr ( char * );
00286 extern int intrflush ( WINDOW *, bool );
00287 extern bool isendwin ( void );
00288 //extern bool is_linetouched ( WINDOW *, int );
00289 //extern bool is_wintouched ( WINDOW * );
00290 extern char *keyname ( int );
00291 extern int keypad ( WINDOW *, bool );
00292 extern char killchar ( void );
00293 extern int leaveok ( WINDOW *, bool );
00294 extern char *longname ( void );
00295 extern int meta ( WINDOW *, bool );
00296 //extern int move ( int, int );
00297 //extern int mvaddch ( int, int, const chtype );
00298 //extern int mvaddchnstr ( int, int, const chtype *, int );
00299 //extern int mvaddchstr ( int, int, const chtype * );
00300 //extern int mvaddnstr ( int, int, const char *, int );
00301 //extern int mvaddstr ( int, int, const char * );
00302 extern int mvcur ( int, int, int, int );
00303 //extern int mvdelch ( int, int );
00304 extern int mvderwin ( WINDOW *, int, int );
00305 //extern int mvgetch ( int, int );
00306 //extern int mvgetnstr ( int, int, char *, int );
00307 //extern int mvgetstr ( int, int, char * );
00308 //extern int mvhline ( int, int, chtype, int );
00309 //extern chtype mvinch ( int, int );
00310 //extern int mvinchnstr ( int, int, chtype *, int );
00311 //extern int mvinchstr ( int, int, chtype * );
00312 //extern int mvinnstr ( int, int, char *, int );
00313 //extern int mvinsch ( int, int, chtype );
00314 //extern int mvinsnstr ( int, int, const char *, int );
00315 //extern int mvinsstr ( int, int, const char * );
00316 //extern int mvinstr ( int, int, char * );
00317 //extern int mvprintw ( int, int, char *,  ... );
00318 //extern int mvscanw ( int, int, char *, ... );
00319 //extern int mvvline ( int, int, chtype, int );
00320 //extern int mvwaddch ( WINDOW *, int, int, const chtype );
00321 //extern int mvwaddchnstr ( WINDOW *, int, int, const chtype *, int );
00322 //extern int mvwaddchstr ( WINDOW *, int, int, const chtype * );
00323 //extern int mvwaddnstr ( WINDOW *, int, int, const char *, int );
00324 //extern int mvwaddstr ( WINDOW *, int, int, const char * );
00325 //extern int mvwdelch ( WINDOW *, int, int );
00326 //extern int mvwgetch ( WINDOW *, int, int );
00327 //extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
00328 //extern int mvwgetstr ( WINDOW *, int, int, char * );
00329 //extern int mvwhline ( WINDOW *, int, int, chtype, int );
00330 extern int mvwin ( WINDOW *, int, int ) __nonnull;
00331 //extern chtype mvwinch ( WINDOW *, int, int );
00332 //extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int );
00333 //extern int mvwinchstr ( WINDOW *, int, int, chtype * );
00334 //extern int mvwinnstr ( WINDOW *, int, int, char *, int );
00335 //extern int mvwinsch ( WINDOW *, int, int, chtype );
00336 //extern int mvwinsnstr ( WINDOW *, int, int, const char *, int );
00337 //extern int mvwinsstr ( WINDOW *, int, int, const char * );
00338 //extern int mvwinstr ( WINDOW *, int, int, char * );
00339 //extern int mvwprintw ( WINDOW *, int, int, char *, ... );
00340 //extern int mvwscanw ( WINDOW *, int, int, char *, ... );
00341 //extern int mvwvline ( WINDOW *, int, int, chtype, int );
00342 extern int napms ( int );
00343 //extern WINDOW *newpad ( int, int );
00344 extern WINDOW *newwin ( int, int, int, int );
00345 extern int nl ( void );
00346 extern int nocbreak ( void );
00347 extern int nodelay ( WINDOW *, bool );
00348 extern int noecho ( void );
00349 extern int nonl ( void );
00350 extern void noqiflush ( void );
00351 extern int noraw ( void );
00352 extern int notimeout ( WINDOW *, bool );
00353 extern int overlay ( const WINDOW *, WINDOW * );
00354 extern int overwrite ( const WINDOW *, WINDOW * );
00355 extern int pair_content ( short, short *, short * ) __nonnull;
00356 //extern int pechochar ( WINDOW *, chtype );
00357 //extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
00358 //extern int prefresh ( WINDOW *, int, int, int, int, int, int );
00359 extern int printw ( char *, ... );
00360 extern int putp ( const char * );
00361 extern void qiflush ( void );
00362 extern int raw ( void );
00363 //extern int redrawwin ( WINDOW * );
00364 //extern int refresh ( void );
00365 extern int reset_prog_mode ( void );
00366 extern int reset_shell_mode ( void );
00367 extern int resetty ( void );
00368 extern int ripoffline ( int, int  (*) ( WINDOW *, int) );
00369 extern int savetty ( void );
00370 //extern int scanw ( char *, ... );
00371 //extern int scrl ( int );
00372 //extern int scroll ( WINDOW * );
00373 //extern int scrollok ( WINDOW *, bool );
00374 //extern int setscrreg ( int, int );
00375 extern SCREEN *set_term ( SCREEN * );
00376 extern int setupterm ( char *, int, int * );
00377 extern int slk_attr_off ( const attr_t, void * );
00378 extern int slk_attroff ( const chtype );
00379 extern int slk_attr_on ( const attr_t, void * );
00380 extern int slk_attron ( const chtype );
00381 extern int slk_attr_set ( const attr_t, short, void * );
00382 extern int slk_attrset ( const chtype );
00383 extern int slk_clear ( void );
00384 extern int slk_colour ( short );
00385 #define slk_color( c ) slk_colour( (c) )
00386 extern int slk_init ( int );
00387 extern char *slk_label ( int );
00388 extern int slk_noutrefresh ( void );
00389 //extern int slk_refresh ( void );
00390 extern int slk_restore ( void );
00391 extern int slk_set ( int, const char *, int ) __nonnull;
00392 extern int slk_touch ( void );
00393 extern int standend ( void );
00394 extern int standout ( void );
00395 //extern int start_colour ( void );
00396 #define start_color() start_colour()
00397 //extern WINDOW *subpad ( WINDOW *, int, int, int, int );
00398 extern WINDOW *subwin ( WINDOW *, int, int, int, int ) __nonnull;
00399 extern int syncok ( WINDOW *, bool );
00400 extern chtype termattrs ( void );
00401 extern attr_t term_attrs ( void );
00402 extern char *termname ( void );
00403 extern int tigetflag ( char * );
00404 extern int tigetnum ( char * );
00405 extern char *tigetstr ( char * );
00406 extern void timeout ( int );
00407 //extern int touchline ( WINDOW *, int, int );
00408 //extern int touchwin ( WINDOW * );
00409 extern char *tparm ( char *, long, long, long, long, long, long, long, long,
00410                    long );
00411 extern int typeahead ( int );
00412 //extern int ungetch ( int );
00413 //extern int untouchwin ( WINDOW * );
00414 extern void use_env ( bool );
00415 extern int vid_attr ( attr_t, short, void * );
00416 extern int vidattr ( chtype );
00417 extern int vid_puts ( attr_t, short, void *, int  ( *) ( int) );
00418 extern int vidputs ( chtype, int  ( *) ( int) );
00419 //extern int vline ( chtype, int );
00420 //extern int vwprintw ( WINDOW *, const char *, va_list );
00421 extern int vw_printw ( WINDOW *, const char *, va_list ) __nonnull;
00422 //extern int vwscanw ( WINDOW *, char *, va_list );
00423 //extern int vw_scanw ( WINDOW *, char *, va_list );
00424 extern int waddch ( WINDOW *, const chtype ) __nonnull;
00425 extern int waddchnstr ( WINDOW *, const chtype *, int ) __nonnull;
00426 //extern int waddchstr ( WINDOW *, const chtype * );
00427 extern int waddnstr ( WINDOW *, const char *, int ) __nonnull;
00428 //extern int waddstr ( WINDOW *, const char * );
00429 extern int wattroff ( WINDOW *, int ) __nonnull;
00430 extern int wattron ( WINDOW *, int ) __nonnull;
00431 extern int wattrset ( WINDOW *, int ) __nonnull;
00432 extern int wattr_get ( WINDOW *, attr_t *, short *, void * )
00433         __attribute__ (( nonnull (1, 2, 3)));
00434 extern int wattr_off ( WINDOW *, attr_t, void * )
00435         __attribute__ (( nonnull (1)));
00436 extern int wattr_on ( WINDOW *, attr_t, void * )
00437         __attribute__ (( nonnull (1)));
00438 extern int wattr_set ( WINDOW *, attr_t, short, void * )
00439         __attribute__ (( nonnull (1)));
00440 //extern void wbkgdset ( WINDOW *, chtype );
00441 extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
00442                    chtype, chtype ) __nonnull;
00443 extern int wclrtobot ( WINDOW * ) __nonnull;
00444 extern int wclrtoeol ( WINDOW * ) __nonnull;
00445 extern void wcursyncup ( WINDOW * );
00446 extern int wcolour_set ( WINDOW *, short, void * )
00447         __attribute__ (( nonnull (1)));
00448 #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
00449 extern int wdelch ( WINDOW * ) __nonnull;
00450 extern int wdeleteln ( WINDOW * ) __nonnull;
00451 extern int wechochar ( WINDOW *, const chtype );
00452 extern int werase ( WINDOW * ) __nonnull;
00453 extern int wgetch ( WINDOW * );
00454 extern int wgetnstr ( WINDOW *, char *, int );
00455 //extern int wgetstr ( WINDOW *, char * );
00456 extern int whline ( WINDOW *, chtype, int ) __nonnull;
00457 //extern chtype winch ( WINDOW * );
00458 //extern int winchnstr ( WINDOW *, chtype *, int );
00459 //extern int winchstr ( WINDOW *, chtype * );
00460 //extern int winnstr ( WINDOW *, char *, int );
00461 //extern int winsch ( WINDOW *, chtype );
00462 //extern int winsnstr ( WINDOW *, const char *, int );
00463 //extern int winsstr ( WINDOW *, const char * );
00464 //extern int winstr ( WINDOW *, char * );
00465 extern int wmove ( WINDOW *, int, int );
00466 //extern int wnoutrefresh ( WINDOW * );
00467 extern int wprintw ( WINDOW *, const char *, ... ) __nonnull;
00468 //extern int wredrawln ( WINDOW *, int, int );
00469 //extern int wrefresh ( WINDOW * );
00470 //extern int wscanw ( WINDOW *, char *, ... );
00471 //extern int wscrl ( WINDOW *, int );
00472 //extern int wsetscrreg ( WINDOW *, int, int );
00473 //extern int wstandend ( WINDOW * );
00474 //extern int wstandout ( WINDOW * );
00475 extern void wsyncup ( WINDOW * );
00476 extern void wsyncdown ( WINDOW * );
00477 extern void wtimeout ( WINDOW *, int );
00478 //extern int wtouchln ( WINDOW *, int, int, int );
00479 extern int wvline ( WINDOW *, chtype, int ) __nonnull;
00480 
00481 /*
00482  * There is frankly a ridiculous amount of redundancy within the
00483  * curses API - ncurses decided to get around this by using #define
00484  * macros, but I've decided to be type-safe and implement them all as
00485  * static inlines instead...
00486  */
00487 
00488 static inline int addch ( const chtype ch ) {
00489         return waddch( stdscr, ch );
00490 }
00491 
00492 static inline int addchnstr ( const chtype *chstr, int n ) {
00493         return waddchnstr ( stdscr, chstr, n );
00494 }
00495 
00496 static inline int addchstr ( const chtype *chstr ) {
00497         return waddchnstr ( stdscr, chstr, -1 );
00498 }
00499 
00500 static inline int addnstr ( const char *str, int n ) {
00501         return waddnstr ( stdscr, str, n );
00502 }
00503 
00504 static inline int addstr ( const char *str ) {
00505         return waddnstr ( stdscr, str, -1 );
00506 }
00507 
00508 static inline int attroff ( int attrs ) {
00509         return wattroff ( stdscr, attrs );
00510 }
00511 
00512 static inline int attron ( int attrs ) {
00513         return wattron ( stdscr, attrs );
00514 }
00515 
00516 static inline int attrset ( int attrs ) {
00517         return wattrset ( stdscr, attrs );
00518 }
00519 
00520 static inline int attr_get ( attr_t *attrs, short *pair, void *opts ) {
00521         return wattr_get ( stdscr, attrs, pair, opts );
00522 }
00523 
00524 static inline int attr_off ( attr_t attrs, void *opts ) {
00525         return wattr_off ( stdscr, attrs, opts );
00526 }
00527 
00528 static inline int attr_on ( attr_t attrs, void *opts ) {
00529         return wattr_on ( stdscr, attrs, opts );
00530 }
00531 
00532 static inline int attr_set ( attr_t attrs, short cpair, void *opts ) {
00533         return wattr_set ( stdscr, attrs, cpair, opts );
00534 }
00535 
00536 static inline void bkgdset ( chtype ch ) {
00537         wattrset ( stdscr, ch );
00538 }
00539 
00540 static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
00541                            chtype tl, chtype tr, chtype bl, chtype br ) {
00542         return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
00543 }
00544 
00545 static inline bool can_change_colour ( void ) {
00546         return FALSE;
00547 }
00548 
00549 static inline int clrtobot ( void ) {
00550         return wclrtobot( stdscr );
00551 }
00552 
00553 static inline int clrtoeol ( void ) {
00554         return wclrtoeol( stdscr );
00555 }
00556 
00557 static inline int colour_set ( short colour_pair_number, void *opts ) {
00558         return wcolour_set ( stdscr, colour_pair_number, opts );
00559 }
00560 
00561 static inline int delch ( void ) {
00562         return wdelch ( stdscr );
00563 }
00564 
00565 static inline int deleteln ( void ) {
00566         return wdeleteln( stdscr );
00567 }
00568 
00569 static inline int getch ( void ) {
00570         return wgetch ( stdscr );
00571 }
00572 
00573 static inline int getnstr ( char *str, int n ) {
00574         return wgetnstr ( stdscr, str, n );
00575 }
00576 
00577 static inline int getstr ( char *str ) {
00578         return wgetnstr ( stdscr, str, -1 );
00579 }
00580 
00581 static inline bool has_colors ( void ) {
00582         return TRUE;
00583 }
00584 
00585 static inline int has_key ( int kc __unused ) {
00586         return TRUE;
00587 }
00588 
00589 static inline int hline ( chtype ch, int n ) {
00590         return whline ( stdscr, ch, n );
00591 }
00592 
00593 static inline int move ( int y, int x ) {
00594         return wmove ( stdscr, y, x );
00595 }
00596 
00597 static inline int mvaddch ( int y, int x, const chtype ch ) {
00598         return ( wmove ( stdscr, y, x ) == OK
00599                  ? waddch( stdscr, ch ) : ERR );
00600 }
00601 
00602 static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
00603         return ( wmove ( stdscr, y, x ) == OK
00604                  ? waddchnstr ( stdscr, chstr, n ) : ERR );
00605 }
00606 
00607 static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
00608         return ( wmove ( stdscr, y, x ) == OK
00609                  ? waddchnstr ( stdscr, chstr, -1 ) : ERR );
00610 }
00611 
00612 static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
00613         return ( wmove ( stdscr, y, x ) == OK
00614                  ? waddnstr ( stdscr, str, n ) : ERR );
00615 }
00616 
00617 static inline int mvaddstr ( int y, int x, const char *str ) {
00618         return ( wmove ( stdscr, y, x ) == OK
00619                  ? waddnstr ( stdscr, str, -1 ) : ERR );
00620 }
00621 
00622 static inline int mvdelch ( int y, int x ) {
00623         return ( wmove ( stdscr, y, x ) == OK
00624                  ? wdelch ( stdscr ) : ERR );
00625 }
00626 
00627 static inline int mvgetch ( int y, int x ) {
00628         return ( wmove ( stdscr, y, x ) == OK
00629                  ? wgetch ( stdscr ) : ERR );
00630 }
00631 
00632 static inline int mvgetnstr ( int y, int x, char *str, int n ) {
00633         return ( wmove ( stdscr, y, x ) == OK
00634                  ? wgetnstr ( stdscr, str, n ) : ERR );
00635 }
00636 
00637 static inline int mvgetstr ( int y, int x, char *str ) {
00638         return ( wmove ( stdscr, y, x ) == OK
00639                  ? wgetnstr ( stdscr, str, -1 ) : ERR );
00640 }
00641 
00642 static inline int mvhline ( int y, int x, chtype ch, int n ) {
00643         return ( wmove ( stdscr, y, x ) == OK
00644                  ? whline ( stdscr, ch, n ) : ERR );
00645 }
00646 
00647 // OK, so maybe a few I did with macros...
00648 #define mvprintw( y, x, fmt, ... ) \
00649         ( wmove(stdscr,(y),(x)) == OK \
00650           ? wprintw( stdscr,(fmt), ## __VA_ARGS__ ) : ERR )
00651 
00652 static inline int mvvline ( int y, int x, chtype ch, int n ) {
00653         return ( wmove ( stdscr, y, x ) == OK
00654                  ? wvline ( stdscr, ch, n ) : ERR );
00655 }
00656 
00657 static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
00658         return ( wmove( win, y, x ) == OK
00659                  ? waddch ( win, ch ) : ERR );
00660 }
00661 
00662 static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
00663         return ( wmove ( win, y, x ) == OK
00664                  ? waddchnstr ( win, chstr, n ) : ERR );
00665 }
00666 
00667 static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
00668         return ( wmove ( win, y, x ) == OK
00669                  ? waddchnstr ( win, chstr, -1 ) : ERR );
00670 }
00671 
00672 static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
00673         return ( wmove ( win, y, x ) == OK
00674                  ? waddnstr ( win, str, n ) : ERR );
00675 }
00676 
00677 static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
00678         return ( wmove ( win, y, x ) == OK
00679                  ? waddnstr ( win, str, -1 ) : ERR );
00680 }
00681 
00682 static inline int mvwdelch ( WINDOW *win, int y, int x ) {
00683         return ( wmove ( win, y, x ) == OK
00684                  ? wdelch ( win ) : ERR );
00685 }
00686 
00687 static inline int mvwgetch ( WINDOW *win, int y, int x ) {
00688         return ( wmove ( win, y, x ) == OK
00689                  ? wgetch ( win ) : ERR );
00690 }
00691 
00692 static inline int mvwgetnstr ( WINDOW *win, int y, int x, char *str, int n ) {
00693         return ( wmove ( win, y, x ) == OK
00694                  ? wgetnstr ( win, str, n ) : ERR );
00695 }
00696 
00697 static inline int mvwgetstr ( WINDOW *win, int y, int x, char *str ) {
00698         return ( wmove ( win, y, x ) == OK
00699                  ? wgetnstr ( win, str, -1 ) : ERR );
00700 }
00701 
00702 static inline int mvwhline ( WINDOW *win, int y, int x, chtype ch, int n ) {
00703         return ( wmove ( win, y, x ) == OK
00704                  ? whline ( win, ch, n ) : ERR );
00705 }
00706 
00707 #define mvwprintw( win, y, x, fmt, ... ) \
00708         ( wmove((win),(y),(x)) == OK \
00709           ? wprintw((win),(fmt), ## __VA_ARGS__) : ERR )
00710 
00711 static inline int mvwvline ( WINDOW *win, int y, int x, chtype ch, int n ) {
00712         return ( wmove ( win, y, x ) == OK
00713                  ? wvline ( win, ch, n ) : ERR );
00714 }
00715 
00716 #define printw( fmt, ... ) wprintw(stdscr,(fmt), ## __VA_ARGS__ )
00717 
00718 static inline int slk_refresh ( void ) {
00719         if ( slk_clear() == OK )
00720                 return slk_restore();
00721         else
00722                 return ERR;
00723 }
00724 
00725 #define standend() wstandend( stdscr )
00726 #define standout() wstandout( stdscr )
00727 
00728 static inline int start_colour ( void ) {
00729         return OK;
00730 }
00731 
00732 static inline int vline ( chtype ch, int n ) {
00733         return wvline ( stdscr, ch, n );
00734 }
00735 
00736 // marked for removal
00737 static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
00738         return vw_printw ( win, fmt, varglist );
00739 }
00740 
00741 static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
00742         return waddchnstr ( win, chstr, -1 );
00743 }
00744 
00745 static inline int waddstr ( WINDOW *win, const char *str ) {
00746         return waddnstr ( win, str, -1 );
00747 }
00748 
00749 static inline int wbkgdset ( WINDOW *win, chtype ch ) {
00750         return wattrset( win, ch );
00751 }
00752 
00753 static inline int wgetstr ( WINDOW *win, char *str ) {
00754         return wgetnstr ( win, str, -1 );
00755 }
00756 
00757 static inline int wstandend ( WINDOW *win ) {
00758         return wattrset ( win, A_DEFAULT );
00759 }
00760 
00761 static inline int wstandout ( WINDOW *win ) {
00762         return wattrset ( win, A_STANDOUT );
00763 }
00764 
00765 #endif /* CURSES_H */