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 #ifdef KEY_REFRESH
00069 #undef KEY_REFRESH
00070 enum {
00075 KEY_REFRESH = 12
00076 };
00077 #endif // KEY_REFRESH
00078
00079
00080
00081 #ifdef HAVE_CURSES_H
00082
00083 #if defined(tab) && defined(_XOPEN_CURSES)
00084 #undef tab
00085 #endif
00086
00087 #ifdef box
00088 #undef box
00089 inline int box(WINDOW* win, int verch, int horch) {
00090 return wborder(win, verch, verch, horch, horch, 0, 0, 0, 0);
00091 }
00092 #endif
00093
00094 #ifdef clear
00095 #undef clear
00096 inline int clear() {
00097 return wclear(stdscr);
00098 }
00099 #endif
00100
00101 #ifdef erase
00102 #undef erase
00103 inline int erase() {
00104 return werase(stdscr);
00105 }
00106 #endif
00107
00108 #ifdef move
00109 #undef move
00110 inline int move(int y, int x) {
00111 return wmove(stdscr, y, x);
00112 }
00113 #endif
00114
00115 #ifdef refresh
00116 #undef refresh
00117 inline int refresh() {
00118 return wrefresh(stdscr);
00119 }
00120 #endif
00121
00122 #endif // HAVE_CURSES_H
00123
00124 #ifdef WADDSTR_USE_CHAR
00125 #ifdef HAVE_STDLIB_H
00126 # include <stdlib.h>
00127 #endif
00128 #ifdef HAVE_STRING_H
00129 # include <string.h>
00130 #endif
00131
00132 inline int waddstr_c(WINDOW* win, const char* str) {
00133 char* tmp_ptr = (char*)malloc(strlen(str)+1);
00134 memcpy(tmp_ptr, str, strlen(str)+1);
00135 int retval = waddstr(win, tmp_ptr);
00136 free(tmp_ptr);
00137 return retval;
00138 }
00139 #define mywaddstr(a,b) waddstr_c(a,b)
00140 #else // WADDSTR_USE_CHAR
00141 #define mywaddstr(a,b) waddstr(a,b)
00142 #endif // WADDSTR_USE_CHAR
00143
00144 #ifdef MVWADDSTR_USE_CHAR
00145 #ifdef HAVE_STDLIB_H
00146 # include <stdlib.h>
00147 #endif
00148 #ifdef HAVE_STRING_H
00149 # include <string.h>
00150 #endif
00151
00152 inline int mvwaddstr_c(WINDOW* win, int y, int x, const char* str) {
00153 char* tmp_ptr = (char*)malloc(strlen(str)+1);
00154 memcpy(tmp_ptr, str, strlen(str)+1);
00155 int retval = mvwaddstr(win, y, x, tmp_ptr);
00156 free(tmp_ptr);
00157 return retval;
00158 }
00159 #define mymvwaddstr(a,b,c,d) mvwaddstr_c(a,b,c,d)
00160 #else // MVWADDSTR_USE_CHAR
00161 #define mymvwaddstr(a,b,c,d) mvwaddstr(a,b,c,d)
00162 #endif // MVWADDSTR_USE_CHAR
00163
00164 #ifdef MVWADDNSTR_USE_CHAR
00165 #ifdef HAVE_STDLIB_H
00166 # include <stdlib.h>
00167 #endif
00168 #ifdef HAVE_STRING_H
00169 # include <string.h>
00170 #endif
00171
00172 inline int mvwaddnstr_c(WINDOW* win, int y, int x, const char* str, int n) {
00173 char* tmp_ptr = (char*)malloc(strlen(str)+1);
00174 memcpy(tmp_ptr, str, strlen(str)+1);
00175 int retval = mvwaddnstr(win, y, x, tmp_ptr, n);
00176 free(tmp_ptr);
00177 return retval;
00178 }
00179 #define mymvwaddnstr(a,b,c,d,e) mvwaddnstr_c(a,b,c,d,e)
00180 #else // MVWADDSTR_USE_CHAR
00181 #define mymvwaddnstr(a,b,c,d,e) mvwaddnstr(a,b,c,d,e)
00182 #endif // MVWADDSTR_USE_CHAR
00183
00184 #if !defined(HAVE_MVWCHGAT) || ( defined(_XOPEN_CURSES) && !defined(__NCURSES_H) )
00185
00186 #ifdef HAVE_ALLOCA_H
00187 # include <alloca.h>
00188 #elif defined __GNUC__
00189 # define alloca __builtin_alloca
00190 #elif defined _AIX
00191 # define alloca __alloca
00192 #elif defined _MSC_VER
00193 # include <malloc.h>
00194 # define alloca _alloca
00195 #else
00196 # include <stddef.h>
00197 # ifdef __cplusplus
00198 extern "C"
00199 # endif
00200 void *alloca (size_t);
00201 #endif
00202
00203 inline int _mvwchgat_(WINDOW* w, int y, int x, int n, int attr, short color, const void*) {
00204 char* buff = (char*)alloca(n);
00205 if (buff == NULL)
00206 return ERR;
00207 int retval = mvwinnstr(w, y, x, buff, n);
00208 if (retval == ERR)
00209 return retval;
00210 retval = wattron(w, attr | COLOR_PAIR(color));
00211 if (retval == ERR)
00212 return retval;
00213 retval = mymvwaddnstr(w, y, x, buff, n);
00214 if (retval == ERR)
00215 return retval;
00216 retval = wattroff(w, attr | COLOR_PAIR(color));
00217 if (retval == ERR)
00218 return retval;
00219
00220 return OK;
00221 }
00222
00223 #define mymvwchgat(a,b,c,d,e,f,g) _mvwchgat_(a,b,c,d,e,f,g)
00224 #else
00225 #define mymvwchgat(a,b,c,d,e,f,g) mvwchgat(a,b,c,d,e,f,g)
00226 #endif // HAVE_MVWCHGAT
00227
00228 #endif // _CURSWA_H