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