source: bootcd/isolinux/syslinux-6.03/gpxe/src/include/curses.h @ dd1be7c

Last change on this file since dd1be7c was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

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