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