22 #if defined(HAVE_NCURSES_H)
24 #elif defined(HAVE_NCURSES_CURSES_H)
25 # include <ncurses/curses.h>
26 #elif defined(HAVE_CURSES_COLR_CURSES_H)
27 # ifdef HAVE_STDARG_PROTOTYPES
32 # include <curses_colr/curses.h>
35 # if defined(__bsdi__) || defined(__NetBSD__) || defined(__APPLE__)
51 #ifdef HAVE_INIT_COLOR
56 #ifdef NCURSES_MOUSE_VERSION
60 #define NUM2CH NUM2CHR
61 #define CH2FIX CHR2FIX
67 static VALUE cMouseEvent;
86 #define GetWINDOW(obj, winp) do {\
87 if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)\
88 rb_raise(rb_eSecurityError, "Insecure: operation on untainted window");\
89 Data_Get_Struct((obj), struct windata, (winp));\
90 if ((winp)->window == 0) no_window();\
107 if (window ==
NULL) {
151 #define curses_stdscr curses_init_screen
216 #define curses_closed rb_f_notimplement
505 #define curses_ungetch rb_f_notimplement
623 int *ip = (
int *)arg;
653 #define GETSTR_BUF_SIZE 1024
658 char *rtn = (
char *)arg;
659 #if defined(HAVE_GETNSTR)
707 #if defined(HAVE_DELETELN) || defined(deleteln)
723 #if defined(HAVE_INSERTLN) || defined(insertln)
841 #ifdef HAVE_SETSCRREG
944 #if defined(HAVE_USE_DEFAULT_COLORS)
954 use_default_colors();
958 #define curses_use_default_colors rb_f_notimplement
961 #if defined(HAVE_TABSIZE)
975 #define curses_tabsize_set rb_f_notimplement
978 #if defined(HAVE_TABSIZE)
988 #define curses_tabsize_get rb_f_notimplement
991 #if defined(HAVE_ESCDELAY)
1004 #define curses_escdelay_set rb_f_notimplement
1007 #if defined(HAVE_ESCDELAY)
1018 #define curses_escdelay_get rb_f_notimplement
1039 #if defined(HAVE_RESIZETERM)
1057 curses_start_color(
VALUE obj)
1117 curses_has_colors(
VALUE obj)
1129 curses_can_change_color(
VALUE obj)
1135 #if defined(HAVE_COLORS)
1142 curses_colors(
VALUE obj)
1147 #define curses_colors rb_f_notimplement
1162 color_content(
NUM2INT(color),&r,&g,&b);
1167 #if defined(HAVE_COLOR_PAIRS)
1174 curses_color_pairs(
VALUE obj)
1179 #define curses_color_pairs rb_f_notimplement
1195 pair_content(
NUM2INT(pair),&f,&b);
1240 #define GetMOUSE(obj, data) do {\
1241 if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)\
1242 rb_raise(rb_eSecurityError, "Insecure: operation on untainted mouse");\
1243 Data_Get_Struct((obj), struct mousedata, (data));\
1244 if ((data)->mevent == 0) no_mevent();\
1248 curses_mousedata_free(
struct mousedata *mdata)
1251 xfree(mdata->mevent);
1264 curses_getmouse(
VALUE obj)
1266 struct mousedata *mdata;
1271 0,curses_mousedata_free,mdata);
1272 mdata->mevent = (MEVENT*)
xmalloc(
sizeof(MEVENT));
1273 return (getmouse(mdata->mevent) == OK) ? val :
Qnil;
1287 struct mousedata *mdata;
1290 GetMOUSE(mevent,mdata);
1291 return (ungetmouse(mdata->mevent) == OK) ?
Qtrue :
Qfalse;
1311 curses_mouseinterval(
VALUE obj,
VALUE interval)
1330 #define DEFINE_MOUSE_GET_MEMBER(func_name,mem) \
1331 static VALUE func_name (VALUE mouse) \
1333 struct mousedata *mdata; \
1334 GetMOUSE(mouse, mdata); \
1335 return (UINT2NUM(mdata->mevent -> mem)); \
1343 DEFINE_MOUSE_GET_MEMBER(curs_mouse_id,
id)
1349 DEFINE_MOUSE_GET_MEMBER(curs_mouse_x, x)
1355 DEFINE_MOUSE_GET_MEMBER(curs_mouse_y, y)
1361 DEFINE_MOUSE_GET_MEMBER(curs_mouse_z, z)
1368 DEFINE_MOUSE_GET_MEMBER(curs_mouse_bstate, bstate)
1369 #undef define_curs_mouse_member
1391 #define curses_timeout rb_f_notimplement
1394 #ifdef HAVE_DEF_PROG_MODE
1410 #define curses_def_prog_mode rb_f_notimplement
1413 #ifdef HAVE_RESET_PROG_MODE
1429 #define curses_reset_prog_mode rb_f_notimplement
1492 window = subwin(winp->
window, h, w, t, l);
1578 #ifdef HAVE_DOUPDATE
1579 wnoutrefresh(winp->
window);
1635 getyx(winp->
window, y, x);
1651 getyx(winp->
window, y, x);
1666 #if defined(getmaxy)
1668 #elif defined(getmaxyx)
1671 getmaxyx(winp->
window, y, x);
1690 #if defined(getmaxx)
1692 #elif defined(getmaxyx)
1695 getmaxyx(winp->
window, y, x);
1716 getbegyx(winp->
window, y, x);
1736 getbegyx(winp->
window, y, x);
1758 VALUE vert, hor, corn;
1766 int cur_x, cur_y, x, y;
1770 getyx(winp->
window, cur_y, cur_x);
1773 wmove(winp->
window, 0, 0);
1775 wmove(winp->
window, y, 0);
1777 wmove(winp->
window, y, x);
1779 wmove(winp->
window, 0, x);
1781 wmove(winp->
window, cur_y, cur_x);
1923 arg->
c = wgetch(arg->
win);
1964 #if defined(HAVE_WGETNSTR)
1967 wgetstr(arg->
win, arg->
rtn);
2015 #if defined(HAVE_WDELETELN) || defined(wdeleteln)
2033 #if defined(HAVE_WINSERTLN) || defined(winsertln)
2110 #ifdef HAVE_WSETSCRREG
2123 #if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET)
2195 #ifdef HAVE_WATTROFF
2265 #ifdef HAVE_WATTRSET
2287 #ifdef HAVE_WBKGDSET
2326 #ifdef HAVE_WGETBKGD
2347 #if defined(HAVE_WRESIZE)
2393 #if defined(__NetBSD__) && !defined(NCURSES_VERSION)
2403 #define window_keypad rb_f_notimplement
2423 #if defined(__NetBSD__) && !defined(NCURSES_VERSION)
2431 #define window_nodelay rb_f_notimplement
2434 #ifdef HAVE_WTIMEOUT
2455 #define window_timeout rb_f_notimplement
2588 curses_can_change_color, 0);
2649 #if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET)
2689 #define rb_curses_define_const(c) rb_define_const(mCurses,#c,UINT2NUM(c))
2919 #ifdef BUTTON1_PRESSED
2929 #ifdef BUTTON1_RELEASED
2939 #ifdef BUTTON1_CLICKED
2949 #ifdef BUTTON1_DOUBLE_CLICKED
2959 #ifdef BUTTON1_TRIPLE_CLICKED
2969 #ifdef BUTTON2_PRESSED
2979 #ifdef BUTTON2_RELEASED
2989 #ifdef BUTTON2_CLICKED
2999 #ifdef BUTTON2_DOUBLE_CLICKED
3009 #ifdef BUTTON2_TRIPLE_CLICKED
3019 #ifdef BUTTON3_PRESSED
3029 #ifdef BUTTON3_RELEASED
3039 #ifdef BUTTON3_CLICKED
3049 #ifdef BUTTON3_DOUBLE_CLICKED
3059 #ifdef BUTTON3_TRIPLE_CLICKED
3069 #ifdef BUTTON4_PRESSED
3079 #ifdef BUTTON4_RELEASED
3089 #ifdef BUTTON4_CLICKED
3099 #ifdef BUTTON4_DOUBLE_CLICKED
3109 #ifdef BUTTON4_TRIPLE_CLICKED
3149 #ifdef ALL_MOUSE_EVENTS
3159 #ifdef REPORT_MOUSE_POSITION
3171 #if defined(KEY_MOUSE) && defined(USE_MOUSE)
3251 #ifdef KEY_BACKSPACE
3266 for (i=0; i<64; i++) {
3267 sprintf(c,
"KEY_F%d", i);
3269 sprintf(c,
"F%d", i);
3714 #ifdef KEY_REFERENCE
3974 #ifdef KEY_SPREVIOUS
4106 char name[] =
"KEY_CTRL_x";
4107 for (c =
'A'; c <=
'Z'; c++) {
4108 name[
sizeof(
name) - 2] = c;
4112 #undef rb_curses_define_const