1 /* retawq/cursesbi.h - a small built-in curses library emulation
2    This file is part of retawq (<http://retawq.sourceforge.net/>), a network
3    client created by Arne Thomassen; retawq is basically released under certain
4    versions of the GNU General Public License and WITHOUT ANY WARRANTY.
5    Read the file COPYING for license details, README for program information.
6    Copyright (C) 2004-2006 Arne Thomassen <arne@arne-thomassen.de>
7 */
8 
9 #ifndef __retawq_cursesbi_h__
10 #define __retawq_cursesbi_h__
11 
12 #ifndef FALSE
13 #define FALSE (0)
14 #endif
15 #ifndef TRUE
16 #define TRUE (1)
17 #endif
18 
19 #define OK (0)
20 #define ERR (-1)
21 
22 typedef unsigned long chtype;
23 typedef chtype attr_t;
24 
25 #define A_REVERSE (1 << 8)
26 #define A_BOLD (1 << 9)
27 #define A_UNDERLINE (1 << 10)
28 #if MIGHT_USE_COLORS
29 #define __A_COLORMARK (1 << 11)
30 #define __A_COLORPAIRSHIFT (12)
31 #define __A_COLORPAIRMASK ( (COLOR_PAIRS - 1) << __A_COLORPAIRSHIFT )
32 #endif
33 
34 typedef struct
35 { chtype* text;
36   attr_t* attr;
37   unsigned char* dirty_lines; /* bitfield */
38   size_t dirty_lines_size;
39   int x, y;
40   tBoolean update_cursor;
41 } WINDOW;
42 
43 #define _curx x
44 #define _cury y
45 
46 typedef unsigned char mmask_t;
47 
48 typedef struct
49 { int x, y;
50   mmask_t bstate;
51 } MEVENT;
52 
53 extern WINDOW* stdscr;
54 extern int COLS, LINES;
55 
56 #define KEY_DOWN 0402
57 #define KEY_UP 0403
58 #define KEY_LEFT 0404
59 #define KEY_RIGHT 0405
60 #define KEY_HOME 0406
61 #define KEY_BACKSPACE 0407
62 /* #define KEY_F0 0410 */
63 /* #define KEY_F(x) (KEY_F0 + (x)) */
64 #define KEY_DC 0512
65 #define KEY_IC 0513
66 #define KEY_NPAGE 0522
67 #define KEY_PPAGE 0523
68 #define KEY_ENTER 0527
69 #define KEY_CANCEL 0543
70 #define KEY_END 0550
71 #define KEY_MOUSE 0631 /* CHECKME! */
72 #define KEY_RESIZE 0632 /* CHECKME! */
73 
74 extern WINDOW* initscr(void);
75 
76 extern int addch(chtype);
77 extern int addstr(const char*);
78 extern int addnstr(const char*, int);
79 extern int attron(attr_t);
80 extern int attroff(attr_t);
81 extern int clear(void);
82 extern int clrtoeol(void);
83 extern int endwin(void);
84 extern int getmouse(MEVENT*);
85 extern chtype inch(void);
86 extern mmask_t mousemask(mmask_t, mmask_t*);
87 extern int move(int, int);
88 extern int mvaddch(int, int, chtype);
89 extern int mvaddnstr(int, int, const char*, int);
90 extern int resizeterm(int, int);
91 #if MIGHT_USE_COLORS
92 extern int start_color(void);
93 #endif
94 
95 extern int my_builtin_getch(tBoolean);
96 extern int getch(void);
97 
98 extern int refresh(void);
99 
100 /* colors stubs - IMPLEMENTME! */
101 
102 #if MIGHT_USE_COLORS
103 #define COLOR_PAIRS (0)
104 #define COLOR_PAIR(cpn) (0)
has_colors(void)105 static __my_inline int has_colors(void) { return(FALSE); }
106 #define bkgdset(ch) do { } while (0)
107 #define init_pair(a, b, c) (ERR)
108 #endif
109 
110 /* lots-o-stubs */
111 
cbreak(void)112 static __my_inline int cbreak(void) { return(OK); }
noecho(void)113 static __my_inline int noecho(void) { return(OK); }
nonl(void)114 static __my_inline int nonl(void) { return(OK); }
115 
116 #define intrflush(a, b) (0)
117 #define keypad(a, b) (0)
118 #define nodelay(a, b) (0)
119 
120 #endif /* #ifndef __retawq_cursesbi_h__ */
121