1 /* retawq/cursesx.h - a small xcurses implementation
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_cursesx_h__
10 #define __retawq_cursesx_h__
11 
12 #include <X11/keysym.h>
13 
14 #ifndef FALSE
15 #define FALSE (0)
16 #endif
17 #ifndef TRUE
18 #define TRUE (1)
19 #endif
20 
21 #if 1 /* MIGHT_USE_COLORS */
22 #define COLOR_PAIRS (8) /* (enough for us; must be a power of 2 here) */
23 #endif
24 
25 typedef unsigned long chtype;
26 typedef chtype attr_t;
27 
28 typedef struct
29 { chtype* text;
30   attr_t* attr;
31   int x, y; /* classical clarification: current cursor coordinates :-) */
32 } WINDOW;
33 
34 #define _curx x
35 #define _cury y
36 
37 #define OK (0)
38 #define ERR (-1)
39 
40 #define KEY_TAB (XK_Tab)
41 #define KEY_ESCAPE (XK_Escape)
42 #define KEY_CANCEL (XK_Cancel)
43 #define KEY_LEFT (XK_Left)
44 #define KEY_RIGHT (XK_Right)
45 #define KEY_END (XK_End)
46 #define KEY_NPAGE (XK_Page_Down)
47 #define KEY_PPAGE (XK_Page_Up)
48 #define KEY_DOWN (XK_Down)
49 #define KEY_UP (XK_Up)
50 #define KEY_HOME (XK_Home)
51 #define KEY_ENTER (XK_Return)
52 #define KEY_BACKSPACE (XK_BackSpace)
53 #define KEY_DC (XK_Delete)
54 #define KEY_IC (XK_Insert)
55 #define KEY_F(x) (XK_F1 + (x) - 1)
56 #define KEY_MOUSE 0631 /* CHECKME! */
57 #define KEY_RESIZE 0632 /* CHECKME! */
58 
59 #define A_REVERSE (1 << 8)
60 #define A_BOLD (1 << 9)
61 #define A_UNDERLINE (1 << 10)
62 #define A_ALTCHARSET (1 << 11)
63 #if MIGHT_USE_COLORS
64 #define __A_COLORMARK (1 << 12)
65 #define __A_COLORPAIRSHIFT (13)
66 #define __A_COLORPAIRMASK ( (COLOR_PAIRS - 1) << __A_COLORPAIRSHIFT )
67 #endif
68 
69 #define ACS_HLINE    ((chtype) (A_ALTCHARSET | 'A'))
70 #define ACS_VLINE    ((chtype) (A_ALTCHARSET | 'B'))
71 #define ACS_ULCORNER ((chtype) (A_ALTCHARSET | 'C'))
72 #define ACS_URCORNER ((chtype) (A_ALTCHARSET | 'D'))
73 #define ACS_LLCORNER ((chtype) (A_ALTCHARSET | 'E'))
74 #define ACS_LRCORNER ((chtype) (A_ALTCHARSET | 'F'))
75 #if 0 /* not (yet?) needed */
76 #define ACS_LTEE     ((chtype) (A_ALTCHARSET | 'G'))
77 #define ACS_RTEE     ((chtype) (A_ALTCHARSET | 'H'))
78 #endif
79 
80 #define BUTTON1_CLICKED (0x01)
81 #define BUTTON2_CLICKED (0x02)
82 #define BUTTON3_CLICKED (0x04)
83 typedef unsigned char mmask_t;
84 
85 typedef struct
86 { int x, y;
87   mmask_t bstate;
88 } MEVENT;
89 
90 extern WINDOW* stdscr;
91 extern int COLS, LINES;
92 
93 extern void xcurses_confuser(unsigned char, void*, void*); /* cf. main.c */
94 
95 extern WINDOW* initscr(void);
96 
97 extern int addch(chtype);
98 extern int addstr(const char*);
99 extern int addnstr(const char*, int);
100 extern int attron(attr_t);
101 extern int attroff(attr_t);
102 extern int clrtoeol(void);
103 extern int getch(void);
104 extern int getmouse(MEVENT*);
105 #if MIGHT_USE_COLORS
106 extern int has_colors(void);
107 #endif
108 extern chtype inch(void);
109 #if MIGHT_USE_COLORS
110 extern int init_pair(short, short, short);
111 #endif
112 extern mmask_t mousemask(mmask_t, mmask_t*);
113 extern int move(int, int);
114 extern int mvaddch(int, int, chtype);
115 extern int mvaddnstr(int, int, const char*, int);
116 extern int refresh(void);
117 
118 #if MIGHT_USE_COLORS
119 #define COLOR_PAIR(cpn) \
120   ( (__A_COLORMARK) | (((attr_t) (cpn)) << __A_COLORPAIRSHIFT) )
121 #endif
122 
123 /* lots-o-stubs */
124 
cbreak(void)125 static __my_inline int cbreak(void) { return(OK); }
clear(void)126 static __my_inline int clear(void) { return(OK); } /* IMPLEMENTME? */
endwin(void)127 static __my_inline int endwin(void) { return(OK); } /* IMPLEMENTME? */
noecho(void)128 static __my_inline int noecho(void) { return(OK); }
nonl(void)129 static __my_inline int nonl(void) { return(OK); }
130 
131 #if MIGHT_USE_COLORS
start_color(void)132 static __my_inline int start_color(void) { return(OK); }
133 #define bkgdset(ch) do { } while (0) /* IMPLEMENTME? */
134 #endif
135 
136 #define intrflush(a, b) (0)
137 #define keypad(a, b) (0)
138 #define nodelay(a, b) (0)
139 #define resizeterm(a, b) (0)
140 
141 #endif /* #ifndef __retawq_cursesx_h__ */
142