00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00061 #ifndef _CURSWA_H
00062 #define _CURSWA_H
00063
00064 #ifdef HAVE_CONFIG_H
00065 # include <config.h>
00066 #endif
00067
00068
00069 enum {
00070 #ifdef KEY_REFRESH
00071 #undef KEY_REFRESH
00072
00076 KEY_REFRESH = 12,
00077 #endif // KEY_REFRESH
00078 #ifndef KEY_ESC
00079
00082 KEY_ESC = 27,
00083 #endif // KEY_ESC
00084 #ifndef KEY_TAB
00085
00088 KEY_TAB = '\t',
00089 #endif // KEY_TAB
00090 #ifndef KEY_SPACE
00091
00094 KEY_SPACE = ' ',
00095 #endif // KEY_SPACE
00096
00097
00098 KEY_CTRL_E = 5
00099 };
00100
00106 inline void
00107 visibleCursor (bool v) {
00108 if (v) {
00109 int err = curs_set (2);
00110
00111 if (err == ERR) curs_set (1);
00112 } else {
00113 curs_set (0);
00114 }
00115 }
00116
00117
00118 #ifdef HAVE_CURSES_H
00119
00120 #if defined(tab) && defined(_XOPEN_CURSES)
00121 #undef tab
00122 #endif
00123
00124 #ifdef box
00125 #undef box
00126 inline int box (WINDOW* win, int verch, int horch) {
00127 return wborder (win, verch, verch, horch, horch, 0, 0, 0, 0);
00128 }
00129 #endif
00130
00131 #ifdef clear
00132 #undef clear
00133 inline int clear() {
00134 return wclear (stdscr);
00135 }
00136 #endif
00137
00138 #ifdef erase
00139 #undef erase
00140 inline int erase() {
00141 return werase (stdscr);
00142 }
00143 #endif
00144
00145 #ifdef move
00146 #undef move
00147 inline int move (int y, int x) {
00148 return wmove (stdscr, y, x);
00149 }
00150 #endif
00151
00152 #ifdef refresh
00153 #undef refresh
00154 inline int refresh() {
00155 return wrefresh (stdscr);
00156 }
00157 #endif
00158
00159 #endif // HAVE_CURSES_H
00160
00161 #ifdef WADDSTR_USE_CHAR
00162 #ifdef HAVE_STDLIB_H
00163 # include <stdlib.h>
00164 #endif
00165 #ifdef HAVE_STRING_H
00166 # include <string.h>
00167 #endif
00168
00169 inline int waddstr_c (WINDOW* win, const char* str) {
00170 char* tmp_ptr = (char*) malloc (strlen (str) + 1);
00171 memcpy (tmp_ptr, str, strlen (str) + 1);
00172 int retval = waddstr (win, tmp_ptr);
00173 free (tmp_ptr);
00174 return retval;
00175 }
00176 #define mywaddstr(a,b) waddstr_c(a,b)
00177 #else // WADDSTR_USE_CHAR
00178 #define mywaddstr(a,b) waddstr(a,b)
00179 #endif // WADDSTR_USE_CHAR
00180
00181 #ifdef MVWADDSTR_USE_CHAR
00182 #ifdef HAVE_STDLIB_H
00183 # include <stdlib.h>
00184 #endif
00185 #ifdef HAVE_STRING_H
00186 # include <string.h>
00187 #endif
00188
00189 inline int mvwaddstr_c (WINDOW* win, int y, int x, const char* str) {
00190 char* tmp_ptr = (char*) malloc (strlen (str) + 1);
00191 memcpy (tmp_ptr, str, strlen (str) + 1);
00192 int retval = mvwaddstr (win, y, x, tmp_ptr);
00193 free (tmp_ptr);
00194 return retval;
00195 }
00196 #define mymvwaddstr(a,b,c,d) mvwaddstr_c(a,b,c,d)
00197 #else // MVWADDSTR_USE_CHAR
00198 #define mymvwaddstr(a,b,c,d) mvwaddstr(a,b,c,d)
00199 #endif // MVWADDSTR_USE_CHAR
00200
00201 #ifdef MVWADDNSTR_USE_CHAR
00202 #ifdef HAVE_STDLIB_H
00203 # include <stdlib.h>
00204 #endif
00205 #ifdef HAVE_STRING_H
00206 # include <string.h>
00207 #endif
00208
00209 inline int mvwaddnstr_c (WINDOW* win, int y, int x, const char* str, int n) {
00210 char* tmp_ptr = (char*) malloc (strlen (str) + 1);
00211 memcpy (tmp_ptr, str, strlen (str) + 1);
00212 int retval = mvwaddnstr (win, y, x, tmp_ptr, n);
00213 free (tmp_ptr);
00214 return retval;
00215 }
00216 #define mymvwaddnstr(a,b,c,d,e) mvwaddnstr_c(a,b,c,d,e)
00217 #else // MVWADDSTR_USE_CHAR
00218 #define mymvwaddnstr(a,b,c,d,e) mvwaddnstr(a,b,c,d,e)
00219 #endif // MVWADDSTR_USE_CHAR
00220
00221 #if !defined(HAVE_MVWCHGAT) || ( defined(_XOPEN_CURSES) && !defined(__NCURSES_H) )
00222
00223 #ifdef HAVE_ALLOCA_H
00224 # include <alloca.h>
00225 #endif
00226
00227 inline int _mvwchgat_ (WINDOW* w, int y, int x, int n, int attr, short color, const void*) {
00228 char* buff = (char*) alloca (n);
00229
00230 if (buff == NULL)
00231 return ERR;
00232
00233 int retval = mvwinnstr (w, y, x, buff, n);
00234
00235 if (retval == ERR)
00236 return retval;
00237
00238 retval = wattron (w, attr | COLOR_PAIR (color) );
00239
00240 if (retval == ERR)
00241 return retval;
00242
00243 retval = mymvwaddnstr (w, y, x, buff, n);
00244
00245 if (retval == ERR)
00246 return retval;
00247
00248 retval = wattroff (w, attr | COLOR_PAIR (color) );
00249
00250 if (retval == ERR)
00251 return retval;
00252
00253 return OK;
00254 }
00255
00256 #define mymvwchgat(a,b,c,d,e,f,g) _mvwchgat_(a,b,c,d,e,f,g)
00257 #else
00258 #define mymvwchgat(a,b,c,d,e,f,g) mvwchgat(a,b,c,d,e,f,g)
00259 #endif // HAVE_MVWCHGAT
00260
00261 #endif // _CURSWA_H