curses.h

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

Generated on Tue Apr 6 20:01:06 2010 for gPXE by  doxygen 1.5.7.1