ncurses-ruby 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +515 -0
- data/Changes +53 -0
- data/README +351 -0
- data/THANKS +15 -0
- data/TODO +15 -0
- data/examples/LICENSES_for_examples +26 -0
- data/examples/example.rb +129 -0
- data/examples/form.rb +82 -0
- data/examples/form2.rb +184 -0
- data/examples/hello_ncurses.rb +57 -0
- data/examples/rain.rb +219 -0
- data/examples/read_line.rb +67 -0
- data/examples/tclock.rb +227 -0
- data/examples/test_scanw.rb +27 -0
- data/ext/ncurses/extconf.rb +139 -0
- data/ext/ncurses/form_wrap.c +1450 -0
- data/ext/ncurses/form_wrap.h +61 -0
- data/ext/ncurses/menu_wrap.c +1141 -0
- data/ext/ncurses/menu_wrap.h +49 -0
- data/ext/ncurses/ncurses_wrap.c +2739 -0
- data/ext/ncurses/ncurses_wrap.h +100 -0
- data/ext/ncurses/panel_wrap.c +256 -0
- data/ext/ncurses/panel_wrap.h +32 -0
- data/lib/ncurses-ruby/version.rb +5 -0
- data/lib/ncurses.rb +344 -0
- metadata +96 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
/*
|
2
|
+
* This is a curses menu wrapper as part of ncurses-ruby.
|
3
|
+
* It borrows heavily from form_wrap.h.
|
4
|
+
* Contributed by Earle Clubb <eclubb@valcom.com>
|
5
|
+
* Valcom Inc. <http://www.valcom.com>
|
6
|
+
* Copyright 2007
|
7
|
+
*
|
8
|
+
* This module is free software; you can redistribute it and/or
|
9
|
+
* modify it under the terms of the GNU Lesser General Public
|
10
|
+
* License as published by the Free Software Foundation; either
|
11
|
+
* version 2 of the License, or (at your option) any later version.
|
12
|
+
*
|
13
|
+
* This module is distributed in the hope that it will be useful,
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16
|
+
* Lesser General Public License for more details.
|
17
|
+
*
|
18
|
+
* You should have received a copy of the GNU Lesser General Public
|
19
|
+
* License along with this module; if not, write to the Free Software
|
20
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
21
|
+
*
|
22
|
+
*/
|
23
|
+
|
24
|
+
#if !defined(MENU_HH) && defined(HAVE_MENU_H)
|
25
|
+
#define MENU_HH
|
26
|
+
|
27
|
+
#include <menu.h>
|
28
|
+
#include <ruby.h>
|
29
|
+
|
30
|
+
extern VALUE mMenu;
|
31
|
+
extern VALUE cITEM;
|
32
|
+
extern VALUE cMENU;
|
33
|
+
|
34
|
+
#define MENU_DEF_CONST(name) \
|
35
|
+
rb_define_const(mMenu, #name, INT2NUM(name));
|
36
|
+
|
37
|
+
#define MENU_SNG_FUNC(name, nargs) \
|
38
|
+
rb_define_singleton_method(mMenu, #name, &rbncurs_m_ ## name, nargs)
|
39
|
+
|
40
|
+
#define RB_CLASS_METH(class, alt_name, name, nargs) \
|
41
|
+
rb_define_method(class, #name, (&rbncurs_c_ ## name), nargs); \
|
42
|
+
if (alt_name != NULL) \
|
43
|
+
rb_define_method(class, alt_name, (&rbncurs_c_ ## name), nargs); \
|
44
|
+
|
45
|
+
//void init_menu_req_constants(void);
|
46
|
+
//void init_menu_opts_constants(void);
|
47
|
+
void init_menu(void);
|
48
|
+
|
49
|
+
#endif
|
@@ -0,0 +1,2739 @@
|
|
1
|
+
/*
|
2
|
+
* ncurses-ruby is a ruby module for accessing the FSF's ncurses library
|
3
|
+
* (C) 2002, 2003, 2004 Tobias Peters <t-peters@berlios.de>
|
4
|
+
* (C) 2004 Simon Kaczor <skaczor@cox.net>
|
5
|
+
* (C) 2005 2006 Tobias Herzke
|
6
|
+
*
|
7
|
+
* This module is free software; you can redistribute it and/or
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
9
|
+
* License as published by the Free Software Foundation; either
|
10
|
+
* version 2 of the License, or (at your option) any later version.
|
11
|
+
*
|
12
|
+
* This module is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
* Lesser General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public
|
18
|
+
* License along with this module; if not, write to the Free Software
|
19
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20
|
+
*
|
21
|
+
* $Id: ncurses_wrap.c,v 1.13 2006/06/19 09:46:59 t-peters Exp $
|
22
|
+
*
|
23
|
+
* This file was adapted from the original ncurses header file which
|
24
|
+
* has the following copyright statements:
|
25
|
+
*/
|
26
|
+
|
27
|
+
/****************************************************************************
|
28
|
+
* Copyright (c) 1998 Free Software Foundation, Inc. *
|
29
|
+
* *
|
30
|
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
31
|
+
* copy of this software and associated documentation files (the *
|
32
|
+
* "Software"), to deal in the Software without restriction, including *
|
33
|
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
34
|
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
35
|
+
* copies of the Software, and to permit persons to whom the Software is *
|
36
|
+
* furnished to do so, subject to the following conditions: *
|
37
|
+
* *
|
38
|
+
* The above copyright notice and this permission notice shall be included *
|
39
|
+
* in all copies or substantial portions of the Software. *
|
40
|
+
* *
|
41
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
42
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
43
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
44
|
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
45
|
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
46
|
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
47
|
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
48
|
+
* *
|
49
|
+
* Except as contained in this notice, the name(s) of the above copyright *
|
50
|
+
* holders shall not be used in advertising or otherwise to promote the *
|
51
|
+
* sale, use or other dealings in this Software without prior written *
|
52
|
+
* authorization. *
|
53
|
+
****************************************************************************/
|
54
|
+
|
55
|
+
/****************************************************************************
|
56
|
+
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
|
57
|
+
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
58
|
+
****************************************************************************/
|
59
|
+
|
60
|
+
/*
|
61
|
+
NOT IMPLEMENTED:
|
62
|
+
- terminfo, termcap-functions
|
63
|
+
- rippoffline
|
64
|
+
- v*printw functions (but normal printw functions are supported!)
|
65
|
+
*/
|
66
|
+
|
67
|
+
#include "ncurses_wrap.h"
|
68
|
+
|
69
|
+
VALUE mNcurses; /* module Ncurses */
|
70
|
+
VALUE cWINDOW; /* class Ncurses::WINDOW */
|
71
|
+
VALUE cSCREEN; /* class Ncurses::SCREEN */
|
72
|
+
VALUE eNcurses; /* Ncurses::Exception thrown by this extension */
|
73
|
+
|
74
|
+
static void Init_ncurses_full(void);
|
75
|
+
|
76
|
+
static
|
77
|
+
void
|
78
|
+
init_constants_1(void)
|
79
|
+
{
|
80
|
+
#ifdef CURSES
|
81
|
+
rb_define_const(mNcurses, "CURSES", INT2NUM((int)(CURSES)));
|
82
|
+
#endif
|
83
|
+
#ifdef CURSES_H
|
84
|
+
rb_define_const(mNcurses, "CURSES_H", INT2NUM((int)(CURSES_H)));
|
85
|
+
#endif
|
86
|
+
#ifdef NCURSES_VERSION_MAJOR
|
87
|
+
rb_define_const(mNcurses, "NCURSES_VERSION_MAJOR",
|
88
|
+
INT2NUM((int)(NCURSES_VERSION_MAJOR)));
|
89
|
+
#endif
|
90
|
+
#ifdef NCURSES_VERSION_MINOR
|
91
|
+
rb_define_const(mNcurses, "NCURSES_VERSION_MINOR",
|
92
|
+
INT2NUM((int)(NCURSES_VERSION_MINOR)));
|
93
|
+
#endif
|
94
|
+
#ifdef NCURSES_VERSION_PATCH
|
95
|
+
rb_define_const(mNcurses, "NCURSES_VERSION_PATCH",
|
96
|
+
INT2NUM((int)(NCURSES_VERSION_PATCH)));
|
97
|
+
#endif
|
98
|
+
#ifdef NCURSES_VERSION
|
99
|
+
rb_define_const(mNcurses, "NCURSES_VERSION",
|
100
|
+
rb_str_new2(NCURSES_VERSION));
|
101
|
+
#endif
|
102
|
+
|
103
|
+
/* attributes */
|
104
|
+
#ifdef WA_ATTRIBUTES
|
105
|
+
rb_define_const(mNcurses, "WA_ATTRIBUTES", INT2NUM(WA_ATTRIBUTES));
|
106
|
+
rb_define_const(mNcurses, "WA_NORMAL", INT2NUM(WA_NORMAL));
|
107
|
+
rb_define_const(mNcurses, "WA_STANDOUT", INT2NUM(WA_STANDOUT));
|
108
|
+
rb_define_const(mNcurses, "WA_UNDERLINE", INT2NUM(WA_UNDERLINE));
|
109
|
+
rb_define_const(mNcurses, "WA_REVERSE", INT2NUM(WA_REVERSE));
|
110
|
+
rb_define_const(mNcurses, "WA_BLINK", INT2NUM(WA_BLINK));
|
111
|
+
rb_define_const(mNcurses, "WA_DIM", INT2NUM(WA_DIM));
|
112
|
+
rb_define_const(mNcurses, "WA_BOLD", INT2NUM(WA_BOLD));
|
113
|
+
rb_define_const(mNcurses, "WA_ALTCHARSET", INT2NUM(WA_ALTCHARSET));
|
114
|
+
rb_define_const(mNcurses, "WA_INVIS", INT2NUM(WA_INVIS));
|
115
|
+
rb_define_const(mNcurses, "WA_PROTECT", INT2NUM(WA_PROTECT));
|
116
|
+
rb_define_const(mNcurses, "WA_HORIZONTAL", INT2NUM(WA_HORIZONTAL));
|
117
|
+
rb_define_const(mNcurses, "WA_LEFT", INT2NUM(WA_LEFT));
|
118
|
+
rb_define_const(mNcurses, "WA_LOW", INT2NUM(WA_LOW));
|
119
|
+
rb_define_const(mNcurses, "WA_RIGHT", INT2NUM(WA_RIGHT));
|
120
|
+
rb_define_const(mNcurses, "WA_TOP", INT2NUM(WA_TOP));
|
121
|
+
rb_define_const(mNcurses, "WA_VERTICAL", INT2NUM(WA_VERTICAL));
|
122
|
+
#endif
|
123
|
+
}
|
124
|
+
|
125
|
+
static VALUE rbncurs_COLORS()
|
126
|
+
{return INT2NUM(COLORS);}
|
127
|
+
static VALUE rbncurs_COLOR_PAIRS()
|
128
|
+
{return INT2NUM(COLOR_PAIRS);}
|
129
|
+
|
130
|
+
static
|
131
|
+
void
|
132
|
+
init_globals_1(void)
|
133
|
+
{
|
134
|
+
/* colors */
|
135
|
+
NCFUNC(COLORS, 0);
|
136
|
+
NCFUNC(COLOR_PAIRS, 0);
|
137
|
+
}
|
138
|
+
static
|
139
|
+
void
|
140
|
+
init_constants_2(void)
|
141
|
+
{
|
142
|
+
rb_define_const(mNcurses, "COLOR_BLACK", INT2NUM(COLOR_BLACK));
|
143
|
+
rb_define_const(mNcurses, "COLOR_RED", INT2NUM(COLOR_RED));
|
144
|
+
rb_define_const(mNcurses, "COLOR_GREEN", INT2NUM(COLOR_GREEN));
|
145
|
+
rb_define_const(mNcurses, "COLOR_YELLOW", INT2NUM(COLOR_YELLOW));
|
146
|
+
rb_define_const(mNcurses, "COLOR_BLUE", INT2NUM(COLOR_BLUE));
|
147
|
+
rb_define_const(mNcurses, "COLOR_MAGENTA", INT2NUM(COLOR_MAGENTA));
|
148
|
+
rb_define_const(mNcurses, "COLOR_CYAN", INT2NUM(COLOR_CYAN));
|
149
|
+
rb_define_const(mNcurses, "COLOR_WHITE", INT2NUM(COLOR_WHITE));
|
150
|
+
|
151
|
+
rb_define_const(mNcurses, "ERR", INT2NUM(ERR));
|
152
|
+
rb_define_const(mNcurses, "OK", INT2NUM(OK));
|
153
|
+
|
154
|
+
/* values for the _flags member */
|
155
|
+
#ifdef _SUBWIN
|
156
|
+
rb_define_const(mNcurses, "SUBWIN", INT2NUM(_SUBWIN));
|
157
|
+
#endif
|
158
|
+
#ifdef _ENDLINE
|
159
|
+
rb_define_const(mNcurses, "ENDLINE", INT2NUM(_ENDLINE));
|
160
|
+
#endif
|
161
|
+
#ifdef _FULLWIN
|
162
|
+
rb_define_const(mNcurses, "FULLWIN", INT2NUM(_FULLWIN));
|
163
|
+
#endif
|
164
|
+
#ifdef _SCROLLWIN
|
165
|
+
rb_define_const(mNcurses, "SCROLLWIN", INT2NUM(_SCROLLWIN));
|
166
|
+
#endif
|
167
|
+
#ifdef _ISPAD
|
168
|
+
rb_define_const(mNcurses, "ISPAD", INT2NUM(_ISPAD));
|
169
|
+
#endif
|
170
|
+
#ifdef _HASMOVED
|
171
|
+
rb_define_const(mNcurses, "HASMOVED", INT2NUM(_HASMOVED));
|
172
|
+
#endif
|
173
|
+
#ifdef _WRAPPED
|
174
|
+
rb_define_const(mNcurses, "WRAPPED", INT2NUM(_WRAPPED));
|
175
|
+
#endif
|
176
|
+
|
177
|
+
#ifdef _NOCHANGE
|
178
|
+
/*
|
179
|
+
* this value is used in the firstchar and lastchar fields to mark
|
180
|
+
* unchanged lines
|
181
|
+
*/
|
182
|
+
rb_define_const(mNcurses, "NOCHANGE", INT2NUM(_NOCHANGE));
|
183
|
+
#endif
|
184
|
+
#ifdef _NEWINDEX
|
185
|
+
/*
|
186
|
+
* this value is used in the oldindex field to mark lines created by
|
187
|
+
* insertions and scrolls.
|
188
|
+
*/
|
189
|
+
rb_define_const(mNcurses, "NEWINDEX", INT2NUM(_NEWINDEX));
|
190
|
+
#endif
|
191
|
+
#ifdef CCHARW_MAX
|
192
|
+
rb_define_const(mNcurses, "CCHARW_MAX", INT2NUM(CCHARW_MAX));
|
193
|
+
#endif
|
194
|
+
}
|
195
|
+
|
196
|
+
VALUE wrap_window(WINDOW* window)
|
197
|
+
{
|
198
|
+
if (window == 0) return Qnil;
|
199
|
+
{
|
200
|
+
VALUE windows_hash = rb_iv_get(mNcurses, "@windows_hash");
|
201
|
+
VALUE window_adress = INT2NUM((long)(window));
|
202
|
+
VALUE rb_window = rb_hash_aref(windows_hash, window_adress);
|
203
|
+
if (rb_window == Qnil) {
|
204
|
+
rb_window = Data_Wrap_Struct(cWINDOW, 0, 0, window);
|
205
|
+
rb_iv_set(rb_window, "@destroyed", Qfalse);
|
206
|
+
rb_hash_aset(windows_hash, window_adress, rb_window);
|
207
|
+
}
|
208
|
+
return rb_window;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
WINDOW* get_window(VALUE rb_window)
|
212
|
+
{
|
213
|
+
WINDOW* window;
|
214
|
+
if (rb_window == Qnil) return 0;
|
215
|
+
if (rb_iv_get(rb_window, "@destroyed") == Qtrue) {
|
216
|
+
rb_raise(eNcurses, "Attempt to access a destroyed window");
|
217
|
+
return 0;
|
218
|
+
}
|
219
|
+
Data_Get_Struct(rb_window, WINDOW, window);
|
220
|
+
return window;
|
221
|
+
}
|
222
|
+
static VALUE rbncurs_delwin(VALUE dummy, VALUE arg1) {
|
223
|
+
VALUE windows_hash = rb_iv_get(mNcurses, "@windows_hash");
|
224
|
+
WINDOW* window = get_window(arg1);
|
225
|
+
VALUE window_adress = INT2NUM((long)(window));
|
226
|
+
rb_funcall(windows_hash, rb_intern("delete"), 1, window_adress);
|
227
|
+
rb_iv_set(arg1, "@destroyed", Qtrue);
|
228
|
+
return INT2NUM(delwin(window));
|
229
|
+
}
|
230
|
+
|
231
|
+
static VALUE wrap_screen(SCREEN* screen)
|
232
|
+
{
|
233
|
+
if (screen == 0) return Qnil;
|
234
|
+
{
|
235
|
+
VALUE screens_hash = rb_iv_get(mNcurses, "@screens_hash");
|
236
|
+
VALUE screen_adress = INT2NUM((long)(screen));
|
237
|
+
VALUE rb_screen = rb_hash_aref(screens_hash, screen_adress);
|
238
|
+
if (rb_screen == Qnil) {
|
239
|
+
rb_screen = Data_Wrap_Struct(cSCREEN, 0, 0, screen);
|
240
|
+
rb_iv_set(rb_screen, "@destroyed", Qfalse);
|
241
|
+
rb_hash_aset(screens_hash, screen_adress, rb_screen);
|
242
|
+
}
|
243
|
+
return rb_screen;
|
244
|
+
}
|
245
|
+
}
|
246
|
+
static SCREEN* get_screen(VALUE rb_screen)
|
247
|
+
{
|
248
|
+
SCREEN* screen;
|
249
|
+
if (rb_screen == Qnil) return 0;
|
250
|
+
if (rb_iv_get(rb_screen, "@destroyed") == Qtrue) {
|
251
|
+
rb_raise(eNcurses, "Attempt to access a destroyed screen");
|
252
|
+
return 0;
|
253
|
+
}
|
254
|
+
Data_Get_Struct(rb_screen, SCREEN, screen);
|
255
|
+
return screen;
|
256
|
+
}
|
257
|
+
#ifdef HAVE_DELSCREEN
|
258
|
+
static VALUE rbncurs_delscreen(VALUE dummy, VALUE arg1) {
|
259
|
+
VALUE screens_hash = rb_iv_get(mNcurses, "@screens_hash");
|
260
|
+
SCREEN* screen = get_screen(arg1);
|
261
|
+
VALUE screen_adress = INT2NUM((long)(screen));
|
262
|
+
rb_funcall(screens_hash, rb_intern("delete"), 1, screen_adress);
|
263
|
+
rb_iv_set(arg1, "@destroyed", Qtrue);
|
264
|
+
delscreen(screen);
|
265
|
+
return Qnil;
|
266
|
+
}
|
267
|
+
#endif
|
268
|
+
static VALUE rbncurs_winchnstr(VALUE dummy, VALUE rb_win, VALUE rb_str, VALUE rb_n)
|
269
|
+
{
|
270
|
+
if (rb_obj_is_instance_of(rb_str, rb_cArray) != Qtrue) {
|
271
|
+
rb_raise(rb_eArgError, "2nd argument must be an empty Array");
|
272
|
+
return Qnil;
|
273
|
+
}
|
274
|
+
|
275
|
+
{
|
276
|
+
WINDOW * window = get_window(rb_win);
|
277
|
+
int n = NUM2INT(rb_n);
|
278
|
+
chtype * str = ALLOC_N(chtype, n + 1);
|
279
|
+
int return_value;
|
280
|
+
return_value = winchnstr(window, str, n);
|
281
|
+
if (return_value != ERR) {
|
282
|
+
int i;
|
283
|
+
for (i = 0; i < return_value; ++i) {
|
284
|
+
rb_ary_push(rb_str, INT2NUM(str[i]));
|
285
|
+
}
|
286
|
+
}
|
287
|
+
xfree(str);
|
288
|
+
return INT2NUM(return_value);
|
289
|
+
}
|
290
|
+
}
|
291
|
+
static VALUE rbncurs_wgetnstr(VALUE dummy, VALUE rb_win, VALUE rb_chstr, VALUE rb_n)
|
292
|
+
{
|
293
|
+
WINDOW * window = get_window(rb_win);
|
294
|
+
int n = NUM2INT(rb_n);
|
295
|
+
char * str = ALLOC_N(char, n + 1);
|
296
|
+
int return_value;
|
297
|
+
return_value = wgetnstr(window, str, n);
|
298
|
+
if (return_value != ERR) {
|
299
|
+
rb_str_cat2(rb_chstr, str);
|
300
|
+
}
|
301
|
+
xfree(str);
|
302
|
+
return INT2NUM(return_value);
|
303
|
+
}
|
304
|
+
static VALUE rbncurs_winnstr(VALUE dummy, VALUE rb_win, VALUE rb_chstr, VALUE rb_n)
|
305
|
+
{
|
306
|
+
WINDOW * window = get_window(rb_win);
|
307
|
+
int n = NUM2INT(rb_n);
|
308
|
+
char* str = ALLOC_N(char, n + 1);
|
309
|
+
int return_value;
|
310
|
+
return_value = winnstr(window, str, n);
|
311
|
+
if (return_value != ERR) {
|
312
|
+
rb_str_cat(rb_chstr, str, return_value);
|
313
|
+
}
|
314
|
+
xfree(str);
|
315
|
+
return INT2NUM(return_value);
|
316
|
+
}
|
317
|
+
|
318
|
+
#ifdef HAVE_PANEL_H
|
319
|
+
#include "panel_wrap.h" /* needs access to mNcurses, wrap_window, get_window */
|
320
|
+
#endif
|
321
|
+
|
322
|
+
#ifdef HAVE_FORM_H
|
323
|
+
#include "form_wrap.h" /* needs init_form */
|
324
|
+
#endif
|
325
|
+
|
326
|
+
#ifdef HAVE_MENU_H
|
327
|
+
#include "menu_wrap.h" /* needs init_menu */
|
328
|
+
#endif
|
329
|
+
|
330
|
+
static
|
331
|
+
void
|
332
|
+
init_functions_0(void)
|
333
|
+
{
|
334
|
+
#ifdef HAVE_DELSCREEN
|
335
|
+
NCFUNC(delscreen, 1);
|
336
|
+
#endif
|
337
|
+
NCFUNC(delwin, 1);
|
338
|
+
NCFUNC(winchnstr, 3);
|
339
|
+
NCFUNC(winnstr, 3);
|
340
|
+
NCFUNC(wgetnstr, 3);
|
341
|
+
}
|
342
|
+
|
343
|
+
static VALUE get_stdscr()
|
344
|
+
{
|
345
|
+
VALUE rb_stdscr = rb_iv_get(mNcurses, "@stdscr");
|
346
|
+
if (rb_stdscr == Qnil) {
|
347
|
+
rb_stdscr = wrap_window(stdscr);
|
348
|
+
rb_iv_set(mNcurses, "@stdscr", rb_stdscr);
|
349
|
+
}
|
350
|
+
return rb_stdscr;
|
351
|
+
}
|
352
|
+
static VALUE get_curscr()
|
353
|
+
{
|
354
|
+
VALUE rb_curscr = rb_iv_get(mNcurses, "@curscr");
|
355
|
+
if (rb_curscr == Qnil) {
|
356
|
+
rb_curscr = wrap_window(curscr);
|
357
|
+
rb_iv_set(mNcurses, "@curscr", rb_curscr);
|
358
|
+
}
|
359
|
+
return rb_curscr;
|
360
|
+
}
|
361
|
+
#ifdef HAVE_NEWSCR
|
362
|
+
static VALUE get_newscr()
|
363
|
+
{
|
364
|
+
VALUE rb_newscr = rb_iv_get(mNcurses, "@newscr");
|
365
|
+
if (rb_newscr == Qnil) {
|
366
|
+
rb_newscr = wrap_window(newscr);
|
367
|
+
rb_iv_set(mNcurses, "@newscr", rb_newscr);
|
368
|
+
}
|
369
|
+
return rb_newscr;
|
370
|
+
}
|
371
|
+
#endif
|
372
|
+
static VALUE get_LINES() {return INT2NUM(LINES);}
|
373
|
+
static VALUE get_COLS() {return INT2NUM(COLS);}
|
374
|
+
#ifdef HAVE_TABSIZE
|
375
|
+
static VALUE get_TABSIZE() {return INT2NUM(TABSIZE);}
|
376
|
+
#endif
|
377
|
+
#ifdef HAVE_ESCDELAY
|
378
|
+
/* This global was an undocumented feature under AIX curses. */
|
379
|
+
/* ESC expire time in milliseconds */
|
380
|
+
static VALUE get_ESCDELAY(){return INT2NUM(ESCDELAY);}
|
381
|
+
static VALUE set_ESCDELAY(VALUE dummy, VALUE new_delay)
|
382
|
+
{
|
383
|
+
ESCDELAY=NUM2INT(new_delay);
|
384
|
+
return INT2NUM(ESCDELAY);
|
385
|
+
}
|
386
|
+
#endif
|
387
|
+
|
388
|
+
/* This global is wrapper-specific. It denotes the interval after which the
|
389
|
+
terminal is periodically checked for having resized or not. */
|
390
|
+
/* time in milliseconds */
|
391
|
+
static VALUE get_RESIZEDELAY(){return rb_iv_get(mNcurses, "@resize_delay");}
|
392
|
+
static VALUE set_RESIZEDELAY(VALUE dummy, VALUE rb_new_delay)
|
393
|
+
{
|
394
|
+
int c_new_delay = NUM2INT(rb_new_delay);
|
395
|
+
if (c_new_delay <= 0)
|
396
|
+
rb_raise(rb_eArgError, "delay must be > 0");
|
397
|
+
rb_new_delay = INT2NUM(c_new_delay);
|
398
|
+
rb_iv_set(mNcurses, "@resize_delay", rb_new_delay);
|
399
|
+
return rb_new_delay ;
|
400
|
+
}
|
401
|
+
|
402
|
+
static
|
403
|
+
void
|
404
|
+
init_globals_2(void)
|
405
|
+
{
|
406
|
+
rb_iv_set(mNcurses, "@stdscr", Qnil);
|
407
|
+
rb_iv_set(mNcurses, "@curscr", Qnil);
|
408
|
+
rb_iv_set(mNcurses, "@newscr", Qnil);
|
409
|
+
|
410
|
+
rb_define_module_function(mNcurses, "stdscr",
|
411
|
+
(&get_stdscr), 0);
|
412
|
+
rb_define_module_function(mNcurses, "curscr",
|
413
|
+
(&get_curscr), 0);
|
414
|
+
#ifdef HAVE_NEWSCR
|
415
|
+
rb_define_module_function(mNcurses, "newscr",
|
416
|
+
(&get_newscr), 0);
|
417
|
+
#endif
|
418
|
+
rb_define_module_function(mNcurses, "LINES",
|
419
|
+
(&get_LINES), 0);
|
420
|
+
rb_define_module_function(mNcurses, "COLS",
|
421
|
+
(&get_COLS), 0);
|
422
|
+
#ifdef HAVE_TABSIZE
|
423
|
+
rb_define_module_function(mNcurses, "TABSIZE",
|
424
|
+
(&get_TABSIZE),0);
|
425
|
+
#endif
|
426
|
+
#ifdef HAVE_ESCDELAY
|
427
|
+
rb_define_module_function(mNcurses, "ESCDELAY",
|
428
|
+
(&get_ESCDELAY),0);
|
429
|
+
rb_define_module_function(mNcurses, "ESCDELAY=",
|
430
|
+
(&set_ESCDELAY),1);
|
431
|
+
#endif
|
432
|
+
/* The maximum delay before screen resize is detected, in milliseconds */
|
433
|
+
rb_iv_set(mNcurses, "@resize_delay", INT2FIX(333));
|
434
|
+
rb_define_module_function(mNcurses, "RESIZEDELAY",
|
435
|
+
(&get_RESIZEDELAY),0);
|
436
|
+
rb_define_module_function(mNcurses, "RESIZEDELAY=",
|
437
|
+
(&set_RESIZEDELAY),1);
|
438
|
+
}
|
439
|
+
#ifdef HAVE_KEYBOUND
|
440
|
+
static VALUE rbncurs_keybound(VALUE dummy, VALUE keycode, VALUE count)
|
441
|
+
{
|
442
|
+
char * str = keybound(NUM2INT(keycode), NUM2INT(count));
|
443
|
+
VALUE rb_str = Qnil;
|
444
|
+
if (str) {
|
445
|
+
rb_str = rb_str_new2(str);
|
446
|
+
free(str);
|
447
|
+
}
|
448
|
+
return rb_str;
|
449
|
+
}
|
450
|
+
#endif
|
451
|
+
#ifdef HAVE_CURSES_VERSION
|
452
|
+
static VALUE rbncurs_curses_version(){return rb_str_new2(curses_version());}
|
453
|
+
#endif
|
454
|
+
#ifdef HAVE_DEFINE_KEY
|
455
|
+
static VALUE rbncurs_define_key(VALUE dummy, VALUE definition, VALUE keycode)
|
456
|
+
{
|
457
|
+
return INT2NUM(define_key((definition != Qnil)
|
458
|
+
? StringValuePtr(definition)
|
459
|
+
: (char*)(NULL),
|
460
|
+
NUM2INT(keycode)));
|
461
|
+
}
|
462
|
+
#endif
|
463
|
+
#ifdef HAVE_KEYOK
|
464
|
+
static VALUE rbncurs_keyok(VALUE dummy, VALUE keycode, VALUE enable)
|
465
|
+
{
|
466
|
+
return INT2NUM(keyok(NUM2INT(keycode), RTEST(enable)));
|
467
|
+
}
|
468
|
+
#endif
|
469
|
+
#ifdef HAVE_RESIZETERM
|
470
|
+
static VALUE rbncurs_resizeterm(VALUE dummy, VALUE lines, VALUE columns)
|
471
|
+
{
|
472
|
+
return INT2NUM(resizeterm(NUM2INT(lines), NUM2INT(columns)));
|
473
|
+
}
|
474
|
+
#endif
|
475
|
+
#ifdef HAVE_USE_DEFAULT_COLORS
|
476
|
+
static VALUE rbncurs_use_default_colors()
|
477
|
+
{
|
478
|
+
return INT2NUM(use_default_colors());
|
479
|
+
}
|
480
|
+
#endif
|
481
|
+
#ifdef HAVE_USE_EXTENDED_NAMES
|
482
|
+
static VALUE rbncurs_use_extended_names(VALUE dummy, VALUE boolean)
|
483
|
+
{return INT2NUM(use_extended_names(RTEST(boolean)));}
|
484
|
+
#endif
|
485
|
+
#ifdef HAVE_WRESIZE
|
486
|
+
static VALUE rbncurs_wresize(VALUE dummy, VALUE win, VALUE lines, VALUE columns)
|
487
|
+
{
|
488
|
+
return INT2NUM(wresize(get_window(win), NUM2INT(lines), NUM2INT(columns)));
|
489
|
+
}
|
490
|
+
#endif
|
491
|
+
static
|
492
|
+
void
|
493
|
+
init_functions_1(void)
|
494
|
+
{
|
495
|
+
#ifdef HAVE_KEYBOUND
|
496
|
+
NCFUNC(keybound, 2);
|
497
|
+
#endif
|
498
|
+
#ifdef HAVE_CURSES_VERSION
|
499
|
+
NCFUNC(curses_version, 0);
|
500
|
+
#endif
|
501
|
+
#ifdef HAVE_DEFINE_KEY
|
502
|
+
NCFUNC(define_key, 2);
|
503
|
+
#endif
|
504
|
+
#ifdef HAVE_KEYOK
|
505
|
+
NCFUNC(keyok, 2);
|
506
|
+
#endif
|
507
|
+
#ifdef HAVE_RESIZETERM
|
508
|
+
NCFUNC(resizeterm, 2);
|
509
|
+
#endif
|
510
|
+
#ifdef HAVE_USE_DEFAULT_COLORS
|
511
|
+
NCFUNC(use_default_colors, 0);
|
512
|
+
#endif
|
513
|
+
#ifdef HAVE_USE_EXTENDED_NAMES
|
514
|
+
NCFUNC(use_extended_names, 1);
|
515
|
+
#endif
|
516
|
+
#ifdef HAVE_WRESIZE
|
517
|
+
NCFUNC(wresize, 3);
|
518
|
+
#endif
|
519
|
+
}
|
520
|
+
/* FIXME: what's this? */
|
521
|
+
/* extern char ttytype[]; */ /* needed for backward compatibility */
|
522
|
+
|
523
|
+
|
524
|
+
/* copy a chstr from ruby to c */
|
525
|
+
static chtype * RB2CHSTR(VALUE array)
|
526
|
+
{
|
527
|
+
if (rb_obj_is_instance_of(array, rb_cArray) != Qtrue) {
|
528
|
+
rb_raise(rb_eArgError,
|
529
|
+
"chtype string argument must be an empty Array");
|
530
|
+
return NULL;
|
531
|
+
}
|
532
|
+
{
|
533
|
+
size_t string_length =
|
534
|
+
NUM2ULONG(rb_funcall(array, rb_intern("size"), 0));
|
535
|
+
size_t vector_length =
|
536
|
+
string_length + 1; /* for terminating 0 */
|
537
|
+
chtype * chstr = ALLOC_N(chtype, vector_length);
|
538
|
+
unsigned long i;
|
539
|
+
for (i = 0; i < string_length; ++i) {
|
540
|
+
chstr[i] = NUM2ULONG(rb_ary_entry(array, i));
|
541
|
+
}
|
542
|
+
chstr[string_length] = 0;
|
543
|
+
return chstr;
|
544
|
+
}
|
545
|
+
}
|
546
|
+
|
547
|
+
static VALUE rbncurs_addch(VALUE dummy, VALUE arg1) {
|
548
|
+
return INT2NUM(addch(NUM2ULONG(arg1)));
|
549
|
+
}
|
550
|
+
static VALUE rbncurs_addchnstr(VALUE dummy, VALUE arg1, VALUE arg2) {
|
551
|
+
chtype * chstr = RB2CHSTR(arg1);
|
552
|
+
VALUE return_value = INT2NUM(addchnstr(chstr, NUM2INT(arg2)));
|
553
|
+
xfree(chstr);
|
554
|
+
return return_value;
|
555
|
+
}
|
556
|
+
static VALUE rbncurs_addchstr(VALUE dummy, VALUE arg1) {
|
557
|
+
chtype * chstr = RB2CHSTR(arg1);
|
558
|
+
VALUE return_value = INT2NUM(addchstr(chstr));
|
559
|
+
xfree(chstr);
|
560
|
+
return return_value;
|
561
|
+
}
|
562
|
+
static VALUE rbncurs_addnstr(VALUE dummy, VALUE arg1, VALUE arg2) {
|
563
|
+
return INT2NUM(addnstr(StringValuePtr(arg1), NUM2INT(arg2)));
|
564
|
+
}
|
565
|
+
static VALUE rbncurs_addstr(VALUE dummy, VALUE arg1) {
|
566
|
+
return INT2NUM(addstr(StringValuePtr(arg1)));
|
567
|
+
}
|
568
|
+
static VALUE rbncurs_attroff(VALUE dummy, VALUE arg1) {
|
569
|
+
return INT2NUM(attroff(NUM2ULONG(arg1)));
|
570
|
+
}
|
571
|
+
static VALUE rbncurs_attron(VALUE dummy, VALUE arg1) {
|
572
|
+
return INT2NUM(attron(NUM2ULONG(arg1)));
|
573
|
+
}
|
574
|
+
static VALUE rbncurs_attrset(VALUE dummy, VALUE arg1) {
|
575
|
+
return INT2NUM(attrset(NUM2ULONG(arg1)));
|
576
|
+
}
|
577
|
+
#if defined(NCURSES_VERSION_MAJOR) && NCURSES_VERSION_MAJOR > 4
|
578
|
+
#ifdef HAVE_ATTR_OFF
|
579
|
+
static VALUE rbncurs_attr_off(VALUE dummy, VALUE arg1, VALUE arg2) {
|
580
|
+
return INT2NUM(attr_off(NUM2ULONG(arg1), ((void)(arg2),NULL)));
|
581
|
+
}
|
582
|
+
#endif
|
583
|
+
#ifdef HAVE_ATTR_ON
|
584
|
+
static VALUE rbncurs_attr_on(VALUE dummy, VALUE arg1, VALUE arg2) {
|
585
|
+
return INT2NUM(attr_on(NUM2ULONG(arg1), ((void)(arg2),NULL)));
|
586
|
+
}
|
587
|
+
#endif
|
588
|
+
#ifdef HAVE_ATTR_SET
|
589
|
+
static VALUE rbncurs_attr_set(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
590
|
+
return INT2NUM(attr_set(NUM2ULONG(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
|
591
|
+
}
|
592
|
+
#endif
|
593
|
+
#if defined(HAVE_SLK_ATTR_OFF) || defined(slk_attr_off)
|
594
|
+
static VALUE rbncurs_slk_attr_off(VALUE dummy, VALUE arg1, VALUE arg2) {
|
595
|
+
return INT2NUM(slk_attr_off(NUM2ULONG(arg1), ((void)(arg2),NULL)));
|
596
|
+
}
|
597
|
+
#endif
|
598
|
+
#if defined(HAVE_SLK_ATTR_ON) || defined(slk_attr_on)
|
599
|
+
static VALUE rbncurs_slk_attr_on(VALUE dummy, VALUE arg1, VALUE arg2) {
|
600
|
+
return INT2NUM(slk_attr_on(NUM2ULONG(arg1), ((void)(arg2),NULL)));
|
601
|
+
}
|
602
|
+
#endif
|
603
|
+
#ifdef HAVE_SLK_ATTR_SET
|
604
|
+
static VALUE rbncurs_slk_attr_set(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
605
|
+
return INT2NUM(slk_attr_set(NUM2ULONG(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
|
606
|
+
}
|
607
|
+
#endif
|
608
|
+
#ifdef HAVE_WATTR_ON
|
609
|
+
static VALUE rbncurs_wattr_on(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
610
|
+
return INT2NUM(wattr_on(get_window(arg1), NUM2ULONG(arg2), ((void)(arg3),NULL)));
|
611
|
+
}
|
612
|
+
#endif
|
613
|
+
#ifdef HAVE_WATTR_OFF
|
614
|
+
static VALUE rbncurs_wattr_off(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
615
|
+
return INT2NUM(wattr_off(get_window(arg1), NUM2ULONG(arg2), ((void)(arg3),NULL)));
|
616
|
+
}
|
617
|
+
#endif
|
618
|
+
#ifdef HAVE_WATTR_SET
|
619
|
+
static VALUE rbncurs_wattr_set(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
620
|
+
return INT2NUM(wattr_set(get_window(arg1), NUM2ULONG(arg2), NUM2INT(arg3), ((void)(arg4),NULL)));
|
621
|
+
}
|
622
|
+
#endif
|
623
|
+
#if defined(HAVE_VID_ATTR) || defined(vid_attr)
|
624
|
+
static VALUE rbncurs_vid_attr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
625
|
+
return INT2NUM(vid_attr(NUM2ULONG(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
|
626
|
+
}
|
627
|
+
#endif
|
628
|
+
#ifdef HAVE_ATTR_GET
|
629
|
+
static VALUE rbncurs_attr_get(VALUE dummy, VALUE rb_attrs, VALUE rb_pair,
|
630
|
+
VALUE dummy2)
|
631
|
+
{
|
632
|
+
if ((rb_obj_is_instance_of(rb_attrs, rb_cArray) != Qtrue)
|
633
|
+
|| (rb_obj_is_instance_of(rb_pair, rb_cArray) != Qtrue)) {
|
634
|
+
rb_raise(rb_eArgError,
|
635
|
+
"attrs and pair arguments must be empty Arrays");
|
636
|
+
return Qnil;
|
637
|
+
}
|
638
|
+
{
|
639
|
+
attr_t attrs = 0;
|
640
|
+
short pair = 0;
|
641
|
+
int return_value = attr_get(&attrs, &pair, 0);
|
642
|
+
rb_ary_push(rb_attrs, INT2NUM(attrs));
|
643
|
+
rb_ary_push(rb_pair, INT2NUM(pair));
|
644
|
+
return INT2NUM(return_value);
|
645
|
+
}
|
646
|
+
}
|
647
|
+
static VALUE rbncurs_wattr_get(VALUE dummy,VALUE win, VALUE rb_attrs, VALUE rb_pair,
|
648
|
+
VALUE dummy2)
|
649
|
+
{
|
650
|
+
if ((rb_obj_is_instance_of(rb_attrs, rb_cArray) != Qtrue)
|
651
|
+
|| (rb_obj_is_instance_of(rb_pair, rb_cArray) != Qtrue)) {
|
652
|
+
rb_raise(rb_eArgError,
|
653
|
+
"attrs and pair arguments must be empty Arrays");
|
654
|
+
return Qnil;
|
655
|
+
}
|
656
|
+
{
|
657
|
+
attr_t attrs = 0;
|
658
|
+
short pair = 0;
|
659
|
+
int return_value = wattr_get(get_window(win), &attrs, &pair, 0);
|
660
|
+
rb_ary_push(rb_attrs, INT2NUM(attrs));
|
661
|
+
rb_ary_push(rb_pair, INT2NUM(pair));
|
662
|
+
return INT2NUM(return_value);
|
663
|
+
}
|
664
|
+
}
|
665
|
+
#endif /* HAVE_ATTR_GET */
|
666
|
+
#endif
|
667
|
+
|
668
|
+
static VALUE rbncurs_baudrate(VALUE dummy) {
|
669
|
+
return INT2NUM(baudrate());
|
670
|
+
}
|
671
|
+
static VALUE rbncurs_beep(VALUE dummy) {
|
672
|
+
return INT2NUM(beep());
|
673
|
+
}
|
674
|
+
static VALUE rbncurs_bkgd(VALUE dummy, VALUE arg1) {
|
675
|
+
return INT2NUM(bkgd(NUM2ULONG(arg1)));
|
676
|
+
}
|
677
|
+
static VALUE rbncurs_bkgdset(VALUE dummy, VALUE arg1) {
|
678
|
+
return ((bkgdset(NUM2ULONG(arg1))),Qnil);
|
679
|
+
}
|
680
|
+
static VALUE rbncurs_border(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7, VALUE arg8) {
|
681
|
+
return INT2NUM(border(NUM2ULONG(arg1), NUM2ULONG(arg2), NUM2ULONG(arg3), NUM2ULONG(arg4), NUM2ULONG(arg5), NUM2ULONG(arg6), NUM2ULONG(arg7), NUM2ULONG(arg8)));
|
682
|
+
}
|
683
|
+
static VALUE rbncurs_box(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
684
|
+
return INT2NUM(box(get_window(arg1), NUM2ULONG(arg2), NUM2ULONG(arg3)));
|
685
|
+
}
|
686
|
+
static VALUE rbncurs_can_change_color(VALUE dummy) {
|
687
|
+
return (can_change_color()) ? Qtrue : Qfalse;
|
688
|
+
}
|
689
|
+
|
690
|
+
static int rbncurshelper_halfdelay_cbreak(int tenths, int break_chars)
|
691
|
+
{
|
692
|
+
int status = break_chars ? cbreak() : nocbreak();
|
693
|
+
if (status != ERR) {
|
694
|
+
rb_iv_set(mNcurses, "@halfdelay", INT2NUM(tenths));
|
695
|
+
rb_iv_set(mNcurses, "@cbreak", break_chars ? Qtrue : Qfalse);
|
696
|
+
}
|
697
|
+
return status;
|
698
|
+
}
|
699
|
+
static void rbncurshelper_halfdelay_cbreak_restore()
|
700
|
+
{
|
701
|
+
if (RTEST(rb_iv_get(mNcurses, "@cbreak")))
|
702
|
+
cbreak();
|
703
|
+
else
|
704
|
+
nocbreak();
|
705
|
+
}
|
706
|
+
static VALUE rbncurs_cbreak(VALUE dummy) {
|
707
|
+
return INT2NUM(rbncurshelper_halfdelay_cbreak(0, 1));
|
708
|
+
}
|
709
|
+
#ifdef HAVE_CHGAT
|
710
|
+
static VALUE rbncurs_chgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
711
|
+
return INT2NUM(chgat(NUM2INT(arg1), NUM2ULONG(arg2), NUM2INT(arg3),
|
712
|
+
((void)(arg4),NULL)));
|
713
|
+
}
|
714
|
+
#endif
|
715
|
+
static VALUE rbncurs_clear(VALUE dummy) {
|
716
|
+
return INT2NUM(clear());
|
717
|
+
}
|
718
|
+
static VALUE rbncurs_clearok(VALUE dummy, VALUE arg1, VALUE arg2) {
|
719
|
+
return INT2NUM(clearok(get_window(arg1), RTEST(arg2)));
|
720
|
+
}
|
721
|
+
static VALUE rbncurs_clrtobot(VALUE dummy) {
|
722
|
+
return INT2NUM(clrtobot());
|
723
|
+
}
|
724
|
+
static VALUE rbncurs_clrtoeol(VALUE dummy) {
|
725
|
+
return INT2NUM(clrtoeol());
|
726
|
+
}
|
727
|
+
#ifdef HAVE_COLOR_SET
|
728
|
+
static VALUE rbncurs_color_set(VALUE dummy, VALUE arg1, VALUE arg2) {
|
729
|
+
return INT2NUM(color_set(NUM2INT(arg1), ((void)(arg2),NULL)));
|
730
|
+
}
|
731
|
+
#endif
|
732
|
+
static VALUE rbncurs_COLOR_PAIR(VALUE dummy, VALUE arg1) {
|
733
|
+
return INT2NUM(COLOR_PAIR(NUM2INT(arg1)));
|
734
|
+
}
|
735
|
+
static VALUE rbncurs_copywin(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7, VALUE arg8, VALUE arg9) {
|
736
|
+
return INT2NUM(copywin(get_window(arg1), get_window(arg2), NUM2INT(arg3), NUM2INT(arg4), NUM2INT(arg5), NUM2INT(arg6), NUM2INT(arg7), NUM2INT(arg8), NUM2INT(arg9)));
|
737
|
+
}
|
738
|
+
static VALUE rbncurs_curs_set(VALUE dummy, VALUE arg1) {
|
739
|
+
return INT2NUM(curs_set(NUM2INT(arg1)));
|
740
|
+
}
|
741
|
+
static VALUE rbncurs_def_prog_mode(VALUE dummy) {
|
742
|
+
return INT2NUM(def_prog_mode());
|
743
|
+
}
|
744
|
+
static VALUE rbncurs_def_shell_mode(VALUE dummy) {
|
745
|
+
return INT2NUM(def_shell_mode());
|
746
|
+
}
|
747
|
+
static VALUE rbncurs_delay_output(VALUE dummy, VALUE arg1) {
|
748
|
+
return INT2NUM(delay_output(NUM2INT(arg1)));
|
749
|
+
}
|
750
|
+
static VALUE rbncurs_delch(VALUE dummy) {
|
751
|
+
return INT2NUM(delch());
|
752
|
+
}
|
753
|
+
static VALUE rbncurs_deleteln(VALUE dummy) {
|
754
|
+
return INT2NUM(deleteln());
|
755
|
+
}
|
756
|
+
static VALUE rbncurs_derwin(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
|
757
|
+
return wrap_window(derwin(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4), NUM2INT(arg5)));
|
758
|
+
}
|
759
|
+
static VALUE rbncurs_doupdate(VALUE dummy) {
|
760
|
+
return INT2NUM(doupdate());
|
761
|
+
}
|
762
|
+
static VALUE rbncurs_dupwin(VALUE dummy, VALUE arg1) {
|
763
|
+
return wrap_window(dupwin(get_window(arg1)));
|
764
|
+
}
|
765
|
+
static VALUE rbncurs_echo(VALUE dummy) {
|
766
|
+
return INT2NUM(echo());
|
767
|
+
}
|
768
|
+
static VALUE rbncurs_echochar(VALUE dummy, VALUE arg1) {
|
769
|
+
return INT2NUM(echochar(NUM2ULONG(arg1)));
|
770
|
+
}
|
771
|
+
static VALUE rbncurs_endwin(VALUE dummy) {
|
772
|
+
return INT2NUM(endwin());
|
773
|
+
}
|
774
|
+
static VALUE rbncurs_erasechar(VALUE dummy) {
|
775
|
+
return INT2NUM(erasechar());
|
776
|
+
}
|
777
|
+
#ifdef HAVE_FILTER
|
778
|
+
static VALUE rbncurs_filter(VALUE dummy) {
|
779
|
+
return ((filter()),Qnil);
|
780
|
+
}
|
781
|
+
#endif
|
782
|
+
static VALUE rbncurs_flash(VALUE dummy) {
|
783
|
+
return INT2NUM(flash());
|
784
|
+
}
|
785
|
+
static VALUE rbncurs_flushinp(VALUE dummy) {
|
786
|
+
return INT2NUM(flushinp());
|
787
|
+
}
|
788
|
+
static VALUE rbncurs_getbkgd(VALUE dummy, VALUE arg1) {
|
789
|
+
return INT2NUM(getbkgd(get_window(arg1)));
|
790
|
+
}
|
791
|
+
|
792
|
+
static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
|
793
|
+
/* nonblocking wgetch only implemented for Ncurses */
|
794
|
+
int halfdelay = NUM2INT(rb_iv_get(mNcurses, "@halfdelay"));
|
795
|
+
int infd = NUM2INT(rb_iv_get(mNcurses, "@infd"));
|
796
|
+
double screen_delay = halfdelay * 0.1;
|
797
|
+
#ifdef NCURSES_VERSION
|
798
|
+
int windelay = c_win->_delay;
|
799
|
+
#else
|
800
|
+
int windelay = 0;
|
801
|
+
#endif
|
802
|
+
double window_delay = (windelay >= 0) ? 0.001 * windelay : (1e200*1e200);
|
803
|
+
/* FIXME: ^ Infinity ^*/
|
804
|
+
double delay = (screen_delay > 0) ? screen_delay : window_delay;
|
805
|
+
int result;
|
806
|
+
struct timeval tv;
|
807
|
+
struct timezone tz = {0,0};
|
808
|
+
double starttime, nowtime, finishtime;
|
809
|
+
double resize_delay = NUM2INT(get_RESIZEDELAY()) / 1000.0;
|
810
|
+
fd_set in_fds;
|
811
|
+
gettimeofday(&tv, &tz);
|
812
|
+
starttime = tv.tv_sec + tv.tv_usec * 1e-6;
|
813
|
+
finishtime = starttime + delay;
|
814
|
+
#ifdef NCURSES_VERSION
|
815
|
+
c_win->_delay = 0;
|
816
|
+
#endif
|
817
|
+
while (doupdate() /* detects resize */, (result = wgetch(c_win)) == ERR) {
|
818
|
+
gettimeofday(&tv, &tz);
|
819
|
+
nowtime = tv.tv_sec + tv.tv_usec * 1e-6;
|
820
|
+
delay = finishtime - nowtime;
|
821
|
+
if (delay <= 0) break;
|
822
|
+
|
823
|
+
/* Check for terminal size change every resize_delay seconds */
|
824
|
+
if (resize_delay > delay) resize_delay = delay;
|
825
|
+
tv.tv_sec = (time_t)resize_delay;
|
826
|
+
tv.tv_usec = (unsigned)( (resize_delay - tv.tv_sec) * 1e6 );
|
827
|
+
|
828
|
+
/* sleep on infd until input is available or tv reaches timeout */
|
829
|
+
FD_ZERO(&in_fds);
|
830
|
+
FD_SET(infd, &in_fds);
|
831
|
+
rb_thread_select(infd + 1, &in_fds, NULL, NULL, &tv);
|
832
|
+
}
|
833
|
+
#ifdef NCURSES_VERSION
|
834
|
+
c_win->_delay = windelay;
|
835
|
+
#endif
|
836
|
+
return result;
|
837
|
+
}
|
838
|
+
static VALUE rbncurs_getch(VALUE dummy) {
|
839
|
+
return INT2NUM(rbncurshelper_nonblocking_wgetch(stdscr));
|
840
|
+
}
|
841
|
+
static VALUE rbncurs_halfdelay(VALUE dummy, VALUE arg1) {
|
842
|
+
return INT2NUM(rbncurshelper_halfdelay_cbreak(NUM2INT(arg1), 1));
|
843
|
+
}
|
844
|
+
static VALUE rbncurs_has_colors(VALUE dummy) {
|
845
|
+
return (has_colors()) ? Qtrue : Qfalse;
|
846
|
+
}
|
847
|
+
static VALUE rbncurs_has_ic(VALUE dummy) {
|
848
|
+
return (has_ic()) ? Qtrue : Qfalse;
|
849
|
+
}
|
850
|
+
static VALUE rbncurs_has_il(VALUE dummy) {
|
851
|
+
return (has_il()) ? Qtrue : Qfalse;
|
852
|
+
}
|
853
|
+
static VALUE rbncurs_hline(VALUE dummy, VALUE arg1, VALUE arg2) {
|
854
|
+
return INT2NUM(hline(NUM2ULONG(arg1), NUM2INT(arg2)));
|
855
|
+
}
|
856
|
+
static VALUE rbncurs_idcok(VALUE dummy, VALUE arg1, VALUE arg2) {
|
857
|
+
return ((idcok(get_window(arg1), RTEST(arg2))),Qnil);
|
858
|
+
}
|
859
|
+
static VALUE rbncurs_idlok(VALUE dummy, VALUE arg1, VALUE arg2) {
|
860
|
+
return INT2NUM(idlok(get_window(arg1), RTEST(arg2)));
|
861
|
+
}
|
862
|
+
static VALUE rbncurs_immedok(VALUE dummy, VALUE arg1, VALUE arg2) {
|
863
|
+
return ((immedok(get_window(arg1), RTEST(arg2))),Qnil);
|
864
|
+
}
|
865
|
+
static VALUE rbncurs_inch(VALUE dummy) {
|
866
|
+
return INT2NUM(inch());
|
867
|
+
}
|
868
|
+
static VALUE rbncurs_initscr(VALUE dummy) {
|
869
|
+
VALUE v = wrap_window(initscr());
|
870
|
+
if (!RTEST(v))
|
871
|
+
return v;
|
872
|
+
|
873
|
+
Init_ncurses_full();
|
874
|
+
|
875
|
+
/* Some constants defined by the initscr call. */
|
876
|
+
|
877
|
+
/* line graphics */
|
878
|
+
|
879
|
+
/* VT100 symbols begin here */
|
880
|
+
|
881
|
+
rb_define_const(mNcurses, "ACS_ULCORNER", INT2NUM(ACS_ULCORNER));
|
882
|
+
rb_define_const(mNcurses, "ACS_LLCORNER", INT2NUM(ACS_LLCORNER));
|
883
|
+
rb_define_const(mNcurses, "ACS_URCORNER", INT2NUM(ACS_URCORNER));
|
884
|
+
rb_define_const(mNcurses, "ACS_LRCORNER", INT2NUM(ACS_LRCORNER));
|
885
|
+
rb_define_const(mNcurses, "ACS_LTEE", INT2NUM(ACS_LTEE));
|
886
|
+
rb_define_const(mNcurses, "ACS_RTEE", INT2NUM(ACS_RTEE));
|
887
|
+
rb_define_const(mNcurses, "ACS_BTEE", INT2NUM(ACS_BTEE));
|
888
|
+
rb_define_const(mNcurses, "ACS_TTEE", INT2NUM(ACS_TTEE));
|
889
|
+
rb_define_const(mNcurses, "ACS_HLINE", INT2NUM(ACS_HLINE));
|
890
|
+
rb_define_const(mNcurses, "ACS_VLINE", INT2NUM(ACS_VLINE));
|
891
|
+
rb_define_const(mNcurses, "ACS_PLUS", INT2NUM(ACS_PLUS));
|
892
|
+
rb_define_const(mNcurses, "ACS_S1", INT2NUM(ACS_S1));
|
893
|
+
rb_define_const(mNcurses, "ACS_S9", INT2NUM(ACS_S9));
|
894
|
+
rb_define_const(mNcurses, "ACS_DIAMOND", INT2NUM(ACS_DIAMOND));
|
895
|
+
rb_define_const(mNcurses, "ACS_CKBOARD", INT2NUM(ACS_CKBOARD));
|
896
|
+
rb_define_const(mNcurses, "ACS_DEGREE", INT2NUM(ACS_DEGREE));
|
897
|
+
rb_define_const(mNcurses, "ACS_PLMINUS", INT2NUM(ACS_PLMINUS));
|
898
|
+
rb_define_const(mNcurses, "ACS_BULLET", INT2NUM(ACS_BULLET));
|
899
|
+
/* Teletype 5410v1 symbols begin here */
|
900
|
+
rb_define_const(mNcurses, "ACS_LARROW", INT2NUM(ACS_LARROW));
|
901
|
+
rb_define_const(mNcurses, "ACS_RARROW", INT2NUM(ACS_RARROW));
|
902
|
+
rb_define_const(mNcurses, "ACS_DARROW", INT2NUM(ACS_DARROW));
|
903
|
+
rb_define_const(mNcurses, "ACS_UARROW", INT2NUM(ACS_UARROW));
|
904
|
+
rb_define_const(mNcurses, "ACS_BOARD", INT2NUM(ACS_BOARD));
|
905
|
+
rb_define_const(mNcurses, "ACS_LANTERN", INT2NUM(ACS_LANTERN));
|
906
|
+
rb_define_const(mNcurses, "ACS_BLOCK", INT2NUM(ACS_BLOCK));
|
907
|
+
/*
|
908
|
+
* These aren't documented, but a lot of System Vs have them anyway
|
909
|
+
* (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
|
910
|
+
* The ACS_names may not match AT&T's, our source didn't know them.
|
911
|
+
*/
|
912
|
+
#ifdef ACS_S3
|
913
|
+
rb_define_const(mNcurses, "ACS_S3", INT2NUM(ACS_S3));
|
914
|
+
#endif
|
915
|
+
#ifdef ACS_S7
|
916
|
+
rb_define_const(mNcurses, "ACS_S7", INT2NUM(ACS_S7));
|
917
|
+
#endif
|
918
|
+
#ifdef ACS_LEQUAL
|
919
|
+
rb_define_const(mNcurses, "ACS_LEQUAL", INT2NUM(ACS_LEQUAL));
|
920
|
+
#endif
|
921
|
+
#ifdef ACS_LEQUAL
|
922
|
+
rb_define_const(mNcurses, "ACS_GEQUAL", INT2NUM(ACS_GEQUAL));
|
923
|
+
#endif
|
924
|
+
#ifdef ACS_PI
|
925
|
+
rb_define_const(mNcurses, "ACS_PI", INT2NUM(ACS_PI));
|
926
|
+
#endif
|
927
|
+
#ifdef ACS_NEQUAL
|
928
|
+
rb_define_const(mNcurses, "ACS_NEQUAL", INT2NUM(ACS_NEQUAL));
|
929
|
+
#endif
|
930
|
+
#ifdef ACS_STERLING
|
931
|
+
rb_define_const(mNcurses, "ACS_STERLING", INT2NUM(ACS_STERLING));
|
932
|
+
#endif
|
933
|
+
/*
|
934
|
+
* Line drawing ACS names are of the form ACS_trbl, where t is the top, r
|
935
|
+
* is the right, b is the bottom, and l is the left. t, r, b, and l might
|
936
|
+
* be B (blank), S (single), D (double), or T (thick). The subset defined
|
937
|
+
* here only uses B and S.
|
938
|
+
*/
|
939
|
+
#ifdef ACS_BSSB
|
940
|
+
rb_define_const(mNcurses, "ACS_BSSB", INT2NUM(ACS_BSSB));
|
941
|
+
#endif
|
942
|
+
#ifdef ACS_SSBB
|
943
|
+
rb_define_const(mNcurses, "ACS_SSBB", INT2NUM(ACS_SSBB));
|
944
|
+
#endif
|
945
|
+
#ifdef ACS_BBSS
|
946
|
+
rb_define_const(mNcurses, "ACS_BBSS", INT2NUM(ACS_BBSS));
|
947
|
+
#endif
|
948
|
+
#ifdef ACS_SBBS
|
949
|
+
rb_define_const(mNcurses, "ACS_SBBS", INT2NUM(ACS_SBBS));
|
950
|
+
#endif
|
951
|
+
#ifdef ACS_SBSS
|
952
|
+
rb_define_const(mNcurses, "ACS_SBSS", INT2NUM(ACS_SBSS));
|
953
|
+
#endif
|
954
|
+
#ifdef ACS_SSSB
|
955
|
+
rb_define_const(mNcurses, "ACS_SSSB", INT2NUM(ACS_SSSB));
|
956
|
+
#endif
|
957
|
+
#ifdef ACS_SSBS
|
958
|
+
rb_define_const(mNcurses, "ACS_SSBS", INT2NUM(ACS_SSBS));
|
959
|
+
#endif
|
960
|
+
#ifdef ACS_BSSS
|
961
|
+
rb_define_const(mNcurses, "ACS_BSSS", INT2NUM(ACS_BSSS));
|
962
|
+
#endif
|
963
|
+
#ifdef ACS_BSBS
|
964
|
+
rb_define_const(mNcurses, "ACS_BSBS", INT2NUM(ACS_BSBS));
|
965
|
+
#endif
|
966
|
+
#ifdef ACS_SBSB
|
967
|
+
rb_define_const(mNcurses, "ACS_SBSB", INT2NUM(ACS_SBSB));
|
968
|
+
#endif
|
969
|
+
#ifdef ACS_SSSS
|
970
|
+
rb_define_const(mNcurses, "ACS_SSSS", INT2NUM(ACS_SSSS));
|
971
|
+
#endif
|
972
|
+
rbncurshelper_halfdelay_cbreak_restore();
|
973
|
+
rb_iv_set(mNcurses, "@infd", INT2FIX(0));
|
974
|
+
rb_iv_set(mNcurses, "@halfdelay", INT2FIX(0));
|
975
|
+
rb_iv_set(mNcurses, "@cbreak", Qfalse);
|
976
|
+
return v;
|
977
|
+
}
|
978
|
+
static VALUE rbncurs_init_color(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
979
|
+
return INT2NUM(init_color(NUM2INT(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4)));
|
980
|
+
}
|
981
|
+
static VALUE rbncurs_init_pair(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
982
|
+
return INT2NUM(init_pair(NUM2INT(arg1), NUM2INT(arg2), NUM2INT(arg3)));
|
983
|
+
}
|
984
|
+
static VALUE rbncurs_insch(VALUE dummy, VALUE arg1) {
|
985
|
+
return INT2NUM(insch(NUM2ULONG(arg1)));
|
986
|
+
}
|
987
|
+
static VALUE rbncurs_insdelln(VALUE dummy, VALUE arg1) {
|
988
|
+
return INT2NUM(insdelln(NUM2INT(arg1)));
|
989
|
+
}
|
990
|
+
static VALUE rbncurs_insertln(VALUE dummy) {
|
991
|
+
return INT2NUM(insertln());
|
992
|
+
}
|
993
|
+
static VALUE rbncurs_insnstr(VALUE dummy, VALUE arg1, VALUE arg2) {
|
994
|
+
return INT2NUM(insnstr(StringValuePtr(arg1), NUM2INT(arg2)));
|
995
|
+
}
|
996
|
+
static VALUE rbncurs_insstr(VALUE dummy, VALUE arg1) {
|
997
|
+
return INT2NUM(insstr(StringValuePtr(arg1)));
|
998
|
+
}
|
999
|
+
#ifdef HAVE_INTRFLUSH
|
1000
|
+
static VALUE rbncurs_intrflush(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1001
|
+
return INT2NUM(intrflush(get_window(arg1), RTEST(arg2)));
|
1002
|
+
}
|
1003
|
+
#endif
|
1004
|
+
static VALUE rbncurs_isendwin(VALUE dummy) {
|
1005
|
+
return (isendwin()) ? Qtrue : Qfalse;
|
1006
|
+
}
|
1007
|
+
static VALUE rbncurs_is_linetouched(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1008
|
+
return (is_linetouched(get_window(arg1), NUM2INT(arg2))) ? Qtrue : Qfalse;
|
1009
|
+
}
|
1010
|
+
static VALUE rbncurs_is_wintouched(VALUE dummy, VALUE arg1) {
|
1011
|
+
return (is_wintouched(get_window(arg1))) ? Qtrue : Qfalse;
|
1012
|
+
}
|
1013
|
+
static VALUE rbncurs_keyname(VALUE dummy, VALUE arg1) {
|
1014
|
+
return rb_str_new2(keyname(NUM2INT(arg1)));
|
1015
|
+
}
|
1016
|
+
static VALUE rbncurs_keypad(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1017
|
+
return INT2NUM(keypad(get_window(arg1), RTEST(arg2)));
|
1018
|
+
}
|
1019
|
+
static VALUE rbncurs_killchar(VALUE dummy) {
|
1020
|
+
return INT2NUM(killchar());
|
1021
|
+
}
|
1022
|
+
static VALUE rbncurs_leaveok(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1023
|
+
return INT2NUM(leaveok(get_window(arg1), RTEST(arg2)));
|
1024
|
+
}
|
1025
|
+
static VALUE rbncurs_longname(VALUE dummy) {
|
1026
|
+
return rb_str_new2(longname());
|
1027
|
+
}
|
1028
|
+
static VALUE rbncurs_meta(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1029
|
+
return INT2NUM(meta(get_window(arg1), RTEST(arg2)));
|
1030
|
+
}
|
1031
|
+
static VALUE rbncurs_move(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1032
|
+
return INT2NUM(move(NUM2INT(arg1), NUM2INT(arg2)));
|
1033
|
+
}
|
1034
|
+
static VALUE rbncurs_mvaddch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1035
|
+
return INT2NUM(mvaddch(NUM2INT(arg1), NUM2INT(arg2), NUM2ULONG(arg3)));
|
1036
|
+
}
|
1037
|
+
static VALUE rbncurs_mvaddchnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3,
|
1038
|
+
VALUE arg4) {
|
1039
|
+
chtype * chstr = RB2CHSTR(arg3);
|
1040
|
+
VALUE return_value = INT2NUM(mvaddchnstr(NUM2INT(arg1), NUM2INT(arg2),
|
1041
|
+
chstr, NUM2INT(arg4)));
|
1042
|
+
xfree(chstr);
|
1043
|
+
return return_value;
|
1044
|
+
}
|
1045
|
+
static VALUE rbncurs_mvaddchstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1046
|
+
chtype * chstr = RB2CHSTR(arg3);
|
1047
|
+
VALUE return_value = INT2NUM(mvaddchstr(NUM2INT(arg1), NUM2INT(arg2),
|
1048
|
+
chstr));
|
1049
|
+
xfree(chstr);
|
1050
|
+
return return_value;
|
1051
|
+
}
|
1052
|
+
static VALUE rbncurs_mvaddnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1053
|
+
return INT2NUM(mvaddnstr(NUM2INT(arg1), NUM2INT(arg2), StringValuePtr(arg3), NUM2INT(arg4)));
|
1054
|
+
}
|
1055
|
+
static VALUE rbncurs_mvaddstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1056
|
+
return INT2NUM(mvaddstr(NUM2INT(arg1), NUM2INT(arg2), StringValuePtr(arg3)));
|
1057
|
+
}
|
1058
|
+
#ifdef HAVE_MVCHGAT
|
1059
|
+
static VALUE rbncurs_mvchgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6) {
|
1060
|
+
return INT2NUM(mvchgat(NUM2INT(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4), NUM2INT(arg5), ((void)(arg6),NULL)));
|
1061
|
+
}
|
1062
|
+
#endif
|
1063
|
+
static VALUE rbncurs_mvcur(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1064
|
+
return INT2NUM(mvcur(NUM2INT(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4)));
|
1065
|
+
}
|
1066
|
+
static VALUE rbncurs_mvdelch(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1067
|
+
return INT2NUM(mvdelch(NUM2INT(arg1), NUM2INT(arg2)));
|
1068
|
+
}
|
1069
|
+
static VALUE rbncurs_mvderwin(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1070
|
+
return INT2NUM(mvderwin(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
|
1071
|
+
}
|
1072
|
+
static VALUE rbncurs_mvgetch(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1073
|
+
if (wmove(stdscr, NUM2INT(arg1), NUM2INT(arg2)) == ERR)
|
1074
|
+
return INT2NUM(ERR);
|
1075
|
+
return INT2NUM(rbncurshelper_nonblocking_wgetch(stdscr));
|
1076
|
+
}
|
1077
|
+
#ifdef HAVE_MVHLINE
|
1078
|
+
static VALUE rbncurs_mvhline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1079
|
+
return INT2NUM(mvhline(NUM2INT(arg1), NUM2INT(arg2), NUM2ULONG(arg3), NUM2INT(arg4)));
|
1080
|
+
}
|
1081
|
+
#endif
|
1082
|
+
static VALUE rbncurs_mvinch(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1083
|
+
return INT2NUM(mvinch(NUM2INT(arg1), NUM2INT(arg2)));
|
1084
|
+
}
|
1085
|
+
static VALUE rbncurs_mvinsch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1086
|
+
return INT2NUM(mvinsch(NUM2INT(arg1), NUM2INT(arg2), NUM2ULONG(arg3)));
|
1087
|
+
}
|
1088
|
+
static VALUE rbncurs_mvinsnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1089
|
+
return INT2NUM(mvinsnstr(NUM2INT(arg1), NUM2INT(arg2), StringValuePtr(arg3), NUM2INT(arg4)));
|
1090
|
+
}
|
1091
|
+
static VALUE rbncurs_mvinsstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1092
|
+
return INT2NUM(mvinsstr(NUM2INT(arg1), NUM2INT(arg2), StringValuePtr(arg3)));
|
1093
|
+
}
|
1094
|
+
#ifdef HAVE_MVVLINE
|
1095
|
+
static VALUE rbncurs_mvvline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1096
|
+
return INT2NUM(mvvline(NUM2INT(arg1), NUM2INT(arg2), NUM2ULONG(arg3), NUM2INT(arg4)));
|
1097
|
+
}
|
1098
|
+
#endif
|
1099
|
+
static VALUE rbncurs_mvwaddch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1100
|
+
return INT2NUM(mvwaddch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4)));
|
1101
|
+
}
|
1102
|
+
static VALUE rbncurs_mvwaddchnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3,
|
1103
|
+
VALUE arg4, VALUE arg5) {
|
1104
|
+
chtype * chstr = RB2CHSTR(arg4);
|
1105
|
+
VALUE return_value = INT2NUM(mvwaddchnstr(get_window(arg1), NUM2INT(arg2),
|
1106
|
+
NUM2INT(arg3), chstr,
|
1107
|
+
NUM2INT(arg5)));
|
1108
|
+
xfree(chstr);
|
1109
|
+
return return_value;
|
1110
|
+
}
|
1111
|
+
static VALUE rbncurs_mvwaddchstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3,
|
1112
|
+
VALUE arg4) {
|
1113
|
+
chtype * chstr = RB2CHSTR(arg4);
|
1114
|
+
VALUE return_value = INT2NUM(mvwaddchstr(get_window(arg1), NUM2INT(arg2),
|
1115
|
+
NUM2INT(arg3), chstr));
|
1116
|
+
xfree(chstr);
|
1117
|
+
return return_value;
|
1118
|
+
}
|
1119
|
+
static VALUE rbncurs_mvwaddnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
|
1120
|
+
return INT2NUM(mvwaddnstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), StringValuePtr(arg4), NUM2INT(arg5)));
|
1121
|
+
}
|
1122
|
+
static VALUE rbncurs_mvwaddstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1123
|
+
return INT2NUM(mvwaddstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), StringValuePtr(arg4)));
|
1124
|
+
}
|
1125
|
+
#ifdef HAVE_MVWCHGAT
|
1126
|
+
static VALUE rbncurs_mvwchgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7) {
|
1127
|
+
return INT2NUM(mvwchgat(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4), NUM2ULONG(arg5), NUM2INT(arg6), ((void)(arg7),NULL)));
|
1128
|
+
}
|
1129
|
+
#endif
|
1130
|
+
static VALUE rbncurs_mvwdelch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1131
|
+
return INT2NUM(mvwdelch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
|
1132
|
+
}
|
1133
|
+
static VALUE rbncurs_mvwgetch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1134
|
+
WINDOW * c_win = get_window(arg1);
|
1135
|
+
if (wmove(c_win, NUM2INT(arg1), NUM2INT(arg2)) == ERR)
|
1136
|
+
return INT2NUM(ERR);
|
1137
|
+
return INT2NUM(rbncurshelper_nonblocking_wgetch(c_win));
|
1138
|
+
}
|
1139
|
+
#ifdef HAVE_MVWHLINE
|
1140
|
+
static VALUE rbncurs_mvwhline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
|
1141
|
+
return INT2NUM(mvwhline(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4), NUM2INT(arg5)));
|
1142
|
+
}
|
1143
|
+
#endif
|
1144
|
+
static VALUE rbncurs_mvwin(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1145
|
+
return INT2NUM(mvwin(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
|
1146
|
+
}
|
1147
|
+
static VALUE rbncurs_mvwinch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1148
|
+
return INT2NUM(mvwinch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
|
1149
|
+
}
|
1150
|
+
static VALUE rbncurs_mvwinsch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1151
|
+
return INT2NUM(mvwinsch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4)));
|
1152
|
+
}
|
1153
|
+
static VALUE rbncurs_mvwinsnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
|
1154
|
+
return INT2NUM(mvwinsnstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), StringValuePtr(arg4), NUM2INT(arg5)));
|
1155
|
+
}
|
1156
|
+
static VALUE rbncurs_mvwinsstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1157
|
+
return INT2NUM(mvwinsstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), StringValuePtr(arg4)));
|
1158
|
+
}
|
1159
|
+
#ifdef HAVE_MVWVLINE
|
1160
|
+
static VALUE rbncurs_mvwvline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
|
1161
|
+
return INT2NUM(mvwvline(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4), NUM2INT(arg5)));
|
1162
|
+
}
|
1163
|
+
#endif
|
1164
|
+
static VALUE rbncurs_napms(VALUE dummy, VALUE arg1) {
|
1165
|
+
return INT2NUM(napms(NUM2INT(arg1)));
|
1166
|
+
}
|
1167
|
+
static VALUE rbncurs_newpad(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1168
|
+
return wrap_window(newpad(NUM2INT(arg1), NUM2INT(arg2)));
|
1169
|
+
}
|
1170
|
+
static VALUE rbncurs_newwin(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1171
|
+
return wrap_window(newwin(NUM2INT(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4)));
|
1172
|
+
}
|
1173
|
+
static VALUE rbncurs_nl(VALUE dummy) {
|
1174
|
+
return INT2NUM(nl());
|
1175
|
+
}
|
1176
|
+
static VALUE rbncurs_nocbreak(VALUE dummy) {
|
1177
|
+
return INT2NUM(rbncurshelper_halfdelay_cbreak(0, 0));
|
1178
|
+
}
|
1179
|
+
static VALUE rbncurs_nodelay(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1180
|
+
return INT2NUM(nodelay(get_window(arg1), RTEST(arg2)));
|
1181
|
+
}
|
1182
|
+
static VALUE rbncurs_noecho(VALUE dummy) {
|
1183
|
+
return INT2NUM(noecho());
|
1184
|
+
}
|
1185
|
+
static VALUE rbncurs_nonl(VALUE dummy) {
|
1186
|
+
return INT2NUM(nonl());
|
1187
|
+
}
|
1188
|
+
#ifdef HAVE_NOQIFLUSH
|
1189
|
+
static VALUE rbncurs_noqiflush(VALUE dummy) {
|
1190
|
+
return ((noqiflush()),Qnil);
|
1191
|
+
}
|
1192
|
+
#endif
|
1193
|
+
static VALUE rbncurs_noraw(VALUE dummy) {
|
1194
|
+
return INT2NUM(noraw());
|
1195
|
+
}
|
1196
|
+
static VALUE rbncurs_notimeout(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1197
|
+
return INT2NUM(notimeout(get_window(arg1), RTEST(arg2)));
|
1198
|
+
}
|
1199
|
+
static VALUE rbncurs_overlay(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1200
|
+
return INT2NUM(overlay(get_window(arg1), get_window(arg2)));
|
1201
|
+
}
|
1202
|
+
static VALUE rbncurs_overwrite(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1203
|
+
return INT2NUM(overwrite(get_window(arg1), get_window(arg2)));
|
1204
|
+
}
|
1205
|
+
static VALUE rbncurs_PAIR_NUMBER(VALUE dummy, VALUE arg1) {
|
1206
|
+
return INT2NUM(PAIR_NUMBER(NUM2INT(arg1)));
|
1207
|
+
}
|
1208
|
+
#ifndef __PDCURSES__ /* pdcurses "pechochar" macro won't compile*/
|
1209
|
+
static VALUE rbncurs_pechochar(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1210
|
+
return INT2NUM(pechochar(get_window(arg1), NUM2ULONG(arg2)));
|
1211
|
+
}
|
1212
|
+
#endif
|
1213
|
+
static VALUE rbncurs_pnoutrefresh(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7) {
|
1214
|
+
return INT2NUM(pnoutrefresh(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4), NUM2INT(arg5), NUM2INT(arg6), NUM2INT(arg7)));
|
1215
|
+
}
|
1216
|
+
static VALUE rbncurs_prefresh(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7) {
|
1217
|
+
return INT2NUM(prefresh(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4), NUM2INT(arg5), NUM2INT(arg6), NUM2INT(arg7)));
|
1218
|
+
}
|
1219
|
+
#ifdef HAVE_PUTP
|
1220
|
+
static VALUE rbncurs_putp(VALUE dummy, VALUE arg1) {
|
1221
|
+
return INT2NUM(putp(StringValuePtr(arg1)));
|
1222
|
+
}
|
1223
|
+
#endif
|
1224
|
+
#ifdef HAVE_QIFLUSH
|
1225
|
+
static VALUE rbncurs_qiflush(VALUE dummy) {
|
1226
|
+
return ((qiflush()),Qnil);
|
1227
|
+
}
|
1228
|
+
#endif
|
1229
|
+
static VALUE rbncurs_raw(VALUE dummy) {
|
1230
|
+
return INT2NUM(raw());
|
1231
|
+
}
|
1232
|
+
#ifndef __PDCURSES__ /* __PDCURSES__ redrawwin macro is buggy */
|
1233
|
+
static VALUE rbncurs_redrawwin(VALUE dummy, VALUE arg1) {
|
1234
|
+
return INT2NUM(redrawwin(get_window(arg1)));
|
1235
|
+
}
|
1236
|
+
#endif
|
1237
|
+
static VALUE rbncurs_refresh(VALUE dummy) {
|
1238
|
+
return INT2NUM(refresh());
|
1239
|
+
}
|
1240
|
+
static VALUE rbncurs_resetty(VALUE dummy) {
|
1241
|
+
return INT2NUM(resetty());
|
1242
|
+
}
|
1243
|
+
static VALUE rbncurs_reset_prog_mode(VALUE dummy) {
|
1244
|
+
return INT2NUM(reset_prog_mode());
|
1245
|
+
}
|
1246
|
+
static VALUE rbncurs_reset_shell_mode(VALUE dummy) {
|
1247
|
+
return INT2NUM(reset_shell_mode());
|
1248
|
+
}
|
1249
|
+
static VALUE rbncurs_savetty(VALUE dummy) {
|
1250
|
+
return INT2NUM(savetty());
|
1251
|
+
}
|
1252
|
+
#ifdef HAVE_SCR_DUMP
|
1253
|
+
static VALUE rbncurs_scr_dump(VALUE dummy, VALUE arg1) {
|
1254
|
+
return INT2NUM(scr_dump(StringValuePtr(arg1)));
|
1255
|
+
}
|
1256
|
+
#endif
|
1257
|
+
#ifdef HAVE_SCR_INIT
|
1258
|
+
static VALUE rbncurs_scr_init(VALUE dummy, VALUE arg1) {
|
1259
|
+
return INT2NUM(scr_init(StringValuePtr(arg1)));
|
1260
|
+
}
|
1261
|
+
#endif
|
1262
|
+
static VALUE rbncurs_scrl(VALUE dummy, VALUE arg1) {
|
1263
|
+
return INT2NUM(scrl(NUM2INT(arg1)));
|
1264
|
+
}
|
1265
|
+
static VALUE rbncurs_scroll(VALUE dummy, VALUE arg1) {
|
1266
|
+
return INT2NUM(scroll(get_window(arg1)));
|
1267
|
+
}
|
1268
|
+
static VALUE rbncurs_scrollok(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1269
|
+
return INT2NUM(scrollok(get_window(arg1), RTEST(arg2)));
|
1270
|
+
}
|
1271
|
+
#ifdef HAVE_SCR_RESTORE
|
1272
|
+
static VALUE rbncurs_scr_restore(VALUE dummy, VALUE arg1) {
|
1273
|
+
return INT2NUM(scr_restore(StringValuePtr(arg1)));
|
1274
|
+
}
|
1275
|
+
#endif
|
1276
|
+
#ifdef HAVE_SCR_SET
|
1277
|
+
static VALUE rbncurs_scr_set(VALUE dummy, VALUE arg1) {
|
1278
|
+
return INT2NUM(scr_set(StringValuePtr(arg1)));
|
1279
|
+
}
|
1280
|
+
#endif
|
1281
|
+
static VALUE rbncurs_setscrreg(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1282
|
+
return INT2NUM(setscrreg(NUM2INT(arg1), NUM2INT(arg2)));
|
1283
|
+
}
|
1284
|
+
static VALUE rbncurs_set_term(VALUE dummy, VALUE rb_new_screen) {
|
1285
|
+
VALUE rb_old_screen = wrap_screen(set_term(get_screen(rb_new_screen)));
|
1286
|
+
rb_iv_set(rb_old_screen, "@infd", rb_iv_get(mNcurses, "@infd"));
|
1287
|
+
rb_iv_set(rb_old_screen, "@halfdelay", rb_iv_get(mNcurses, "@halfdelay"));
|
1288
|
+
rb_iv_set(rb_old_screen, "@cbreak", rb_iv_get(mNcurses, "@cbreak"));
|
1289
|
+
rb_iv_set(mNcurses, "@infd", rb_iv_get(rb_new_screen, "@infd"));
|
1290
|
+
rb_iv_set(mNcurses, "@halfdelay", rb_iv_get(rb_new_screen, "@halfdelay"));
|
1291
|
+
rb_iv_set(mNcurses, "@cbreak", rb_iv_get(rb_new_screen, "@cbreak"));
|
1292
|
+
|
1293
|
+
rbncurshelper_halfdelay_cbreak_restore();
|
1294
|
+
return rb_old_screen;
|
1295
|
+
}
|
1296
|
+
static VALUE rbncurs_slk_attroff(VALUE dummy, VALUE arg1) {
|
1297
|
+
return INT2NUM(slk_attroff(NUM2ULONG(arg1)));
|
1298
|
+
}
|
1299
|
+
static VALUE rbncurs_slk_attron(VALUE dummy, VALUE arg1) {
|
1300
|
+
return INT2NUM(slk_attron(NUM2ULONG(arg1)));
|
1301
|
+
}
|
1302
|
+
static VALUE rbncurs_slk_attrset(VALUE dummy, VALUE arg1) {
|
1303
|
+
return INT2NUM(slk_attrset(NUM2ULONG(arg1)));
|
1304
|
+
}
|
1305
|
+
#ifdef HAVE_SLK_ATTR
|
1306
|
+
static VALUE rbncurs_slk_attr(VALUE dummy) {
|
1307
|
+
return INT2NUM(slk_attr());
|
1308
|
+
}
|
1309
|
+
#endif
|
1310
|
+
|
1311
|
+
static VALUE rbncurs_slk_clear(VALUE dummy) {
|
1312
|
+
return INT2NUM(slk_clear());
|
1313
|
+
}
|
1314
|
+
#ifdef HAVE_SLK_COLOR
|
1315
|
+
static VALUE rbncurs_slk_color(VALUE dummy, VALUE arg1) {
|
1316
|
+
return INT2NUM(slk_color(NUM2INT(arg1)));
|
1317
|
+
}
|
1318
|
+
#endif
|
1319
|
+
static VALUE rbncurs_slk_init(VALUE dummy, VALUE arg1) {
|
1320
|
+
return INT2NUM(slk_init(NUM2INT(arg1)));
|
1321
|
+
}
|
1322
|
+
static VALUE rbncurs_slk_label(VALUE dummy, VALUE arg1) {
|
1323
|
+
return rb_str_new2(slk_label(NUM2INT(arg1)));
|
1324
|
+
}
|
1325
|
+
static VALUE rbncurs_slk_noutrefresh(VALUE dummy) {
|
1326
|
+
return INT2NUM(slk_noutrefresh());
|
1327
|
+
}
|
1328
|
+
static VALUE rbncurs_slk_refresh(VALUE dummy) {
|
1329
|
+
return INT2NUM(slk_refresh());
|
1330
|
+
}
|
1331
|
+
static VALUE rbncurs_slk_restore(VALUE dummy) {
|
1332
|
+
return INT2NUM(slk_restore());
|
1333
|
+
}
|
1334
|
+
static VALUE rbncurs_slk_set(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1335
|
+
return INT2NUM(slk_set(NUM2INT(arg1), StringValuePtr(arg2), NUM2INT(arg3)));
|
1336
|
+
}
|
1337
|
+
static VALUE rbncurs_slk_touch(VALUE dummy) {
|
1338
|
+
return INT2NUM(slk_touch());
|
1339
|
+
}
|
1340
|
+
static VALUE rbncurs_standout(VALUE dummy) {
|
1341
|
+
return INT2NUM(standout());
|
1342
|
+
}
|
1343
|
+
static VALUE rbncurs_standend(VALUE dummy) {
|
1344
|
+
return INT2NUM(standend());
|
1345
|
+
}
|
1346
|
+
static VALUE rbncurs_start_color(VALUE dummy) {
|
1347
|
+
return INT2NUM(start_color());
|
1348
|
+
}
|
1349
|
+
static VALUE rbncurs_subpad(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
|
1350
|
+
return wrap_window(subpad(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4), NUM2INT(arg5)));
|
1351
|
+
}
|
1352
|
+
static VALUE rbncurs_subwin(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
|
1353
|
+
return wrap_window(subwin(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4), NUM2INT(arg5)));
|
1354
|
+
}
|
1355
|
+
static VALUE rbncurs_syncok(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1356
|
+
return INT2NUM(syncok(get_window(arg1), RTEST(arg2)));
|
1357
|
+
}
|
1358
|
+
static VALUE rbncurs_termattrs(VALUE dummy) {
|
1359
|
+
return INT2NUM(termattrs());
|
1360
|
+
}
|
1361
|
+
static VALUE rbncurs_termname(VALUE dummy) {
|
1362
|
+
return rb_str_new2(termname());
|
1363
|
+
}
|
1364
|
+
#ifdef HAVE_TIGETFLAG
|
1365
|
+
static VALUE rbncurs_tigetflag(VALUE dummy, VALUE arg1) {
|
1366
|
+
return INT2NUM(tigetflag(StringValuePtr(arg1)));
|
1367
|
+
}
|
1368
|
+
#endif
|
1369
|
+
#ifdef HAVE_TIGETNUM
|
1370
|
+
static VALUE rbncurs_tigetnum(VALUE dummy, VALUE arg1) {
|
1371
|
+
return INT2NUM(tigetnum(StringValuePtr(arg1)));
|
1372
|
+
}
|
1373
|
+
#endif
|
1374
|
+
#ifdef HAVE_TIGETSTR
|
1375
|
+
static VALUE rbncurs_tigetstr(VALUE dummy, VALUE arg1) {
|
1376
|
+
return rb_str_new2(tigetstr(StringValuePtr(arg1)));
|
1377
|
+
}
|
1378
|
+
#endif
|
1379
|
+
static VALUE rbncurs_timeout(VALUE dummy, VALUE arg1) {
|
1380
|
+
return ((timeout(NUM2INT(arg1))),Qnil);
|
1381
|
+
}
|
1382
|
+
static VALUE rbncurs_typeahead(VALUE dummy, VALUE arg1) {
|
1383
|
+
return INT2NUM(typeahead(NUM2INT(arg1)));
|
1384
|
+
}
|
1385
|
+
static VALUE rbncurs_ungetch(VALUE dummy, VALUE arg1) {
|
1386
|
+
return INT2NUM(ungetch(NUM2INT(arg1)));
|
1387
|
+
}
|
1388
|
+
static VALUE rbncurs_untouchwin(VALUE dummy, VALUE arg1) {
|
1389
|
+
return INT2NUM(untouchwin(get_window(arg1)));
|
1390
|
+
}
|
1391
|
+
#ifdef HAVE_USE_ENV
|
1392
|
+
static VALUE rbncurs_use_env(VALUE dummy, VALUE arg1) {
|
1393
|
+
return ((use_env(RTEST(arg1))),Qnil);
|
1394
|
+
}
|
1395
|
+
#endif
|
1396
|
+
#ifdef HAVE_VIDATTR
|
1397
|
+
static VALUE rbncurs_vidattr(VALUE dummy, VALUE arg1) {
|
1398
|
+
return INT2NUM(vidattr(NUM2ULONG(arg1)));
|
1399
|
+
}
|
1400
|
+
#endif
|
1401
|
+
static VALUE rbncurs_vline(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1402
|
+
return INT2NUM(vline(NUM2ULONG(arg1), NUM2INT(arg2)));
|
1403
|
+
}
|
1404
|
+
static VALUE rbncurs_waddch(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1405
|
+
return INT2NUM(waddch(get_window(arg1), NUM2ULONG(arg2)));
|
1406
|
+
}
|
1407
|
+
static VALUE rbncurs_waddchnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1408
|
+
chtype * chstr = RB2CHSTR(arg2);
|
1409
|
+
VALUE return_value = INT2NUM(waddchnstr(get_window(arg1), chstr,
|
1410
|
+
NUM2INT(arg3)));
|
1411
|
+
xfree(chstr);
|
1412
|
+
return return_value;
|
1413
|
+
}
|
1414
|
+
static VALUE rbncurs_waddchstr(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1415
|
+
chtype * chstr = RB2CHSTR(arg2);
|
1416
|
+
VALUE return_value = INT2NUM(waddchstr(get_window(arg1), chstr));
|
1417
|
+
xfree(chstr);
|
1418
|
+
return return_value;
|
1419
|
+
}
|
1420
|
+
static VALUE rbncurs_waddnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1421
|
+
return INT2NUM(waddnstr(get_window(arg1), StringValuePtr(arg2), NUM2INT(arg3)));
|
1422
|
+
}
|
1423
|
+
static VALUE rbncurs_waddstr(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1424
|
+
return INT2NUM(waddstr(get_window(arg1), StringValuePtr(arg2)));
|
1425
|
+
}
|
1426
|
+
static VALUE rbncurs_wattron(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1427
|
+
return INT2NUM(wattron(get_window(arg1), NUM2INT(arg2)));
|
1428
|
+
}
|
1429
|
+
static VALUE rbncurs_wattroff(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1430
|
+
return INT2NUM(wattroff(get_window(arg1), NUM2INT(arg2)));
|
1431
|
+
}
|
1432
|
+
static VALUE rbncurs_wattrset(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1433
|
+
return INT2NUM(wattrset(get_window(arg1), NUM2INT(arg2)));
|
1434
|
+
}
|
1435
|
+
static VALUE rbncurs_wbkgd(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1436
|
+
return INT2NUM(wbkgd(get_window(arg1), NUM2ULONG(arg2)));
|
1437
|
+
}
|
1438
|
+
static VALUE rbncurs_wbkgdset(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1439
|
+
return ((wbkgdset(get_window(arg1), NUM2ULONG(arg2))),Qnil);
|
1440
|
+
}
|
1441
|
+
static VALUE rbncurs_wborder(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7, VALUE arg8, VALUE arg9) {
|
1442
|
+
return INT2NUM(wborder(get_window(arg1), NUM2ULONG(arg2), NUM2ULONG(arg3), NUM2ULONG(arg4), NUM2ULONG(arg5), NUM2ULONG(arg6), NUM2ULONG(arg7), NUM2ULONG(arg8), NUM2ULONG(arg9)));
|
1443
|
+
}
|
1444
|
+
#ifdef HAVE_WCHGAT
|
1445
|
+
static VALUE rbncurs_wchgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
|
1446
|
+
return INT2NUM(wchgat(get_window(arg1), NUM2INT(arg2), NUM2ULONG(arg3), NUM2INT(arg4), ((void)(arg5),NULL)));
|
1447
|
+
}
|
1448
|
+
#endif
|
1449
|
+
static VALUE rbncurs_wclear(VALUE dummy, VALUE arg1) {
|
1450
|
+
return INT2NUM(wclear(get_window(arg1)));
|
1451
|
+
}
|
1452
|
+
static VALUE rbncurs_wclrtobot(VALUE dummy, VALUE arg1) {
|
1453
|
+
return INT2NUM(wclrtobot(get_window(arg1)));
|
1454
|
+
}
|
1455
|
+
static VALUE rbncurs_wclrtoeol(VALUE dummy, VALUE arg1) {
|
1456
|
+
return INT2NUM(wclrtoeol(get_window(arg1)));
|
1457
|
+
}
|
1458
|
+
#ifdef HAVE_WCOLOR_SET
|
1459
|
+
static VALUE rbncurs_wcolor_set(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1460
|
+
return INT2NUM(wcolor_set(get_window(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
|
1461
|
+
}
|
1462
|
+
#endif
|
1463
|
+
static VALUE rbncurs_wcursyncup(VALUE dummy, VALUE arg1) {
|
1464
|
+
return ((wcursyncup(get_window(arg1))),Qnil);
|
1465
|
+
}
|
1466
|
+
static VALUE rbncurs_wdelch(VALUE dummy, VALUE arg1) {
|
1467
|
+
return INT2NUM(wdelch(get_window(arg1)));
|
1468
|
+
}
|
1469
|
+
static VALUE rbncurs_wdeleteln(VALUE dummy, VALUE arg1) {
|
1470
|
+
return INT2NUM(wdeleteln(get_window(arg1)));
|
1471
|
+
}
|
1472
|
+
static VALUE rbncurs_wechochar(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1473
|
+
return INT2NUM(wechochar(get_window(arg1), NUM2ULONG(arg2)));
|
1474
|
+
}
|
1475
|
+
static VALUE rbncurs_werase(VALUE dummy, VALUE arg1) {
|
1476
|
+
return INT2NUM(werase(get_window(arg1)));
|
1477
|
+
}
|
1478
|
+
static VALUE rbncurs_wgetch(VALUE dummy, VALUE arg1) {
|
1479
|
+
return INT2NUM(rbncurshelper_nonblocking_wgetch(get_window(arg1)));
|
1480
|
+
}
|
1481
|
+
static VALUE rbncurs_whline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1482
|
+
return INT2NUM(whline(get_window(arg1), NUM2ULONG(arg2), NUM2INT(arg3)));
|
1483
|
+
}
|
1484
|
+
static VALUE rbncurs_winch(VALUE dummy, VALUE arg1) {
|
1485
|
+
return INT2NUM(winch(get_window(arg1)));
|
1486
|
+
}
|
1487
|
+
static VALUE rbncurs_winsch(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1488
|
+
return INT2NUM(winsch(get_window(arg1), NUM2ULONG(arg2)));
|
1489
|
+
}
|
1490
|
+
static VALUE rbncurs_winsdelln(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1491
|
+
return INT2NUM(winsdelln(get_window(arg1), NUM2INT(arg2)));
|
1492
|
+
}
|
1493
|
+
static VALUE rbncurs_winsertln(VALUE dummy, VALUE arg1) {
|
1494
|
+
return INT2NUM(winsertln(get_window(arg1)));
|
1495
|
+
}
|
1496
|
+
static VALUE rbncurs_winsnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1497
|
+
return INT2NUM(winsnstr(get_window(arg1), StringValuePtr(arg2), NUM2INT(arg3)));
|
1498
|
+
}
|
1499
|
+
static VALUE rbncurs_winsstr(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1500
|
+
return INT2NUM(winsstr(get_window(arg1), StringValuePtr(arg2)));
|
1501
|
+
}
|
1502
|
+
static VALUE rbncurs_wmove(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1503
|
+
return INT2NUM(wmove(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
|
1504
|
+
}
|
1505
|
+
static VALUE rbncurs_wnoutrefresh(VALUE dummy, VALUE arg1) {
|
1506
|
+
return INT2NUM(wnoutrefresh(get_window(arg1)));
|
1507
|
+
}
|
1508
|
+
static VALUE rbncurs_wredrawln(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1509
|
+
return INT2NUM(wredrawln(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
|
1510
|
+
}
|
1511
|
+
static VALUE rbncurs_wrefresh(VALUE dummy, VALUE arg1) {
|
1512
|
+
return INT2NUM(wrefresh(get_window(arg1)));
|
1513
|
+
}
|
1514
|
+
static VALUE rbncurs_wscrl(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1515
|
+
return INT2NUM(wscrl(get_window(arg1), NUM2INT(arg2)));
|
1516
|
+
}
|
1517
|
+
static VALUE rbncurs_wsetscrreg(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1518
|
+
return INT2NUM(wsetscrreg(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
|
1519
|
+
}
|
1520
|
+
static VALUE rbncurs_wstandout(VALUE dummy, VALUE arg1) {
|
1521
|
+
return INT2NUM(wstandout(get_window(arg1)));
|
1522
|
+
}
|
1523
|
+
static VALUE rbncurs_wstandend(VALUE dummy, VALUE arg1) {
|
1524
|
+
return INT2NUM(wstandend(get_window(arg1)));
|
1525
|
+
}
|
1526
|
+
static VALUE rbncurs_wsyncdown(VALUE dummy, VALUE arg1) {
|
1527
|
+
return ((wsyncdown(get_window(arg1))),Qnil);
|
1528
|
+
}
|
1529
|
+
static VALUE rbncurs_wsyncup(VALUE dummy, VALUE arg1) {
|
1530
|
+
return ((wsyncup(get_window(arg1))),Qnil);
|
1531
|
+
}
|
1532
|
+
static VALUE rbncurs_wtimeout(VALUE dummy, VALUE arg1, VALUE arg2) {
|
1533
|
+
return ((wtimeout(get_window(arg1), NUM2INT(arg2))),Qnil);
|
1534
|
+
}
|
1535
|
+
static VALUE rbncurs_wtouchln(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
|
1536
|
+
return INT2NUM(wtouchln(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4)));
|
1537
|
+
}
|
1538
|
+
static VALUE rbncurs_wvline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
|
1539
|
+
return INT2NUM(wvline(get_window(arg1), NUM2ULONG(arg2), NUM2INT(arg3)));
|
1540
|
+
}
|
1541
|
+
static VALUE rbncurs_color_content(VALUE dummy, VALUE color, VALUE r, VALUE g, VALUE b) {
|
1542
|
+
if (rb_obj_is_instance_of(r, rb_cArray) != Qtrue
|
1543
|
+
|| rb_obj_is_instance_of(g, rb_cArray) != Qtrue
|
1544
|
+
|| rb_obj_is_instance_of(b, rb_cArray) != Qtrue) {
|
1545
|
+
rb_raise(rb_eArgError,
|
1546
|
+
"r,g and b (2nd to 4th argument) must be an empty Arrays");
|
1547
|
+
return Qnil;
|
1548
|
+
}
|
1549
|
+
{
|
1550
|
+
short cv[3] = {0,0,0};
|
1551
|
+
int return_value = color_content(NUM2INT(color), &cv[0], &cv[1],
|
1552
|
+
&cv[2]);
|
1553
|
+
rb_ary_push(r, INT2NUM(cv[0])); rb_ary_push(g, INT2NUM(cv[1]));
|
1554
|
+
rb_ary_push(b, INT2NUM(cv[2])); return INT2NUM(return_value);
|
1555
|
+
}
|
1556
|
+
}
|
1557
|
+
static VALUE rbncurs_pair_content(VALUE dummy, VALUE pair, VALUE fg, VALUE bg) {
|
1558
|
+
if (rb_obj_is_instance_of(fg, rb_cArray) != Qtrue
|
1559
|
+
|| rb_obj_is_instance_of(bg, rb_cArray) != Qtrue) {
|
1560
|
+
rb_raise(rb_eArgError,
|
1561
|
+
"fg and bg (2nd and 3rd argument) must be an empty Arrays");
|
1562
|
+
return Qnil;
|
1563
|
+
}
|
1564
|
+
{
|
1565
|
+
short cn[2] = {0,0};
|
1566
|
+
int return_value = pair_content(NUM2INT(pair), &cn[0], &cn[1]);
|
1567
|
+
rb_ary_push(fg, INT2NUM(cn[0])); rb_ary_push(bg, INT2NUM(cn[1]));
|
1568
|
+
return INT2NUM(return_value);
|
1569
|
+
}
|
1570
|
+
}
|
1571
|
+
#ifdef HAVE_GETWIN
|
1572
|
+
static VALUE rbncurs_getwin(VALUE dummy, VALUE io)
|
1573
|
+
{
|
1574
|
+
int fd = dup(NUM2INT(rb_funcall(io, rb_intern("to_i"), 0)));
|
1575
|
+
FILE * f = fdopen(fd, "r");
|
1576
|
+
WINDOW * win = getwin(f);
|
1577
|
+
fclose(f);
|
1578
|
+
close(fd);
|
1579
|
+
{
|
1580
|
+
VALUE return_value = Qnil;
|
1581
|
+
if (win) return_value = wrap_window(win);
|
1582
|
+
return return_value;
|
1583
|
+
}
|
1584
|
+
}
|
1585
|
+
#endif
|
1586
|
+
#ifdef HAVE_PUTWIN
|
1587
|
+
static VALUE rbncurs_putwin(VALUE dummy, VALUE rb_win, VALUE io)
|
1588
|
+
{
|
1589
|
+
int fd = dup(NUM2INT(rb_funcall(io, rb_intern("to_i"), 0)));
|
1590
|
+
FILE * f = fdopen(fd, "w");
|
1591
|
+
WINDOW * win = get_window(rb_win);
|
1592
|
+
int return_value = putwin(win, f);
|
1593
|
+
fclose(f);
|
1594
|
+
close(fd);
|
1595
|
+
return INT2NUM(return_value);
|
1596
|
+
}
|
1597
|
+
#endif
|
1598
|
+
static VALUE rbncurs_unctrl(VALUE dummy, VALUE ch)
|
1599
|
+
{ return rb_str_new2(unctrl(NUM2ULONG(ch))); }
|
1600
|
+
static VALUE rbncurs_newterm(VALUE dummy, VALUE rb_type, VALUE rb_outfd, VALUE rb_infd)
|
1601
|
+
{
|
1602
|
+
char * type = (rb_type == Qnil) ? (char*)0 : StringValuePtr(rb_type);
|
1603
|
+
int outfd = NUM2INT(rb_funcall(rb_outfd, rb_intern("to_i"), 0));
|
1604
|
+
int infd = NUM2INT(rb_funcall(rb_infd, rb_intern("to_i"), 0));
|
1605
|
+
VALUE rb_screen =
|
1606
|
+
wrap_screen(newterm(type, fdopen(outfd, "w"), fdopen(infd, "r")));
|
1607
|
+
if (RTEST(rb_screen)) {
|
1608
|
+
Init_ncurses_full();
|
1609
|
+
rbncurshelper_halfdelay_cbreak_restore();
|
1610
|
+
}
|
1611
|
+
rb_iv_set(mNcurses, "@infd", INT2NUM(infd));
|
1612
|
+
rb_iv_set(rb_screen, "@infd", INT2NUM(infd));
|
1613
|
+
rb_iv_set(mNcurses, "@halfdelay", INT2FIX(0));
|
1614
|
+
rb_iv_set(rb_screen, "@halfdelay", INT2FIX(0));
|
1615
|
+
rb_iv_set(mNcurses, "@cbreak", Qfalse);
|
1616
|
+
rb_iv_set(rb_screen, "@cbreak", Qfalse);
|
1617
|
+
return rb_screen;
|
1618
|
+
}
|
1619
|
+
|
1620
|
+
|
1621
|
+
static void init_functions_2(void) {
|
1622
|
+
NCFUNC(addch, 1);
|
1623
|
+
NCFUNC(addchnstr, 2);
|
1624
|
+
NCFUNC(addchstr, 1);
|
1625
|
+
NCFUNC(addnstr, 2);
|
1626
|
+
NCFUNC(addstr, 1);
|
1627
|
+
NCFUNC(attroff, 1);
|
1628
|
+
NCFUNC(attron, 1);
|
1629
|
+
NCFUNC(attrset, 1);
|
1630
|
+
#if defined(NCURSES_VERSION_MAJOR) && NCURSES_VERSION_MAJOR > 4
|
1631
|
+
#ifdef HAVE_ATTR_OFF
|
1632
|
+
NCFUNC(attr_off, 2);
|
1633
|
+
#endif
|
1634
|
+
#ifdef HAVE_ATTR_ON
|
1635
|
+
NCFUNC(attr_on, 2);
|
1636
|
+
#endif
|
1637
|
+
#ifdef HAVE_ATTR_SET
|
1638
|
+
NCFUNC(attr_set, 3);
|
1639
|
+
#endif
|
1640
|
+
#if defined(HAVE_SLK_ATTR_OFF) || defined(slk_attr_off)
|
1641
|
+
NCFUNC(slk_attr_off, 2);
|
1642
|
+
#endif
|
1643
|
+
#if defined(HAVE_SLK_ATTR_ON) || defined(slk_attr_on)
|
1644
|
+
NCFUNC(slk_attr_on, 2);
|
1645
|
+
#endif
|
1646
|
+
#ifdef HAVE_SLK_ATTR_SET
|
1647
|
+
NCFUNC(slk_attr_set, 3);
|
1648
|
+
#endif
|
1649
|
+
#ifdef HAVE_WATTR_ON
|
1650
|
+
NCFUNC(wattr_on, 3);
|
1651
|
+
#endif
|
1652
|
+
#ifdef HAVE_WATTR_OFF
|
1653
|
+
NCFUNC(wattr_off, 3);
|
1654
|
+
#endif
|
1655
|
+
#ifdef HAVE_WATTR_SET
|
1656
|
+
NCFUNC(wattr_set, 4);
|
1657
|
+
#endif
|
1658
|
+
#if defined (HAVE_VID_ATTR) || defined(vid_attr)
|
1659
|
+
NCFUNC(vid_attr, 3);
|
1660
|
+
#endif
|
1661
|
+
#ifdef HAVE_ATTR_GET
|
1662
|
+
NCFUNC(attr_get, 3);
|
1663
|
+
NCFUNC(wattr_get, 4);
|
1664
|
+
#endif /* HAVE_ATTR_GET */
|
1665
|
+
#endif
|
1666
|
+
NCFUNC(baudrate, 0);
|
1667
|
+
NCFUNC(beep, 0);
|
1668
|
+
NCFUNC(bkgd, 1);
|
1669
|
+
NCFUNC(bkgdset, 1);
|
1670
|
+
NCFUNC(border, 8);
|
1671
|
+
NCFUNC(box, 3);
|
1672
|
+
rb_define_module_function(mNcurses, "can_change_color?",
|
1673
|
+
(&rbncurs_can_change_color),
|
1674
|
+
0);
|
1675
|
+
NCFUNC(cbreak, 0);
|
1676
|
+
#ifdef HAVE_CHGAT
|
1677
|
+
NCFUNC(chgat, 4);
|
1678
|
+
#endif
|
1679
|
+
NCFUNC(clear, 0);
|
1680
|
+
NCFUNC(clearok, 2);
|
1681
|
+
NCFUNC(clrtobot, 0);
|
1682
|
+
NCFUNC(clrtoeol, 0);
|
1683
|
+
#ifdef HAVE_COLOR_SET
|
1684
|
+
NCFUNC(color_set, 2);
|
1685
|
+
#endif
|
1686
|
+
NCFUNC(COLOR_PAIR, 1);
|
1687
|
+
NCFUNC(copywin, 9);
|
1688
|
+
NCFUNC(curs_set, 1);
|
1689
|
+
NCFUNC(def_prog_mode, 0);
|
1690
|
+
NCFUNC(def_shell_mode, 0);
|
1691
|
+
NCFUNC(delay_output, 1);
|
1692
|
+
NCFUNC(delch, 0);
|
1693
|
+
NCFUNC(deleteln, 0);
|
1694
|
+
NCFUNC(derwin, 5);
|
1695
|
+
NCFUNC(doupdate, 0);
|
1696
|
+
NCFUNC(dupwin, 1);
|
1697
|
+
NCFUNC(echo, 0);
|
1698
|
+
NCFUNC(echochar, 1);
|
1699
|
+
NCFUNC(endwin, 0);
|
1700
|
+
NCFUNC(erasechar, 0);
|
1701
|
+
NCFUNC(flash, 0);
|
1702
|
+
NCFUNC(flushinp, 0);
|
1703
|
+
NCFUNC(getbkgd, 1);
|
1704
|
+
NCFUNC(getch, 0);
|
1705
|
+
NCFUNC(halfdelay, 1);
|
1706
|
+
rb_define_module_function(mNcurses, "has_colors?",
|
1707
|
+
(&rbncurs_has_colors),
|
1708
|
+
0);
|
1709
|
+
rb_define_module_function(mNcurses, "has_ic?",
|
1710
|
+
(&rbncurs_has_ic),
|
1711
|
+
0);
|
1712
|
+
rb_define_module_function(mNcurses, "has_il?",
|
1713
|
+
(&rbncurs_has_il),
|
1714
|
+
0);
|
1715
|
+
NCFUNC(hline, 2);
|
1716
|
+
NCFUNC(idcok, 2);
|
1717
|
+
NCFUNC(idlok, 2);
|
1718
|
+
NCFUNC(immedok, 2);
|
1719
|
+
NCFUNC(inch, 0);
|
1720
|
+
NCFUNC(init_color, 4);
|
1721
|
+
NCFUNC(init_pair, 3);
|
1722
|
+
NCFUNC(insch, 1);
|
1723
|
+
NCFUNC(insdelln, 1);
|
1724
|
+
NCFUNC(insertln, 0);
|
1725
|
+
NCFUNC(insnstr, 2);
|
1726
|
+
NCFUNC(insstr, 1);
|
1727
|
+
#ifdef HAVE_INTRFLUSH
|
1728
|
+
NCFUNC(intrflush, 2);
|
1729
|
+
#endif
|
1730
|
+
rb_define_module_function(mNcurses, "isendwin?",
|
1731
|
+
(&rbncurs_isendwin),
|
1732
|
+
0);
|
1733
|
+
rb_define_module_function(mNcurses, "is_linetouched?",
|
1734
|
+
(&rbncurs_is_linetouched),
|
1735
|
+
2);
|
1736
|
+
rb_define_module_function(mNcurses, "is_wintouched?",
|
1737
|
+
(&rbncurs_is_wintouched),
|
1738
|
+
1);
|
1739
|
+
NCFUNC(keyname, 1);
|
1740
|
+
NCFUNC(keypad, 2);
|
1741
|
+
NCFUNC(killchar, 0);
|
1742
|
+
NCFUNC(leaveok, 2);
|
1743
|
+
NCFUNC(longname, 0);
|
1744
|
+
NCFUNC(meta, 2);
|
1745
|
+
NCFUNC(move, 2);
|
1746
|
+
NCFUNC(mvaddch, 3);
|
1747
|
+
NCFUNC(mvaddchnstr, 4);
|
1748
|
+
NCFUNC(mvaddchstr, 3);
|
1749
|
+
NCFUNC(mvaddnstr, 4);
|
1750
|
+
NCFUNC(mvaddstr, 3);
|
1751
|
+
#ifdef HAVE_MVCHGAT
|
1752
|
+
NCFUNC(mvchgat, 6);
|
1753
|
+
#endif
|
1754
|
+
NCFUNC(mvcur, 4);
|
1755
|
+
NCFUNC(mvdelch, 2);
|
1756
|
+
NCFUNC(mvderwin, 3);
|
1757
|
+
NCFUNC(mvgetch, 2);
|
1758
|
+
#ifdef HAVE_MVHLINE
|
1759
|
+
NCFUNC(mvhline, 4);
|
1760
|
+
#endif
|
1761
|
+
NCFUNC(mvinch, 2);
|
1762
|
+
NCFUNC(mvinsch, 3);
|
1763
|
+
NCFUNC(mvinsnstr, 4);
|
1764
|
+
NCFUNC(mvinsstr, 3);
|
1765
|
+
#ifdef HAVE_MVVLINE
|
1766
|
+
NCFUNC(mvvline, 4);
|
1767
|
+
#endif
|
1768
|
+
NCFUNC(mvwaddch, 4);
|
1769
|
+
NCFUNC(mvwaddchnstr, 5);
|
1770
|
+
NCFUNC(mvwaddchstr, 4);
|
1771
|
+
NCFUNC(mvwaddnstr, 5);
|
1772
|
+
NCFUNC(mvwaddstr, 4);
|
1773
|
+
#ifdef HAVE_MVWCHGAT
|
1774
|
+
NCFUNC(mvwchgat, 7);
|
1775
|
+
#endif
|
1776
|
+
NCFUNC(mvwdelch, 3);
|
1777
|
+
NCFUNC(mvwgetch, 3);
|
1778
|
+
#ifdef HAVE_MVWHLINE
|
1779
|
+
NCFUNC(mvwhline, 5);
|
1780
|
+
#endif
|
1781
|
+
NCFUNC(mvwin, 3);
|
1782
|
+
NCFUNC(mvwinch, 3);
|
1783
|
+
NCFUNC(mvwinsch, 4);
|
1784
|
+
NCFUNC(mvwinsnstr, 5);
|
1785
|
+
NCFUNC(mvwinsstr, 4);
|
1786
|
+
#ifdef HAVE_MVWVLINE
|
1787
|
+
NCFUNC(mvwvline, 5);
|
1788
|
+
#endif
|
1789
|
+
NCFUNC(napms, 1);
|
1790
|
+
NCFUNC(newpad, 2);
|
1791
|
+
NCFUNC(newwin, 4);
|
1792
|
+
NCFUNC(nl, 0);
|
1793
|
+
NCFUNC(nocbreak, 0);
|
1794
|
+
NCFUNC(nodelay, 2);
|
1795
|
+
NCFUNC(noecho, 0);
|
1796
|
+
NCFUNC(nonl, 0);
|
1797
|
+
#ifdef HAVE_NOQIFLUSH
|
1798
|
+
NCFUNC(noqiflush, 0);
|
1799
|
+
#endif
|
1800
|
+
NCFUNC(noraw, 0);
|
1801
|
+
NCFUNC(notimeout, 2);
|
1802
|
+
NCFUNC(overlay, 2);
|
1803
|
+
NCFUNC(overwrite, 2);
|
1804
|
+
NCFUNC(PAIR_NUMBER, 1);
|
1805
|
+
#ifndef __PDCURSES__ /* pdcurses' pechochar macro does not work */
|
1806
|
+
NCFUNC(pechochar, 2);
|
1807
|
+
#endif
|
1808
|
+
NCFUNC(pnoutrefresh, 7);
|
1809
|
+
NCFUNC(prefresh, 7);
|
1810
|
+
#ifdef HAVE_PUTP
|
1811
|
+
NCFUNC(putp, 1);
|
1812
|
+
#endif
|
1813
|
+
#ifdef HAVE_QIFLUSH
|
1814
|
+
NCFUNC(qiflush, 0);
|
1815
|
+
#endif
|
1816
|
+
NCFUNC(raw, 0);
|
1817
|
+
#ifndef __PDCURSES__ /* pdcurses redrawwin macro has a bug */
|
1818
|
+
NCFUNC(redrawwin, 1);
|
1819
|
+
#endif
|
1820
|
+
NCFUNC(refresh, 0);
|
1821
|
+
NCFUNC(resetty, 0);
|
1822
|
+
NCFUNC(reset_prog_mode, 0);
|
1823
|
+
NCFUNC(reset_shell_mode, 0);
|
1824
|
+
NCFUNC(savetty, 0);
|
1825
|
+
#ifdef HAVE_SCR_DUMP
|
1826
|
+
NCFUNC(scr_dump, 1);
|
1827
|
+
#endif
|
1828
|
+
#ifdef HAVE_SCR_INIT
|
1829
|
+
NCFUNC(scr_init, 1);
|
1830
|
+
#endif
|
1831
|
+
NCFUNC(scrl, 1);
|
1832
|
+
NCFUNC(scroll, 1);
|
1833
|
+
NCFUNC(scrollok, 2);
|
1834
|
+
#ifdef HAVE_SCR_RESTORE
|
1835
|
+
NCFUNC(scr_restore, 1);
|
1836
|
+
#endif
|
1837
|
+
#ifdef HAVE_SCR_SET
|
1838
|
+
NCFUNC(scr_set, 1);
|
1839
|
+
#endif
|
1840
|
+
NCFUNC(setscrreg, 2);
|
1841
|
+
NCFUNC(set_term, 1);
|
1842
|
+
NCFUNC(slk_attroff, 1);
|
1843
|
+
NCFUNC(slk_attron, 1);
|
1844
|
+
NCFUNC(slk_attrset, 1);
|
1845
|
+
#ifdef HAVE_SLK_ATTR
|
1846
|
+
NCFUNC(slk_attr, 0);
|
1847
|
+
#endif
|
1848
|
+
NCFUNC(slk_clear, 0);
|
1849
|
+
#ifdef HAVE_SLK_COLOR
|
1850
|
+
NCFUNC(slk_color, 1);
|
1851
|
+
#endif
|
1852
|
+
NCFUNC(slk_label, 1);
|
1853
|
+
NCFUNC(slk_noutrefresh, 0);
|
1854
|
+
NCFUNC(slk_refresh, 0);
|
1855
|
+
NCFUNC(slk_restore, 0);
|
1856
|
+
NCFUNC(slk_set, 3);
|
1857
|
+
NCFUNC(slk_touch, 0);
|
1858
|
+
NCFUNC(standout, 0);
|
1859
|
+
NCFUNC(standend, 0);
|
1860
|
+
NCFUNC(start_color, 0);
|
1861
|
+
NCFUNC(subpad, 5);
|
1862
|
+
NCFUNC(subwin, 5);
|
1863
|
+
NCFUNC(syncok, 2);
|
1864
|
+
NCFUNC(termattrs, 0);
|
1865
|
+
NCFUNC(termname, 0);
|
1866
|
+
#ifdef HAVE_TIGETFLAG
|
1867
|
+
NCFUNC(tigetflag, 1);
|
1868
|
+
#endif
|
1869
|
+
#ifdef HAVE_TIGETNUM
|
1870
|
+
NCFUNC(tigetnum, 1);
|
1871
|
+
#endif
|
1872
|
+
#ifdef HAVE_TIGETSTR
|
1873
|
+
NCFUNC(tigetstr, 1);
|
1874
|
+
#endif
|
1875
|
+
NCFUNC(timeout, 1);
|
1876
|
+
NCFUNC(typeahead, 1);
|
1877
|
+
NCFUNC(ungetch, 1);
|
1878
|
+
NCFUNC(untouchwin, 1);
|
1879
|
+
#ifdef HAVE_VIDATTR
|
1880
|
+
NCFUNC(vidattr, 1);
|
1881
|
+
#endif
|
1882
|
+
NCFUNC(vline, 2);
|
1883
|
+
NCFUNC(waddch, 2);
|
1884
|
+
NCFUNC(waddchnstr, 3);
|
1885
|
+
NCFUNC(waddchstr, 2);
|
1886
|
+
NCFUNC(waddnstr, 3);
|
1887
|
+
NCFUNC(waddstr, 2);
|
1888
|
+
NCFUNC(wattron, 2);
|
1889
|
+
NCFUNC(wattroff, 2);
|
1890
|
+
NCFUNC(wattrset, 2);
|
1891
|
+
NCFUNC(wbkgd, 2);
|
1892
|
+
NCFUNC(wbkgdset, 2);
|
1893
|
+
NCFUNC(wborder, 9);
|
1894
|
+
#ifdef HAVE_WCHGAT
|
1895
|
+
NCFUNC(wchgat, 5);
|
1896
|
+
#endif
|
1897
|
+
NCFUNC(wclear, 1);
|
1898
|
+
NCFUNC(wclrtobot, 1);
|
1899
|
+
NCFUNC(wclrtoeol, 1);
|
1900
|
+
#ifdef HAVE_WCOLOR_SET
|
1901
|
+
NCFUNC(wcolor_set, 3);
|
1902
|
+
#endif
|
1903
|
+
NCFUNC(wcursyncup, 1);
|
1904
|
+
NCFUNC(wdelch, 1);
|
1905
|
+
NCFUNC(wdeleteln, 1);
|
1906
|
+
NCFUNC(wechochar, 2);
|
1907
|
+
NCFUNC(werase, 1);
|
1908
|
+
NCFUNC(wgetch, 1);
|
1909
|
+
NCFUNC(whline, 3);
|
1910
|
+
NCFUNC(winch, 1);
|
1911
|
+
NCFUNC(winsch, 2);
|
1912
|
+
NCFUNC(winsdelln, 2);
|
1913
|
+
NCFUNC(winsertln, 1);
|
1914
|
+
NCFUNC(winsnstr, 3);
|
1915
|
+
NCFUNC(winsstr, 2);
|
1916
|
+
NCFUNC(wmove, 3);
|
1917
|
+
NCFUNC(wnoutrefresh, 1);
|
1918
|
+
NCFUNC(wredrawln, 3);
|
1919
|
+
NCFUNC(wrefresh, 1);
|
1920
|
+
NCFUNC(wscrl, 2);
|
1921
|
+
NCFUNC(wsetscrreg, 3);
|
1922
|
+
NCFUNC(wstandout, 1);
|
1923
|
+
NCFUNC(wstandend, 1);
|
1924
|
+
NCFUNC(wsyncdown, 1);
|
1925
|
+
NCFUNC(wsyncup, 1);
|
1926
|
+
NCFUNC(wtimeout, 2);
|
1927
|
+
NCFUNC(wtouchln, 4);
|
1928
|
+
NCFUNC(wvline, 3);
|
1929
|
+
NCFUNC(color_content, 4);
|
1930
|
+
NCFUNC(pair_content, 3);
|
1931
|
+
NCFUNC(pair_content, 3);
|
1932
|
+
#ifdef HAVE_GETWIN
|
1933
|
+
NCFUNC(getwin, 1);
|
1934
|
+
#endif
|
1935
|
+
#ifdef HAVE_PUTWIN
|
1936
|
+
NCFUNC(putwin, 2);
|
1937
|
+
#endif
|
1938
|
+
NCFUNC(unctrl, 1);
|
1939
|
+
}
|
1940
|
+
|
1941
|
+
|
1942
|
+
static void init_constants_3(void) {
|
1943
|
+
/* #define NCURSES_BITS(mask,shift) ((mask) << ((shift) + 8)) */
|
1944
|
+
|
1945
|
+
/* attributes */
|
1946
|
+
|
1947
|
+
rb_define_const(mNcurses, "A_NORMAL", INT2NUM(A_NORMAL));
|
1948
|
+
rb_define_const(mNcurses, "A_ATTRIBUTES", INT2NUM(A_ATTRIBUTES));
|
1949
|
+
rb_define_const(mNcurses, "A_CHARTEXT", INT2NUM(A_CHARTEXT));
|
1950
|
+
rb_define_const(mNcurses, "A_COLOR", INT2NUM(A_COLOR));
|
1951
|
+
rb_define_const(mNcurses, "A_STANDOUT", INT2NUM(A_STANDOUT));
|
1952
|
+
rb_define_const(mNcurses, "A_UNDERLINE", INT2NUM(A_UNDERLINE));
|
1953
|
+
rb_define_const(mNcurses, "A_REVERSE", INT2NUM(A_REVERSE));
|
1954
|
+
rb_define_const(mNcurses, "A_BLINK", INT2NUM(A_BLINK));
|
1955
|
+
rb_define_const(mNcurses, "A_DIM", INT2NUM(A_DIM));
|
1956
|
+
rb_define_const(mNcurses, "A_BOLD", INT2NUM(A_BOLD));
|
1957
|
+
rb_define_const(mNcurses, "A_ALTCHARSET", INT2NUM(A_ALTCHARSET));
|
1958
|
+
rb_define_const(mNcurses, "A_INVIS", INT2NUM(A_INVIS));
|
1959
|
+
|
1960
|
+
/* Tradeoff on 32-bit machines ('protect' vs widec). The others (e.g., left
|
1961
|
+
* highlight are not implemented in any terminal descriptions, anyway.
|
1962
|
+
*/
|
1963
|
+
rb_define_const(mNcurses, "A_PROTECT", INT2NUM(A_PROTECT));
|
1964
|
+
#ifdef A_HORIZONTAL
|
1965
|
+
rb_define_const(mNcurses, "A_HORIZONTAL", INT2NUM(A_HORIZONTAL));
|
1966
|
+
#endif
|
1967
|
+
#ifdef A_LEFT
|
1968
|
+
rb_define_const(mNcurses, "A_LEFT", INT2NUM(A_LEFT));
|
1969
|
+
#endif
|
1970
|
+
#ifdef A_LOW
|
1971
|
+
rb_define_const(mNcurses, "A_LOW", INT2NUM(A_LOW));
|
1972
|
+
#endif
|
1973
|
+
#ifdef A_RIGHT
|
1974
|
+
rb_define_const(mNcurses, "A_RIGHT", INT2NUM(A_RIGHT));
|
1975
|
+
#endif
|
1976
|
+
#ifdef A_TOP
|
1977
|
+
rb_define_const(mNcurses, "A_TOP", INT2NUM(A_TOP));
|
1978
|
+
#endif
|
1979
|
+
#ifdef A_VERTICAL
|
1980
|
+
rb_define_const(mNcurses, "A_VERTICAL", INT2NUM(A_VERTICAL));
|
1981
|
+
#endif
|
1982
|
+
|
1983
|
+
/* Pseudo-character tokens outside ASCII range. The curses wgetch()
|
1984
|
+
* function will return any given one of these only if the corresponding
|
1985
|
+
* k- capability is defined in your terminal's terminfo entry. */
|
1986
|
+
#ifdef KEY_CODE_YES
|
1987
|
+
rb_define_const(mNcurses, "KEY_CODE_YES", INT2NUM(KEY_CODE_YES));
|
1988
|
+
#endif
|
1989
|
+
rb_define_const(mNcurses, "KEY_MIN", INT2NUM(KEY_MIN));
|
1990
|
+
rb_define_const(mNcurses, "KEY_BREAK", INT2NUM(KEY_BREAK));
|
1991
|
+
rb_define_const(mNcurses, "KEY_DOWN", INT2NUM(KEY_DOWN));
|
1992
|
+
rb_define_const(mNcurses, "KEY_UP", INT2NUM(KEY_UP));
|
1993
|
+
rb_define_const(mNcurses, "KEY_LEFT", INT2NUM(KEY_LEFT));
|
1994
|
+
rb_define_const(mNcurses, "KEY_RIGHT", INT2NUM(KEY_RIGHT));
|
1995
|
+
rb_define_const(mNcurses, "KEY_HOME", INT2NUM(KEY_HOME));
|
1996
|
+
rb_define_const(mNcurses, "KEY_BACKSPACE", INT2NUM(KEY_BACKSPACE));
|
1997
|
+
rb_define_const(mNcurses, "KEY_F0", INT2NUM(KEY_F(0)));
|
1998
|
+
rb_define_const(mNcurses, "KEY_F1", INT2NUM(KEY_F(1)));
|
1999
|
+
rb_define_const(mNcurses, "KEY_F2", INT2NUM(KEY_F(2)));
|
2000
|
+
rb_define_const(mNcurses, "KEY_F3", INT2NUM(KEY_F(3)));
|
2001
|
+
rb_define_const(mNcurses, "KEY_F4", INT2NUM(KEY_F(4)));
|
2002
|
+
rb_define_const(mNcurses, "KEY_F5", INT2NUM(KEY_F(5)));
|
2003
|
+
rb_define_const(mNcurses, "KEY_F6", INT2NUM(KEY_F(6)));
|
2004
|
+
rb_define_const(mNcurses, "KEY_F7", INT2NUM(KEY_F(7)));
|
2005
|
+
rb_define_const(mNcurses, "KEY_F8", INT2NUM(KEY_F(8)));
|
2006
|
+
rb_define_const(mNcurses, "KEY_F9", INT2NUM(KEY_F(9)));
|
2007
|
+
rb_define_const(mNcurses, "KEY_F10", INT2NUM(KEY_F(10)));
|
2008
|
+
rb_define_const(mNcurses, "KEY_F11", INT2NUM(KEY_F(11)));
|
2009
|
+
rb_define_const(mNcurses, "KEY_F12", INT2NUM(KEY_F(12)));
|
2010
|
+
rb_define_const(mNcurses, "KEY_F13", INT2NUM(KEY_F(13)));
|
2011
|
+
rb_define_const(mNcurses, "KEY_F14", INT2NUM(KEY_F(14)));
|
2012
|
+
rb_define_const(mNcurses, "KEY_F15", INT2NUM(KEY_F(15)));
|
2013
|
+
rb_define_const(mNcurses, "KEY_F16", INT2NUM(KEY_F(16)));
|
2014
|
+
rb_define_const(mNcurses, "KEY_F17", INT2NUM(KEY_F(17)));
|
2015
|
+
rb_define_const(mNcurses, "KEY_F18", INT2NUM(KEY_F(18)));
|
2016
|
+
rb_define_const(mNcurses, "KEY_F19", INT2NUM(KEY_F(19)));
|
2017
|
+
rb_define_const(mNcurses, "KEY_F20", INT2NUM(KEY_F(20)));
|
2018
|
+
rb_define_const(mNcurses, "KEY_F21", INT2NUM(KEY_F(21)));
|
2019
|
+
rb_define_const(mNcurses, "KEY_F22", INT2NUM(KEY_F(22)));
|
2020
|
+
rb_define_const(mNcurses, "KEY_F23", INT2NUM(KEY_F(23)));
|
2021
|
+
rb_define_const(mNcurses, "KEY_F24", INT2NUM(KEY_F(24)));
|
2022
|
+
rb_define_const(mNcurses, "KEY_F25", INT2NUM(KEY_F(25)));
|
2023
|
+
rb_define_const(mNcurses, "KEY_F26", INT2NUM(KEY_F(26)));
|
2024
|
+
rb_define_const(mNcurses, "KEY_F27", INT2NUM(KEY_F(27)));
|
2025
|
+
rb_define_const(mNcurses, "KEY_F28", INT2NUM(KEY_F(28)));
|
2026
|
+
rb_define_const(mNcurses, "KEY_F29", INT2NUM(KEY_F(29)));
|
2027
|
+
rb_define_const(mNcurses, "KEY_F30", INT2NUM(KEY_F(30)));
|
2028
|
+
rb_define_const(mNcurses, "KEY_DL", INT2NUM(KEY_DL));
|
2029
|
+
rb_define_const(mNcurses, "KEY_IL", INT2NUM(KEY_IL));
|
2030
|
+
rb_define_const(mNcurses, "KEY_DC", INT2NUM(KEY_DC));
|
2031
|
+
rb_define_const(mNcurses, "KEY_IC", INT2NUM(KEY_IC));
|
2032
|
+
rb_define_const(mNcurses, "KEY_EIC", INT2NUM(KEY_EIC));
|
2033
|
+
rb_define_const(mNcurses, "KEY_CLEAR", INT2NUM(KEY_CLEAR));
|
2034
|
+
rb_define_const(mNcurses, "KEY_EOS", INT2NUM(KEY_EOS));
|
2035
|
+
rb_define_const(mNcurses, "KEY_EOL", INT2NUM(KEY_EOL));
|
2036
|
+
rb_define_const(mNcurses, "KEY_SF", INT2NUM(KEY_SF));
|
2037
|
+
rb_define_const(mNcurses, "KEY_SR", INT2NUM(KEY_SR));
|
2038
|
+
rb_define_const(mNcurses, "KEY_NPAGE", INT2NUM(KEY_NPAGE));
|
2039
|
+
rb_define_const(mNcurses, "KEY_PPAGE", INT2NUM(KEY_PPAGE));
|
2040
|
+
rb_define_const(mNcurses, "KEY_STAB", INT2NUM(KEY_STAB));
|
2041
|
+
rb_define_const(mNcurses, "KEY_CTAB", INT2NUM(KEY_CTAB));
|
2042
|
+
rb_define_const(mNcurses, "KEY_CATAB", INT2NUM(KEY_CATAB));
|
2043
|
+
rb_define_const(mNcurses, "KEY_ENTER", INT2NUM(KEY_ENTER));
|
2044
|
+
rb_define_const(mNcurses, "KEY_SRESET", INT2NUM(KEY_SRESET));
|
2045
|
+
rb_define_const(mNcurses, "KEY_RESET", INT2NUM(KEY_RESET));
|
2046
|
+
rb_define_const(mNcurses, "KEY_PRINT", INT2NUM(KEY_PRINT));
|
2047
|
+
rb_define_const(mNcurses, "KEY_LL", INT2NUM(KEY_LL));
|
2048
|
+
|
2049
|
+
/* The keypad is arranged like this: */
|
2050
|
+
/* a1 up a3 */
|
2051
|
+
/* left b2 right */
|
2052
|
+
/* c1 down c3 */
|
2053
|
+
|
2054
|
+
rb_define_const(mNcurses, "KEY_A1", INT2NUM(KEY_A1));
|
2055
|
+
rb_define_const(mNcurses, "KEY_A3", INT2NUM(KEY_A3));
|
2056
|
+
rb_define_const(mNcurses, "KEY_B2", INT2NUM(KEY_B2));
|
2057
|
+
rb_define_const(mNcurses, "KEY_C1", INT2NUM(KEY_C1));
|
2058
|
+
rb_define_const(mNcurses, "KEY_C3", INT2NUM(KEY_C3));
|
2059
|
+
rb_define_const(mNcurses, "KEY_BTAB", INT2NUM(KEY_BTAB));
|
2060
|
+
rb_define_const(mNcurses, "KEY_BEG", INT2NUM(KEY_BEG));
|
2061
|
+
rb_define_const(mNcurses, "KEY_CANCEL", INT2NUM(KEY_CANCEL));
|
2062
|
+
rb_define_const(mNcurses, "KEY_CLOSE", INT2NUM(KEY_CLOSE));
|
2063
|
+
rb_define_const(mNcurses, "KEY_COMMAND", INT2NUM(KEY_COMMAND));
|
2064
|
+
rb_define_const(mNcurses, "KEY_COPY", INT2NUM(KEY_COPY));
|
2065
|
+
rb_define_const(mNcurses, "KEY_CREATE", INT2NUM(KEY_CREATE));
|
2066
|
+
rb_define_const(mNcurses, "KEY_END", INT2NUM(KEY_END));
|
2067
|
+
rb_define_const(mNcurses, "KEY_EXIT", INT2NUM(KEY_EXIT));
|
2068
|
+
rb_define_const(mNcurses, "KEY_FIND", INT2NUM(KEY_FIND));
|
2069
|
+
rb_define_const(mNcurses, "KEY_HELP", INT2NUM(KEY_HELP));
|
2070
|
+
rb_define_const(mNcurses, "KEY_MARK", INT2NUM(KEY_MARK));
|
2071
|
+
rb_define_const(mNcurses, "KEY_MESSAGE", INT2NUM(KEY_MESSAGE));
|
2072
|
+
rb_define_const(mNcurses, "KEY_MOVE", INT2NUM(KEY_MOVE));
|
2073
|
+
rb_define_const(mNcurses, "KEY_NEXT", INT2NUM(KEY_NEXT));
|
2074
|
+
rb_define_const(mNcurses, "KEY_OPEN", INT2NUM(KEY_OPEN));
|
2075
|
+
rb_define_const(mNcurses, "KEY_OPTIONS", INT2NUM(KEY_OPTIONS));
|
2076
|
+
rb_define_const(mNcurses, "KEY_PREVIOUS", INT2NUM(KEY_PREVIOUS));
|
2077
|
+
rb_define_const(mNcurses, "KEY_REDO", INT2NUM(KEY_REDO));
|
2078
|
+
rb_define_const(mNcurses, "KEY_REFERENCE", INT2NUM(KEY_REFERENCE));
|
2079
|
+
rb_define_const(mNcurses, "KEY_REFRESH", INT2NUM(KEY_REFRESH));
|
2080
|
+
rb_define_const(mNcurses, "KEY_REPLACE", INT2NUM(KEY_REPLACE));
|
2081
|
+
rb_define_const(mNcurses, "KEY_RESTART", INT2NUM(KEY_RESTART));
|
2082
|
+
rb_define_const(mNcurses, "KEY_RESUME", INT2NUM(KEY_RESUME));
|
2083
|
+
rb_define_const(mNcurses, "KEY_SAVE", INT2NUM(KEY_SAVE));
|
2084
|
+
rb_define_const(mNcurses, "KEY_SBEG", INT2NUM(KEY_SBEG));
|
2085
|
+
rb_define_const(mNcurses, "KEY_SCANCEL", INT2NUM(KEY_SCANCEL));
|
2086
|
+
rb_define_const(mNcurses, "KEY_SCOMMAND", INT2NUM(KEY_SCOMMAND));
|
2087
|
+
rb_define_const(mNcurses, "KEY_SCOPY", INT2NUM(KEY_SCOPY));
|
2088
|
+
rb_define_const(mNcurses, "KEY_SCREATE", INT2NUM(KEY_SCREATE));
|
2089
|
+
rb_define_const(mNcurses, "KEY_SDC", INT2NUM(KEY_SDC));
|
2090
|
+
rb_define_const(mNcurses, "KEY_SDL", INT2NUM(KEY_SDL));
|
2091
|
+
rb_define_const(mNcurses, "KEY_SELECT", INT2NUM(KEY_SELECT));
|
2092
|
+
rb_define_const(mNcurses, "KEY_SEND", INT2NUM(KEY_SEND));
|
2093
|
+
rb_define_const(mNcurses, "KEY_SEOL", INT2NUM(KEY_SEOL));
|
2094
|
+
rb_define_const(mNcurses, "KEY_SEXIT", INT2NUM(KEY_SEXIT));
|
2095
|
+
rb_define_const(mNcurses, "KEY_SFIND", INT2NUM(KEY_SFIND));
|
2096
|
+
rb_define_const(mNcurses, "KEY_SHELP", INT2NUM(KEY_SHELP));
|
2097
|
+
rb_define_const(mNcurses, "KEY_SHOME", INT2NUM(KEY_SHOME));
|
2098
|
+
rb_define_const(mNcurses, "KEY_SIC", INT2NUM(KEY_SIC));
|
2099
|
+
rb_define_const(mNcurses, "KEY_SLEFT", INT2NUM(KEY_SLEFT));
|
2100
|
+
rb_define_const(mNcurses, "KEY_SMESSAGE", INT2NUM(KEY_SMESSAGE));
|
2101
|
+
rb_define_const(mNcurses, "KEY_SMOVE", INT2NUM(KEY_SMOVE));
|
2102
|
+
rb_define_const(mNcurses, "KEY_SNEXT", INT2NUM(KEY_SNEXT));
|
2103
|
+
rb_define_const(mNcurses, "KEY_SOPTIONS", INT2NUM(KEY_SOPTIONS));
|
2104
|
+
rb_define_const(mNcurses, "KEY_SPREVIOUS", INT2NUM(KEY_SPREVIOUS));
|
2105
|
+
rb_define_const(mNcurses, "KEY_SPRINT", INT2NUM(KEY_SPRINT));
|
2106
|
+
rb_define_const(mNcurses, "KEY_SREDO", INT2NUM(KEY_SREDO));
|
2107
|
+
rb_define_const(mNcurses, "KEY_SREPLACE", INT2NUM(KEY_SREPLACE));
|
2108
|
+
rb_define_const(mNcurses, "KEY_SRIGHT", INT2NUM(KEY_SRIGHT));
|
2109
|
+
rb_define_const(mNcurses, "KEY_SRSUME", INT2NUM(KEY_SRSUME));
|
2110
|
+
rb_define_const(mNcurses, "KEY_SSAVE", INT2NUM(KEY_SSAVE));
|
2111
|
+
rb_define_const(mNcurses, "KEY_SSUSPEND", INT2NUM(KEY_SSUSPEND));
|
2112
|
+
rb_define_const(mNcurses, "KEY_SUNDO", INT2NUM(KEY_SUNDO));
|
2113
|
+
rb_define_const(mNcurses, "KEY_SUSPEND", INT2NUM(KEY_SUSPEND));
|
2114
|
+
rb_define_const(mNcurses, "KEY_UNDO", INT2NUM(KEY_UNDO));
|
2115
|
+
rb_define_const(mNcurses, "KEY_MOUSE", INT2NUM(KEY_MOUSE));
|
2116
|
+
rb_define_const(mNcurses, "KEY_RESIZE", INT2NUM(KEY_RESIZE));
|
2117
|
+
rb_define_const(mNcurses, "KEY_MAX", INT2NUM(KEY_MAX));
|
2118
|
+
|
2119
|
+
/* mouse interface */
|
2120
|
+
/* #define NCURSES_MOUSE_VERSION 1 */
|
2121
|
+
|
2122
|
+
/* event masks */
|
2123
|
+
rb_define_const(mNcurses, "BUTTON1_RELEASED", INT2NUM(BUTTON1_RELEASED));
|
2124
|
+
rb_define_const(mNcurses, "BUTTON1_PRESSED", INT2NUM(BUTTON1_PRESSED));
|
2125
|
+
rb_define_const(mNcurses, "BUTTON1_CLICKED", INT2NUM(BUTTON1_CLICKED));
|
2126
|
+
rb_define_const(mNcurses, "BUTTON1_DOUBLE_CLICKED", INT2NUM(BUTTON1_DOUBLE_CLICKED));
|
2127
|
+
rb_define_const(mNcurses, "BUTTON1_TRIPLE_CLICKED", INT2NUM(BUTTON1_TRIPLE_CLICKED));
|
2128
|
+
#ifdef BUTTON1_RESERVED_EVENT
|
2129
|
+
rb_define_const(mNcurses, "BUTTON1_RESERVED_EVENT", INT2NUM(BUTTON1_RESERVED_EVENT));
|
2130
|
+
#endif
|
2131
|
+
rb_define_const(mNcurses, "BUTTON2_RELEASED", INT2NUM(BUTTON2_RELEASED));
|
2132
|
+
rb_define_const(mNcurses, "BUTTON2_PRESSED", INT2NUM(BUTTON2_PRESSED));
|
2133
|
+
rb_define_const(mNcurses, "BUTTON2_CLICKED", INT2NUM(BUTTON2_CLICKED));
|
2134
|
+
rb_define_const(mNcurses, "BUTTON2_DOUBLE_CLICKED", INT2NUM(BUTTON2_DOUBLE_CLICKED));
|
2135
|
+
rb_define_const(mNcurses, "BUTTON2_TRIPLE_CLICKED", INT2NUM(BUTTON2_TRIPLE_CLICKED));
|
2136
|
+
#ifdef BUTTON2_RESERVED_EVENT
|
2137
|
+
rb_define_const(mNcurses, "BUTTON2_RESERVED_EVENT", INT2NUM(BUTTON2_RESERVED_EVENT));
|
2138
|
+
#endif
|
2139
|
+
rb_define_const(mNcurses, "BUTTON3_RELEASED", INT2NUM(BUTTON3_RELEASED));
|
2140
|
+
rb_define_const(mNcurses, "BUTTON3_PRESSED", INT2NUM(BUTTON3_PRESSED));
|
2141
|
+
rb_define_const(mNcurses, "BUTTON3_CLICKED", INT2NUM(BUTTON3_CLICKED));
|
2142
|
+
rb_define_const(mNcurses, "BUTTON3_DOUBLE_CLICKED", INT2NUM(BUTTON3_DOUBLE_CLICKED));
|
2143
|
+
rb_define_const(mNcurses, "BUTTON3_TRIPLE_CLICKED", INT2NUM(BUTTON3_TRIPLE_CLICKED));
|
2144
|
+
#ifdef BUTTON3_RESERVED_EVENT
|
2145
|
+
rb_define_const(mNcurses, "BUTTON3_RESERVED_EVENT", INT2NUM(BUTTON3_RESERVED_EVENT));
|
2146
|
+
#endif
|
2147
|
+
#ifdef BUTTON4_RELEASED
|
2148
|
+
rb_define_const(mNcurses, "BUTTON4_RELEASED", INT2NUM(BUTTON4_RELEASED));
|
2149
|
+
#endif
|
2150
|
+
#ifdef BUTTON4_PRESSED
|
2151
|
+
rb_define_const(mNcurses, "BUTTON4_PRESSED", INT2NUM(BUTTON4_PRESSED));
|
2152
|
+
#endif
|
2153
|
+
#ifdef BUTTON4_CLICKED
|
2154
|
+
rb_define_const(mNcurses, "BUTTON4_CLICKED", INT2NUM(BUTTON4_CLICKED));
|
2155
|
+
#endif
|
2156
|
+
#ifdef BUTTON4_DOUBLE_CLICKED
|
2157
|
+
rb_define_const(mNcurses, "BUTTON4_DOUBLE_CLICKED", INT2NUM(BUTTON4_DOUBLE_CLICKED));
|
2158
|
+
#endif
|
2159
|
+
#ifdef BUTTON4_TRIPLE_CLICKED
|
2160
|
+
rb_define_const(mNcurses, "BUTTON4_TRIPLE_CLICKED", INT2NUM(BUTTON4_TRIPLE_CLICKED));
|
2161
|
+
#endif
|
2162
|
+
#ifdef BUTTON4_RESERVED_EVENT
|
2163
|
+
rb_define_const(mNcurses, "BUTTON4_RESERVED_EVENT", INT2NUM(BUTTON4_RESERVED_EVENT));
|
2164
|
+
#endif
|
2165
|
+
#ifdef BUTTON_CTRL
|
2166
|
+
rb_define_const(mNcurses, "BUTTON_CTRL", INT2NUM(BUTTON_CTRL));
|
2167
|
+
#endif
|
2168
|
+
#ifdef BUTTON_CONTROL
|
2169
|
+
rb_define_const(mNcurses, "BUTTON_CTRL", INT2NUM(BUTTON_CONTROL));
|
2170
|
+
#endif
|
2171
|
+
rb_define_const(mNcurses, "BUTTON_SHIFT", INT2NUM(BUTTON_SHIFT));
|
2172
|
+
rb_define_const(mNcurses, "BUTTON_ALT", INT2NUM(BUTTON_ALT));
|
2173
|
+
rb_define_const(mNcurses, "ALL_MOUSE_EVENTS", INT2NUM(ALL_MOUSE_EVENTS));
|
2174
|
+
rb_define_const(mNcurses, "REPORT_MOUSE_POSITION", INT2NUM(REPORT_MOUSE_POSITION));
|
2175
|
+
}
|
2176
|
+
|
2177
|
+
/* typedef struct */
|
2178
|
+
/* { */
|
2179
|
+
/* short id; */ /* ID to distinguish multiple devices */
|
2180
|
+
/* int x, y, z; */ /* event coordinates (character-cell) */
|
2181
|
+
/* mmask_t bstate; *//* button state bits */
|
2182
|
+
/* } */
|
2183
|
+
/* MEVENT; */
|
2184
|
+
#ifdef HAVE_UNGETMOUSE
|
2185
|
+
static VALUE rbncurs_getmouse(VALUE dummy, VALUE rb_m)
|
2186
|
+
{
|
2187
|
+
MEVENT m;
|
2188
|
+
int return_value = getmouse(&m);
|
2189
|
+
if (return_value != ERR) {
|
2190
|
+
rb_iv_set(rb_m, "@id", INT2NUM(m.id));
|
2191
|
+
rb_iv_set(rb_m, "@x", INT2NUM(m.x));
|
2192
|
+
rb_iv_set(rb_m, "@y", INT2NUM(m.y));
|
2193
|
+
rb_iv_set(rb_m, "@z", INT2NUM(m.z));
|
2194
|
+
rb_iv_set(rb_m, "@bstate", INT2NUM(m.bstate));
|
2195
|
+
}
|
2196
|
+
return INT2NUM(return_value);
|
2197
|
+
}
|
2198
|
+
static VALUE rbncurs_ungetmouse(VALUE dummy, VALUE rb_m)
|
2199
|
+
{
|
2200
|
+
MEVENT m;
|
2201
|
+
m.id = NUM2INT(rb_iv_get(rb_m, "@id"));
|
2202
|
+
m.x = NUM2INT(rb_iv_get(rb_m, "@x"));
|
2203
|
+
m.y = NUM2INT(rb_iv_get(rb_m, "@y"));
|
2204
|
+
m.z = NUM2INT(rb_iv_get(rb_m, "@z"));
|
2205
|
+
m.bstate = NUM2ULONG(rb_iv_get(rb_m, "@bstate"));
|
2206
|
+
return INT2NUM(ungetmouse(&m));
|
2207
|
+
}
|
2208
|
+
#endif
|
2209
|
+
#ifdef HAVE_MOUSEMASK
|
2210
|
+
static VALUE rbncurs_mousemask(VALUE dummy, VALUE rb_newmask, VALUE rb_oldmask)
|
2211
|
+
{
|
2212
|
+
if (rb_obj_is_instance_of(rb_oldmask, rb_cArray) != Qtrue) {
|
2213
|
+
rb_raise(rb_eArgError,
|
2214
|
+
"oldmask (2nd argument) must be an empty Array");
|
2215
|
+
return Qnil;
|
2216
|
+
}
|
2217
|
+
{
|
2218
|
+
mmask_t oldmask, return_value;
|
2219
|
+
return_value = mousemask(NUM2ULONG(rb_newmask), &oldmask);
|
2220
|
+
rb_ary_push(rb_oldmask, INT2NUM(oldmask));
|
2221
|
+
return INT2NUM(return_value);
|
2222
|
+
}
|
2223
|
+
}
|
2224
|
+
#endif
|
2225
|
+
#ifdef HAVE_WENCLOSE
|
2226
|
+
static VALUE rbncurs_wenclose(VALUE dummy, VALUE rb_win, VALUE rb_y, VALUE rb_x)
|
2227
|
+
{
|
2228
|
+
return wenclose(get_window(rb_win), NUM2INT(rb_y), NUM2INT(rb_y))
|
2229
|
+
? Qtrue : Qfalse;
|
2230
|
+
}
|
2231
|
+
#endif
|
2232
|
+
#ifdef HAVE_MOUSEINTERVAL
|
2233
|
+
static VALUE rbncurs_mouseinterval(VALUE dummy, VALUE rb_interval)
|
2234
|
+
{ return INT2NUM(mouseinterval(NUM2INT(rb_interval))); }
|
2235
|
+
#endif
|
2236
|
+
#ifdef HAVE_WMOUSE_TRAFO
|
2237
|
+
static VALUE rbncurs_wmouse_trafo(VALUE dummy, VALUE rb_win, VALUE rb_pY, VALUE rb_pX,
|
2238
|
+
VALUE rb_to_screen)
|
2239
|
+
{
|
2240
|
+
if ((rb_obj_is_instance_of(rb_pY, rb_cArray) != Qtrue)
|
2241
|
+
|| (rb_obj_is_instance_of(rb_pY, rb_cArray) != Qtrue)) {
|
2242
|
+
rb_raise(rb_eArgError,
|
2243
|
+
"pY and pX arguments must be Arrays, containing exactly one "
|
2244
|
+
"Integer");
|
2245
|
+
return Qnil;
|
2246
|
+
}
|
2247
|
+
{
|
2248
|
+
int X = NUM2INT(rb_ary_pop(rb_pX));
|
2249
|
+
int Y = NUM2INT(rb_ary_pop(rb_pY));
|
2250
|
+
bool return_value =
|
2251
|
+
wmouse_trafo(get_window(rb_win), &Y, &X, RTEST(rb_to_screen));
|
2252
|
+
rb_ary_push(rb_pY, INT2NUM(Y)); rb_ary_push(rb_pX, INT2NUM(X));
|
2253
|
+
return return_value ? Qtrue : Qfalse;
|
2254
|
+
}
|
2255
|
+
}
|
2256
|
+
#endif
|
2257
|
+
#ifdef HAVE_MCPRINT
|
2258
|
+
static VALUE rbncurs_mcprint(VALUE dummy, VALUE data, VALUE len)
|
2259
|
+
{
|
2260
|
+
return INT2NUM(mcprint(StringValuePtr(data), NUM2INT(len)));
|
2261
|
+
}
|
2262
|
+
#endif
|
2263
|
+
#ifdef HAVE_HAS_KEY
|
2264
|
+
static VALUE rbncurs_has_key(VALUE dummy, VALUE ch)
|
2265
|
+
{return INT2NUM(has_key(NUM2INT(ch)));}
|
2266
|
+
#endif
|
2267
|
+
static VALUE rbncurs_getyx(VALUE dummy, VALUE rb_win, VALUE rb_y, VALUE rb_x)
|
2268
|
+
{
|
2269
|
+
if ((rb_obj_is_instance_of(rb_y, rb_cArray) != Qtrue)
|
2270
|
+
|| (rb_obj_is_instance_of(rb_x, rb_cArray) != Qtrue)) {
|
2271
|
+
rb_raise(rb_eArgError,
|
2272
|
+
"y and x arguments must be empty Arrays");
|
2273
|
+
return Qnil;
|
2274
|
+
}
|
2275
|
+
{
|
2276
|
+
int y,x;
|
2277
|
+
getyx(get_window(rb_win), y,x);
|
2278
|
+
rb_ary_push(rb_y, INT2NUM(y));
|
2279
|
+
rb_ary_push(rb_x, INT2NUM(x));
|
2280
|
+
return Qnil;
|
2281
|
+
}
|
2282
|
+
}
|
2283
|
+
#if defined(HAVE_GETATTRS) || defined(getattrs)
|
2284
|
+
static VALUE rbncurs_getattrs(VALUE dummy, VALUE rb_win)
|
2285
|
+
{return INT2NUM(getattrs(get_window(rb_win)));}
|
2286
|
+
#endif
|
2287
|
+
static VALUE rbncurs_getbegyx(VALUE dummy, VALUE rb_win, VALUE rb_y, VALUE rb_x)
|
2288
|
+
{
|
2289
|
+
int y,x;
|
2290
|
+
if ((rb_obj_is_instance_of(rb_y, rb_cArray) != Qtrue)
|
2291
|
+
|| (rb_obj_is_instance_of(rb_x, rb_cArray) != Qtrue)) {
|
2292
|
+
rb_raise(rb_eArgError,
|
2293
|
+
"y and x arguments must be empty Arrays");
|
2294
|
+
return Qnil;
|
2295
|
+
}
|
2296
|
+
getbegyx(get_window(rb_win), y,x);
|
2297
|
+
rb_ary_push(rb_y, INT2NUM(y));
|
2298
|
+
rb_ary_push(rb_x, INT2NUM(x));
|
2299
|
+
return Qnil;
|
2300
|
+
}
|
2301
|
+
static VALUE rbncurs_getmaxyx(VALUE dummy, VALUE rb_win, VALUE rb_y, VALUE rb_x)
|
2302
|
+
{
|
2303
|
+
int y,x;
|
2304
|
+
if ((rb_obj_is_instance_of(rb_y, rb_cArray) != Qtrue)
|
2305
|
+
|| (rb_obj_is_instance_of(rb_x, rb_cArray) != Qtrue)) {
|
2306
|
+
rb_raise(rb_eArgError,
|
2307
|
+
"y and x arguments must be empty Arrays");
|
2308
|
+
return Qnil;
|
2309
|
+
}
|
2310
|
+
getmaxyx(get_window(rb_win), y,x);
|
2311
|
+
rb_ary_push(rb_y, INT2NUM(y));
|
2312
|
+
rb_ary_push(rb_x, INT2NUM(x));
|
2313
|
+
return Qnil;
|
2314
|
+
}
|
2315
|
+
static VALUE rbncurs_getparyx(VALUE dummy, VALUE rb_win, VALUE rb_y, VALUE rb_x)
|
2316
|
+
{
|
2317
|
+
int y,x;
|
2318
|
+
if ((rb_obj_is_instance_of(rb_y, rb_cArray) != Qtrue)
|
2319
|
+
|| (rb_obj_is_instance_of(rb_x, rb_cArray) != Qtrue)) {
|
2320
|
+
rb_raise(rb_eArgError,
|
2321
|
+
"y and x arguments must be empty Arrays");
|
2322
|
+
return Qnil;
|
2323
|
+
}
|
2324
|
+
getparyx(get_window(rb_win), y,x);
|
2325
|
+
rb_ary_push(rb_y, INT2NUM(y));
|
2326
|
+
rb_ary_push(rb_x, INT2NUM(x));
|
2327
|
+
return Qnil;
|
2328
|
+
}
|
2329
|
+
static VALUE rbncurs_getsyx(VALUE dummy, VALUE rb_y, VALUE rb_x)
|
2330
|
+
{
|
2331
|
+
int y,x;
|
2332
|
+
if ((rb_obj_is_instance_of(rb_y, rb_cArray) != Qtrue)
|
2333
|
+
|| (rb_obj_is_instance_of(rb_x, rb_cArray) != Qtrue)) {
|
2334
|
+
rb_raise(rb_eArgError,
|
2335
|
+
"y and x arguments must be empty Arrays");
|
2336
|
+
return Qnil;
|
2337
|
+
}
|
2338
|
+
#ifdef getsyx
|
2339
|
+
getsyx(y,x);
|
2340
|
+
#else
|
2341
|
+
getsyx(&y,&x);
|
2342
|
+
#endif
|
2343
|
+
rb_ary_push(rb_y, INT2NUM(y));
|
2344
|
+
rb_ary_push(rb_x, INT2NUM(x));
|
2345
|
+
return Qnil;
|
2346
|
+
}
|
2347
|
+
static VALUE rbncurs_setsyx(VALUE dummy, VALUE rb_y, VALUE rb_x)
|
2348
|
+
{
|
2349
|
+
int y = NUM2INT(rb_y), x = NUM2INT(rb_x);
|
2350
|
+
setsyx(y,x);
|
2351
|
+
return Qnil;
|
2352
|
+
}
|
2353
|
+
|
2354
|
+
static VALUE rbncurs_wprintw(int argc, VALUE * argv, VALUE dummy)
|
2355
|
+
{
|
2356
|
+
if (argc < 2) {
|
2357
|
+
rb_raise(rb_eArgError, "function needs at least 2 arguments: a WINDOW"
|
2358
|
+
" and a String");
|
2359
|
+
return Qnil;
|
2360
|
+
}
|
2361
|
+
VALUE tmp = rb_funcall3(rb_mKernel, rb_intern("sprintf"), argc-1, argv + 1);
|
2362
|
+
wprintw(get_window(argv[0]), "%s", StringValuePtr(tmp));
|
2363
|
+
return Qnil;
|
2364
|
+
}
|
2365
|
+
|
2366
|
+
/* Debugging : use with libncurses_g.a */
|
2367
|
+
#ifdef HAVE__TRACEF
|
2368
|
+
static VALUE rbncurs_tracef(int argc, VALUE * argv, VALUE dummy)
|
2369
|
+
{
|
2370
|
+
(void) dummy;
|
2371
|
+
if (argc < 1) {
|
2372
|
+
rb_raise(rb_eArgError, "function needs at least 1 argument");
|
2373
|
+
return Qnil;
|
2374
|
+
}
|
2375
|
+
_tracef("%s",
|
2376
|
+
StringValuePtr(funcall3(rb_mKernel, rb_intern("sprintf"), argc, argv)));
|
2377
|
+
return Qnil;
|
2378
|
+
}
|
2379
|
+
#endif /* HAVE__TRACEF */
|
2380
|
+
#ifdef HAVE__TRACEDUMP
|
2381
|
+
static VALUE rbncurs_tracedump(VALUE dummy, VALUE rb_label, VALUE rb_win)
|
2382
|
+
{
|
2383
|
+
_tracedump(StringValuePtr(rb_label), get_window(rb_win));
|
2384
|
+
}
|
2385
|
+
#endif /* HAVE__TRACEDUMP */
|
2386
|
+
#ifdef HAVE__TRACEATTR
|
2387
|
+
static VALUE rbncurs_traceattr(VALUE dummy, VALUE attr)
|
2388
|
+
{ return rb_str_new2(_traceattr(NUM2ULONG(attr))); }
|
2389
|
+
#endif /* HAVE__TRACEATTR */
|
2390
|
+
#ifdef HAVE__TRACEATTR2
|
2391
|
+
static VALUE rbncurs_traceattr2(VALUE dummy, VALUE buffer, VALUE ch)
|
2392
|
+
{ return rb_str_new2(_traceattr2(NUM2INT(buffer),NUM2ULONG(ch))); }
|
2393
|
+
#endif /* HAVE__TRACEATTR2 */
|
2394
|
+
#ifdef HAVE__TRACEBITS
|
2395
|
+
static VALUE rbncurs_tracebits(VALUE dummy)
|
2396
|
+
{ return rb_str_new2(_tracebits()); }
|
2397
|
+
#endif /* HAVE__TRACEBITS */
|
2398
|
+
#ifdef HAVE__TRACECHAR
|
2399
|
+
static VALUE rbncurs_tracechar(VALUE dummy, VALUE ch)
|
2400
|
+
{ return rb_str_new2(_tracechar(NUM2ULONG(ch))); }
|
2401
|
+
#endif /* HAVE__TRACECHAR */
|
2402
|
+
#ifdef HAVE__TRACECHTYPE
|
2403
|
+
static VALUE rbncurs_tracechtype(VALUE dummy, VALUE ch)
|
2404
|
+
{ return rb_str_new2(_tracechtype(NUM2ULONG(ch))); }
|
2405
|
+
#endif /* HAVE__TRACECHTYPE */
|
2406
|
+
#ifdef HAVE__TRACECHTYPE2
|
2407
|
+
static VALUE rbncurs_tracechtype2(VALUE dummy, VALUE buffer, VALUE ch)
|
2408
|
+
{ return rb_str_new2(_tracechtype2(NUM2INT(buffer),NUM2ULONG(ch))); }
|
2409
|
+
#endif /* HAVE__TRACECHTYPE2 */
|
2410
|
+
#ifdef HAVE__TRACEMOUSE
|
2411
|
+
static VALUE rbncurs_tracemouse(VALUE dummy, VALUE rb_m)
|
2412
|
+
{
|
2413
|
+
MEVENT m;
|
2414
|
+
m.id = NUM2INT(rb_iv_get(rb_m, "@id"));
|
2415
|
+
m.x = NUM2INT(rb_iv_get(rb_m, "@x"));
|
2416
|
+
m.y = NUM2INT(rb_iv_get(rb_m, "@y"));
|
2417
|
+
m.z = NUM2INT(rb_iv_get(rb_m, "@z"));
|
2418
|
+
m.bstate = NUM2ULONG(rb_iv_get(rb_m, "@bstate"));
|
2419
|
+
return rb_str_new2(_tracemouse(&m));
|
2420
|
+
}
|
2421
|
+
#endif /* HAVE__TRACEMOUSE */
|
2422
|
+
#ifdef HAVE_TRACE
|
2423
|
+
static VALUE rbncurs_trace(VALUE dummy, VALUE param)
|
2424
|
+
{ trace(NUM2ULONG(param)); return Qnil; }
|
2425
|
+
#endif /* HAVE_TRACE */
|
2426
|
+
#ifdef HAVE__NC_TRACEBITS
|
2427
|
+
static VALUE rbncurs_nc_tracebits()
|
2428
|
+
{ return rb_str_new2((char*)_nc_tracebits()); }
|
2429
|
+
#endif /* HAVE__NC_TRACEBITS */
|
2430
|
+
|
2431
|
+
#ifdef HAVE_ASSUME_DEFAULT_COLORS
|
2432
|
+
static VALUE rbncurs_assume_default_colors(VALUE dummy, VALUE fg, VALUE bg)
|
2433
|
+
{ return INT2NUM(assume_default_colors(NUM2INT(fg),NUM2INT(bg))); }
|
2434
|
+
#endif /* HAVE_ASSUME_DEFAULT_COLORS */
|
2435
|
+
|
2436
|
+
static void init_functions_3(void)
|
2437
|
+
{
|
2438
|
+
#ifdef HAVE_UNGETMOUSE
|
2439
|
+
NCFUNC(getmouse, 1);
|
2440
|
+
NCFUNC(ungetmouse, 1);
|
2441
|
+
#endif
|
2442
|
+
#ifdef HAVE_MOUSEMASK
|
2443
|
+
NCFUNC(mousemask, 2);
|
2444
|
+
#endif
|
2445
|
+
#ifdef HAVE_WENCLOSE
|
2446
|
+
rb_define_module_function(mNcurses, "wenclose?",
|
2447
|
+
(&rbncurs_wenclose),
|
2448
|
+
1);
|
2449
|
+
#endif
|
2450
|
+
#ifdef HAVE_MOUSEINTERVAL
|
2451
|
+
NCFUNC(mouseinterval, 1);
|
2452
|
+
#endif
|
2453
|
+
#ifdef HAVE_WMOUSE_TRAFO
|
2454
|
+
NCFUNC(wmouse_trafo, 4);
|
2455
|
+
#endif
|
2456
|
+
#ifdef HAVE_MCPRINT
|
2457
|
+
NCFUNC(mcprint, 2);
|
2458
|
+
#endif
|
2459
|
+
#ifdef HAVE_HAS_KEY
|
2460
|
+
rb_define_module_function(mNcurses, "has_key?",
|
2461
|
+
(&rbncurs_has_key),
|
2462
|
+
2);
|
2463
|
+
#endif
|
2464
|
+
NCFUNC(getyx, 3);
|
2465
|
+
NCFUNC(getbegyx, 3);
|
2466
|
+
NCFUNC(getmaxyx, 3);
|
2467
|
+
NCFUNC(getparyx, 3);
|
2468
|
+
NCFUNC(getsyx, 2);
|
2469
|
+
NCFUNC(setsyx, 2);
|
2470
|
+
#if defined(HAVE_GETATTRS) || defined(getattrs)
|
2471
|
+
NCFUNC(getattrs, 1);
|
2472
|
+
#endif
|
2473
|
+
#ifdef HAVE__TRACEF
|
2474
|
+
rb_define_module_function(mNcurses, "_tracef",
|
2475
|
+
(&rbncurs_tracef), -1);
|
2476
|
+
#endif /* HAVE__TRACEF */
|
2477
|
+
#ifdef HAVE__TRACEDUMP
|
2478
|
+
rb_define_module_function(mNcurses, "_tracedump",
|
2479
|
+
(&rbncurs_tracedump),
|
2480
|
+
2);
|
2481
|
+
#endif /* HAVE__TRACEDUMP */
|
2482
|
+
#ifdef HAVE__TRACEATTR
|
2483
|
+
rb_define_module_function(mNcurses, "_traceattr",
|
2484
|
+
(&rbncurs_traceattr),
|
2485
|
+
1);
|
2486
|
+
#endif /* HAVE__TRACEATTR */
|
2487
|
+
#ifdef HAVE__TRACEATTR2
|
2488
|
+
rb_define_module_function(mNcurses, "_traceattr2",
|
2489
|
+
(&rbncurs_traceattr2),
|
2490
|
+
2);
|
2491
|
+
#endif /* HAVE__TRACEATTR2 */
|
2492
|
+
#ifdef HAVE__TRACEBITS
|
2493
|
+
rb_define_module_function(mNcurses, "_tracebits",
|
2494
|
+
(&rbncurs_tracebits),
|
2495
|
+
0);
|
2496
|
+
#endif /* HAVE__TRACEBITS */
|
2497
|
+
#ifdef HAVE__TRACECHAR
|
2498
|
+
rb_define_module_function(mNcurses, "_tracechar",
|
2499
|
+
(&rbncurs_tracechar),
|
2500
|
+
1);
|
2501
|
+
#endif /* HAVE__TRACECHAR */
|
2502
|
+
#ifdef HAVE__TRACECHTYPE
|
2503
|
+
rb_define_module_function(mNcurses, "_tracechtype",
|
2504
|
+
(&rbncurs_tracechtype),
|
2505
|
+
1);
|
2506
|
+
#endif /* HAVE__TRACECHTYPE */
|
2507
|
+
#ifdef HAVE__TRACECHTYPE2
|
2508
|
+
rb_define_module_function(mNcurses, "_tracechtype2",
|
2509
|
+
(&rbncurs_tracechtype2), 2);
|
2510
|
+
#endif /* HAVE__TRACECHTYPE2 */
|
2511
|
+
#ifdef HAVE__TRACEMOUSE
|
2512
|
+
rb_define_module_function(mNcurses, "_tracechmouse",
|
2513
|
+
(&rbncurs_tracemouse),
|
2514
|
+
1);
|
2515
|
+
#endif /* HAVE__TRACEMOUSE */
|
2516
|
+
#ifdef HAVE_TRACE
|
2517
|
+
NCFUNC(trace, 1);
|
2518
|
+
#endif /* HAVE_TRACE */
|
2519
|
+
#ifdef HAVE__NC_TRACEBITS
|
2520
|
+
rb_define_module_function(mNcurses, "_nc_tracebits", &rbncurs_nc_tracebits, 0);
|
2521
|
+
#endif /* HAVE__NC_TRACEBITS */
|
2522
|
+
#ifdef HAVE_ASSUME_DEFAULT_COLORS
|
2523
|
+
NCFUNC(assume_default_colors, 2);
|
2524
|
+
#endif /* HAVE_ASSUME_DEFAULT_COLORS */
|
2525
|
+
NCFUNC(wprintw, -1);
|
2526
|
+
}
|
2527
|
+
|
2528
|
+
static void init_constants_4(void)
|
2529
|
+
{
|
2530
|
+
/* trace masks */
|
2531
|
+
#ifdef TRACE_DISABLE
|
2532
|
+
rb_define_const(mNcurses, "TRACE_DISABLE", INT2NUM(TRACE_DISABLE));
|
2533
|
+
#endif
|
2534
|
+
#ifdef TRACE_TIMES
|
2535
|
+
rb_define_const(mNcurses, "TRACE_TIMES", INT2NUM(TRACE_TIMES));
|
2536
|
+
#endif
|
2537
|
+
#ifdef TRACE_TPUTS
|
2538
|
+
rb_define_const(mNcurses, "TRACE_TPUTS", INT2NUM(TRACE_TPUTS));
|
2539
|
+
#endif
|
2540
|
+
#ifdef TRACE_UPDATE
|
2541
|
+
rb_define_const(mNcurses, "TRACE_UPDATE", INT2NUM(TRACE_UPDATE));
|
2542
|
+
#endif
|
2543
|
+
#ifdef TRACE_MOVE
|
2544
|
+
rb_define_const(mNcurses, "TRACE_MOVE", INT2NUM(TRACE_MOVE));
|
2545
|
+
#endif
|
2546
|
+
#ifdef TRACE_CHARPUT
|
2547
|
+
rb_define_const(mNcurses, "TRACE_CHARPUT", INT2NUM(TRACE_CHARPUT));
|
2548
|
+
#endif
|
2549
|
+
#ifdef TRACE_ORDINARY
|
2550
|
+
rb_define_const(mNcurses, "TRACE_ORDINARY", INT2NUM(TRACE_ORDINARY));
|
2551
|
+
#endif
|
2552
|
+
#ifdef TRACE_CALLS
|
2553
|
+
rb_define_const(mNcurses, "TRACE_CALLS", INT2NUM(TRACE_CALLS));
|
2554
|
+
#endif
|
2555
|
+
#ifdef TRACE_VIRTPUT
|
2556
|
+
rb_define_const(mNcurses, "TRACE_VIRTPUT", INT2NUM(TRACE_VIRTPUT));
|
2557
|
+
#endif
|
2558
|
+
#ifdef TRACE_IEVENT
|
2559
|
+
rb_define_const(mNcurses, "TRACE_IEVENT", INT2NUM(TRACE_IEVENT));
|
2560
|
+
#endif
|
2561
|
+
#ifdef TRACE_BITS
|
2562
|
+
rb_define_const(mNcurses, "TRACE_BITS", INT2NUM(TRACE_BITS));
|
2563
|
+
#endif
|
2564
|
+
#ifdef TRACE_ICALLS
|
2565
|
+
rb_define_const(mNcurses, "TRACE_ICALLS", INT2NUM(TRACE_ICALLS));
|
2566
|
+
#endif
|
2567
|
+
#ifdef TRACE_CCALLS
|
2568
|
+
rb_define_const(mNcurses, "TRACE_CCALLS", INT2NUM(TRACE_CCALLS));
|
2569
|
+
#endif
|
2570
|
+
#ifdef TRACE_MAXIMUM
|
2571
|
+
rb_define_const(mNcurses, "TRACE_MAXIMUM", INT2NUM(TRACE_MAXIMUM));
|
2572
|
+
#endif
|
2573
|
+
}
|
2574
|
+
|
2575
|
+
/* Wrap ACS_* constants (additionally) as methods of SCREEN: */
|
2576
|
+
#define rb_ACS(ACS) \
|
2577
|
+
VALUE rb_## ACS (VALUE rb_screen) \
|
2578
|
+
{ \
|
2579
|
+
VALUE current_screen = \
|
2580
|
+
rbncurs_set_term(mNcurses, rb_screen); \
|
2581
|
+
VALUE rb_ACS_CONST = INT2NUM(ACS); \
|
2582
|
+
rbncurs_set_term(mNcurses, current_screen); \
|
2583
|
+
return rb_ACS_CONST; \
|
2584
|
+
}
|
2585
|
+
#define wrap_ACS(ACS) \
|
2586
|
+
rb_define_method(cSCREEN, #ACS, \
|
2587
|
+
(&rb_ ## ACS), \
|
2588
|
+
0)
|
2589
|
+
rb_ACS(ACS_ULCORNER)
|
2590
|
+
rb_ACS(ACS_LLCORNER)
|
2591
|
+
rb_ACS(ACS_URCORNER)
|
2592
|
+
rb_ACS(ACS_LRCORNER)
|
2593
|
+
rb_ACS(ACS_LTEE)
|
2594
|
+
rb_ACS(ACS_RTEE)
|
2595
|
+
rb_ACS(ACS_BTEE)
|
2596
|
+
rb_ACS(ACS_TTEE)
|
2597
|
+
rb_ACS(ACS_HLINE)
|
2598
|
+
rb_ACS(ACS_VLINE)
|
2599
|
+
rb_ACS(ACS_PLUS)
|
2600
|
+
rb_ACS(ACS_S1)
|
2601
|
+
rb_ACS(ACS_S9)
|
2602
|
+
rb_ACS(ACS_DIAMOND)
|
2603
|
+
rb_ACS(ACS_CKBOARD)
|
2604
|
+
rb_ACS(ACS_DEGREE)
|
2605
|
+
rb_ACS(ACS_PLMINUS)
|
2606
|
+
rb_ACS(ACS_BULLET)
|
2607
|
+
rb_ACS(ACS_LARROW)
|
2608
|
+
rb_ACS(ACS_RARROW)
|
2609
|
+
rb_ACS(ACS_DARROW)
|
2610
|
+
rb_ACS(ACS_UARROW)
|
2611
|
+
rb_ACS(ACS_BOARD)
|
2612
|
+
rb_ACS(ACS_LANTERN)
|
2613
|
+
rb_ACS(ACS_BLOCK)
|
2614
|
+
#ifdef ACS_S3
|
2615
|
+
rb_ACS(ACS_S3)
|
2616
|
+
#endif
|
2617
|
+
#ifdef ACS_S7
|
2618
|
+
rb_ACS(ACS_S7)
|
2619
|
+
#endif
|
2620
|
+
#ifdef ACS_LEQUAL
|
2621
|
+
rb_ACS(ACS_LEQUAL)
|
2622
|
+
#endif
|
2623
|
+
#ifdef ACS_GEQUAL
|
2624
|
+
rb_ACS(ACS_GEQUAL)
|
2625
|
+
#endif
|
2626
|
+
#ifdef ACS_PI
|
2627
|
+
rb_ACS(ACS_PI)
|
2628
|
+
#endif
|
2629
|
+
#ifdef ACS_NEQUAL
|
2630
|
+
rb_ACS(ACS_NEQUAL)
|
2631
|
+
#endif
|
2632
|
+
#ifdef ACS_STERLING
|
2633
|
+
rb_ACS(ACS_STERLING)
|
2634
|
+
#endif
|
2635
|
+
|
2636
|
+
void init_SCREEN_methods(void)
|
2637
|
+
{
|
2638
|
+
wrap_ACS(ACS_ULCORNER);
|
2639
|
+
wrap_ACS(ACS_LLCORNER);
|
2640
|
+
wrap_ACS(ACS_URCORNER);
|
2641
|
+
wrap_ACS(ACS_LRCORNER);
|
2642
|
+
wrap_ACS(ACS_LTEE);
|
2643
|
+
wrap_ACS(ACS_RTEE);
|
2644
|
+
wrap_ACS(ACS_BTEE);
|
2645
|
+
wrap_ACS(ACS_TTEE);
|
2646
|
+
wrap_ACS(ACS_HLINE);
|
2647
|
+
wrap_ACS(ACS_VLINE);
|
2648
|
+
wrap_ACS(ACS_PLUS);
|
2649
|
+
wrap_ACS(ACS_S1);
|
2650
|
+
wrap_ACS(ACS_S9);
|
2651
|
+
wrap_ACS(ACS_DIAMOND);
|
2652
|
+
wrap_ACS(ACS_CKBOARD);
|
2653
|
+
wrap_ACS(ACS_DEGREE);
|
2654
|
+
wrap_ACS(ACS_PLMINUS);
|
2655
|
+
wrap_ACS(ACS_BULLET);
|
2656
|
+
wrap_ACS(ACS_LARROW);
|
2657
|
+
wrap_ACS(ACS_RARROW);
|
2658
|
+
wrap_ACS(ACS_DARROW);
|
2659
|
+
wrap_ACS(ACS_UARROW);
|
2660
|
+
wrap_ACS(ACS_BOARD);
|
2661
|
+
wrap_ACS(ACS_LANTERN);
|
2662
|
+
wrap_ACS(ACS_BLOCK);
|
2663
|
+
#ifdef ACS_S3
|
2664
|
+
wrap_ACS(ACS_S3);
|
2665
|
+
#endif
|
2666
|
+
#ifdef ACS_S7
|
2667
|
+
wrap_ACS(ACS_S7);
|
2668
|
+
#endif
|
2669
|
+
#ifdef ACS_LEQUAL
|
2670
|
+
wrap_ACS(ACS_LEQUAL);
|
2671
|
+
#endif
|
2672
|
+
#ifdef ACS_GEQUAL
|
2673
|
+
wrap_ACS(ACS_GEQUAL);
|
2674
|
+
#endif
|
2675
|
+
#ifdef ACS_PI
|
2676
|
+
wrap_ACS(ACS_PI);
|
2677
|
+
#endif
|
2678
|
+
#ifdef ACS_NEQUAL
|
2679
|
+
wrap_ACS(ACS_NEQUAL);
|
2680
|
+
#endif
|
2681
|
+
#ifdef ACS_STERLING
|
2682
|
+
wrap_ACS(ACS_STERLING);
|
2683
|
+
#endif
|
2684
|
+
}
|
2685
|
+
|
2686
|
+
static void init_safe_functions(void)
|
2687
|
+
{
|
2688
|
+
NCFUNC(initscr, 0);
|
2689
|
+
NCFUNC(newterm, 3);
|
2690
|
+
NCFUNC(slk_init, 1);
|
2691
|
+
#ifdef HAVE_FILTER
|
2692
|
+
NCFUNC(filter, 0);
|
2693
|
+
#endif
|
2694
|
+
#ifdef HAVE_USE_ENV
|
2695
|
+
NCFUNC(use_env, 1);
|
2696
|
+
#endif
|
2697
|
+
}
|
2698
|
+
void Init_ncurses(void)
|
2699
|
+
{
|
2700
|
+
mNcurses = rb_define_module("Ncurses");
|
2701
|
+
eNcurses = rb_define_class_under(mNcurses, "Exception", rb_eRuntimeError);
|
2702
|
+
rb_iv_set(mNcurses, "@windows_hash", rb_hash_new());
|
2703
|
+
rb_iv_set(mNcurses, "@screens_hash", rb_hash_new());
|
2704
|
+
|
2705
|
+
/* keep track of "halfdelay" settings in the wrapper */
|
2706
|
+
rb_iv_set(mNcurses, "@halfdelay", INT2FIX(0));
|
2707
|
+
rb_iv_set(mNcurses, "@cbreak", Qfalse);
|
2708
|
+
|
2709
|
+
/* filedescriptor that transports input from terminal to application */
|
2710
|
+
rb_iv_set(mNcurses, "@infd", Qnil);
|
2711
|
+
|
2712
|
+
cWINDOW = rb_define_class_under(mNcurses, "WINDOW", rb_cObject);
|
2713
|
+
cSCREEN = rb_define_class_under(mNcurses, "SCREEN", rb_cObject);
|
2714
|
+
init_constants_1();
|
2715
|
+
init_constants_2();
|
2716
|
+
init_constants_3();
|
2717
|
+
init_constants_4();
|
2718
|
+
init_safe_functions();
|
2719
|
+
}
|
2720
|
+
static void Init_ncurses_full(void)
|
2721
|
+
{
|
2722
|
+
init_globals_1();
|
2723
|
+
init_globals_2();
|
2724
|
+
init_functions_0();
|
2725
|
+
init_functions_1();
|
2726
|
+
init_functions_2();
|
2727
|
+
init_functions_3();
|
2728
|
+
|
2729
|
+
init_SCREEN_methods();
|
2730
|
+
#ifdef HAVE_PANEL_H
|
2731
|
+
init_panel();
|
2732
|
+
#endif
|
2733
|
+
#ifdef HAVE_FORM_H
|
2734
|
+
init_form();
|
2735
|
+
#endif
|
2736
|
+
#ifdef HAVE_MENU_H
|
2737
|
+
init_menu();
|
2738
|
+
#endif
|
2739
|
+
}
|