ncursesw 1.2.4.3 → 1.4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/THANKS +1 -1
- data/TODO +1 -1
- data/VERSION +1 -1
- data/compat.h +1 -1
- data/examples/LICENSES_for_examples +1 -1
- data/examples/example.rb +2 -2
- data/examples/form.rb +1 -1
- data/examples/form2.rb +1 -1
- data/examples/hello_ncurses.rb +2 -2
- data/examples/rain.rb +2 -2
- data/examples/read_line.rb +1 -1
- data/examples/tclock.rb +2 -2
- data/examples/test_scanw.rb +2 -2
- data/extconf.rb +44 -5
- data/form_wrap.c +90 -65
- data/form_wrap.h +11 -3
- data/lib/ncurses_sugar.rb +342 -0
- data/lib/ncursesw.rb +4 -324
- data/make_dist.rb +16 -23
- data/menu_wrap.c +6 -4
- data/menu_wrap.h +7 -1
- data/ncurses_wrap.c +176 -83
- data/ncurses_wrap.h +8 -4
- data/panel_wrap.c +3 -2
- data/panel_wrap.h +7 -2
- metadata +35 -38
data/form_wrap.h
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Contributed by Simon Kaczor <skaczor@cox.net>
|
4
4
|
* Prognosoft Inc. <http://www.prognosoft.biz>
|
5
5
|
* Copyright 2004
|
6
|
-
*
|
6
|
+
*
|
7
7
|
* This module is free software; you can redistribute it and/or
|
8
8
|
* modify it under the terms of the GNU Lesser General Public
|
9
9
|
* License as published by the Free Software Foundation; either
|
@@ -18,12 +18,20 @@
|
|
18
18
|
* License along with this module; if not, write to the Free Software
|
19
19
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20
20
|
*
|
21
|
+
* Changes
|
22
|
+
* (C) 2011 Tobias Herzke
|
23
|
+
* (C) 2013 Gaute Hope <eg@gaute.vetsj.com>
|
21
24
|
*/
|
22
25
|
|
23
|
-
#if !defined(FORM_HH) && defined(HAVE_FORM_H)
|
26
|
+
#if !defined(FORM_HH) && (defined(HAVE_FORM_H) || defined(HAVE_NCURSESW_FORM_H))
|
24
27
|
#define FORM_HH
|
25
28
|
|
29
|
+
#ifdef HAVE_FORM_H
|
26
30
|
#include <form.h>
|
31
|
+
#else
|
32
|
+
#include <ncursesw/form.h>
|
33
|
+
#endif
|
34
|
+
|
27
35
|
#include <ruby.h>
|
28
36
|
|
29
37
|
extern VALUE mForm;
|
@@ -33,7 +41,7 @@ extern VALUE cFORM;
|
|
33
41
|
/*extern VALUE cPAGE;*/
|
34
42
|
|
35
43
|
typedef struct {
|
36
|
-
bool (* field_check)(FIELD *,const void *);
|
44
|
+
bool (* field_check)(FIELD *,const void *);
|
37
45
|
FIELDTYPE* fieldtype;
|
38
46
|
} FLDCHKFUNC;
|
39
47
|
|
@@ -0,0 +1,342 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# ncurses-ruby is a ruby module for accessing the FSF's ncurses library
|
3
|
+
# (C) 2002, 2003, 2004 Tobias Peters <t-peters@users.berlios.de>
|
4
|
+
# (C) 2004 Simon Kaczor <skaczor@cox.net>
|
5
|
+
# (C) 2005 2011 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_sugar.rb,v 1.1 2011-05-30 23:05:50 t-peters Exp $
|
22
|
+
|
23
|
+
# Ncurses constants with leading underscore
|
24
|
+
def Ncurses._XOPEN_CURSES
|
25
|
+
Ncurses::XOPEN_CURSES
|
26
|
+
end
|
27
|
+
def Ncurses._SUBWIN
|
28
|
+
Ncurses::SUBWIN
|
29
|
+
end
|
30
|
+
def Ncurses._ENDLINE
|
31
|
+
Ncurses::ENDLINE
|
32
|
+
end
|
33
|
+
def Ncurses._FULLWIN
|
34
|
+
Ncurses::FULLWIN
|
35
|
+
end
|
36
|
+
def Ncurses._SCROLLWIN
|
37
|
+
Ncurses::SCROLLWIN
|
38
|
+
end
|
39
|
+
def Ncurses._ISPAD
|
40
|
+
Ncurses::ISPAD
|
41
|
+
end
|
42
|
+
def Ncurses._HASMOVED
|
43
|
+
Ncurses::HASMOVED
|
44
|
+
end
|
45
|
+
def Ncurses._WRAPPED
|
46
|
+
Ncurses::WRAPPED
|
47
|
+
end
|
48
|
+
def Ncurses._NOCHANGE
|
49
|
+
Ncurses::NOCHANGE
|
50
|
+
end
|
51
|
+
def Ncurses._NEWINDEX
|
52
|
+
Ncurses::NEWINDEX
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
module Ncurses
|
57
|
+
module Destroy_checker; def destroyed?; @destroyed; end; end
|
58
|
+
class WINDOW
|
59
|
+
include Destroy_checker
|
60
|
+
def method_missing(name, *args)
|
61
|
+
name = name.to_s
|
62
|
+
if (name[0,2] == "mv")
|
63
|
+
test_name = name.dup
|
64
|
+
test_name[2,0] = "w" # insert "w" after"mv"
|
65
|
+
if (Ncurses.respond_to?(test_name))
|
66
|
+
return Ncurses.send(test_name, self, *args)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
test_name = "w" + name
|
70
|
+
if (Ncurses.respond_to?(test_name))
|
71
|
+
return Ncurses.send(test_name, self, *args)
|
72
|
+
end
|
73
|
+
Ncurses.send(name, self, *args)
|
74
|
+
end
|
75
|
+
def respond_to?(name)
|
76
|
+
name = name.to_s
|
77
|
+
if (name[0,2] == "mv" && Ncurses.respond_to?("mvw" + name[2..-1]))
|
78
|
+
return true
|
79
|
+
end
|
80
|
+
Ncurses.respond_to?("w" + name) || Ncurses.respond_to?(name)
|
81
|
+
end
|
82
|
+
def del
|
83
|
+
Ncurses.delwin(self)
|
84
|
+
end
|
85
|
+
alias delete del
|
86
|
+
def WINDOW.new(*args)
|
87
|
+
Ncurses.newwin(*args)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
class SCREEN
|
91
|
+
include Destroy_checker
|
92
|
+
def del
|
93
|
+
Ncurses.delscreen(self)
|
94
|
+
end
|
95
|
+
alias delete del
|
96
|
+
end
|
97
|
+
class MEVENT
|
98
|
+
attr_accessor :id, :x,:y,:z, :bstate
|
99
|
+
end
|
100
|
+
GETSTR_LIMIT = 1024
|
101
|
+
|
102
|
+
module Panel
|
103
|
+
class PANEL; end
|
104
|
+
end
|
105
|
+
|
106
|
+
module Form
|
107
|
+
class FORM
|
108
|
+
attr_reader :user_object
|
109
|
+
|
110
|
+
# This placeholder replaces the form_userptr function in curses
|
111
|
+
def user_object=(obj)
|
112
|
+
@user_object = obj
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class FIELD
|
117
|
+
attr_reader :user_object
|
118
|
+
|
119
|
+
# This placeholder replaces the field_userptr function in curses
|
120
|
+
def user_object=(obj)
|
121
|
+
@user_object = obj
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class FIELDTYPE
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
module Menu
|
130
|
+
class MENU
|
131
|
+
attr_reader :user_object
|
132
|
+
|
133
|
+
# This placeholder replaces the menu_userptr function in curses
|
134
|
+
def user_object=(obj)
|
135
|
+
@user_object = obj
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
class ITEM
|
140
|
+
attr_reader :user_object
|
141
|
+
|
142
|
+
# This placeholder replaces the item_userptr function in curses
|
143
|
+
def user_object=(obj)
|
144
|
+
@user_object = obj
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
def Ncurses.inchnstr(str,n)
|
150
|
+
Ncurses.winchnstr(Ncurses.stdscr, str, n)
|
151
|
+
end
|
152
|
+
def Ncurses.inchstr(str)
|
153
|
+
Ncurses.winchstr(Ncurses.stdscr, str)
|
154
|
+
end
|
155
|
+
def Ncurses.mvinchnstr(y,x, str, n)
|
156
|
+
Ncurses.mvwinchnstr(Ncurses.stdscr, y,x, str, n)
|
157
|
+
end
|
158
|
+
def Ncurses.mvinchstr(y,x, str)
|
159
|
+
Ncurses.mvwinchstr(Ncurses.stdscr, y,x, str)
|
160
|
+
end
|
161
|
+
def Ncurses.mvwinchnstr(win, y,x, str, n)
|
162
|
+
if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
|
163
|
+
Ncurses::ERR
|
164
|
+
else
|
165
|
+
Ncurses.winchnstr(win,str,n)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
def Ncurses.mvwinchstr(win, y,x, str)
|
169
|
+
maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
|
170
|
+
return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
|
171
|
+
Ncurses.mvwinchnstr(win, y,x, str, maxx[0]+1)
|
172
|
+
end
|
173
|
+
def Ncurses.winchstr(win, str)
|
174
|
+
maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
|
175
|
+
return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
|
176
|
+
Ncurses.winchnstr(win, str, maxx[0]+1)
|
177
|
+
end
|
178
|
+
|
179
|
+
def Ncurses.getnstr(str,n)
|
180
|
+
Ncurses.wgetnstr(Ncurses.stdscr, str, n)
|
181
|
+
end
|
182
|
+
def Ncurses.mvgetnstr(y,x, str, n)
|
183
|
+
Ncurses.mvwgetnstr(Ncurses.stdscr, y,x, str, n)
|
184
|
+
end
|
185
|
+
def Ncurses.mvwgetnstr(win, y,x, str, n)
|
186
|
+
if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
|
187
|
+
Ncurses::ERR
|
188
|
+
else
|
189
|
+
Ncurses.wgetnstr(win,str,n)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def Ncurses.innstr(str,n)
|
194
|
+
Ncurses.winnstr(Ncurses.stdscr, str, n)
|
195
|
+
end
|
196
|
+
def Ncurses.instr(str)
|
197
|
+
Ncurses.winstr(Ncurses.stdscr, str)
|
198
|
+
end
|
199
|
+
def Ncurses.mvinnstr(y,x, str, n)
|
200
|
+
Ncurses.mvwinnstr(Ncurses.stdscr, y,x, str, n)
|
201
|
+
end
|
202
|
+
def Ncurses.mvinstr(y,x, str)
|
203
|
+
Ncurses.mvwinstr(Ncurses.stdscr, y,x, str)
|
204
|
+
end
|
205
|
+
def Ncurses.mvwinnstr(win, y,x, str, n)
|
206
|
+
if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
|
207
|
+
Ncurses::ERR
|
208
|
+
else
|
209
|
+
Ncurses.winnstr(win,str,n)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
def Ncurses.mvwinstr(win, y,x, str)
|
213
|
+
maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
|
214
|
+
return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
|
215
|
+
Ncurses.mvwinnstr(win, y,x, str, maxx[0]+1)
|
216
|
+
end
|
217
|
+
def Ncurses.winstr(win, str)
|
218
|
+
maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
|
219
|
+
return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
|
220
|
+
Ncurses.winnstr(win, str, maxx[0]+1)
|
221
|
+
end
|
222
|
+
|
223
|
+
def Ncurses.mouse_trafo(pY, pX, to_screen)
|
224
|
+
Ncurses.wmouse_trafo(Ncurses.stdscr, pY, pX, to_screen)
|
225
|
+
end
|
226
|
+
|
227
|
+
def Ncurses.getcurx(win)
|
228
|
+
x = []; y = []; Ncurses.getyx(win, y,x); x[0]
|
229
|
+
end
|
230
|
+
def Ncurses.getcury(win)
|
231
|
+
x = []; y = []; Ncurses.getyx(win, y,x); y[0]
|
232
|
+
end
|
233
|
+
def Ncurses.getbegx(win)
|
234
|
+
x = []; y = []; Ncurses.getbegyx(win, y,x); x[0]
|
235
|
+
end
|
236
|
+
def Ncurses.getbegy(win)
|
237
|
+
x = []; y = []; Ncurses.getbegyx(win, y,x); y[0]
|
238
|
+
end
|
239
|
+
def Ncurses.getmaxx(win)
|
240
|
+
x = []; y = []; Ncurses.getmaxyx(win, y,x); x[0]
|
241
|
+
end
|
242
|
+
def Ncurses.getmaxy(win)
|
243
|
+
x = []; y = []; Ncurses.getmaxyx(win, y,x); y[0]
|
244
|
+
end
|
245
|
+
def Ncurses.getparx(win)
|
246
|
+
x = []; y = []; Ncurses.getparyx(win, y,x); x[0]
|
247
|
+
end
|
248
|
+
def Ncurses.getpary(win)
|
249
|
+
x = []; y = []; Ncurses.getparyx(win, y,x); y[0]
|
250
|
+
end
|
251
|
+
def Ncurses.erase
|
252
|
+
Ncurses.werase(Ncurses.stdscr)
|
253
|
+
end
|
254
|
+
def Ncurses.getstr(str)
|
255
|
+
Ncurses.getnstr(str, Ncurses::GETSTR_LIMIT)
|
256
|
+
end
|
257
|
+
def Ncurses.mvgetstr(y,x, str)
|
258
|
+
Ncurses.mvgetnstr(y,x, str, Ncurses::GETSTR_LIMIT)
|
259
|
+
end
|
260
|
+
def Ncurses.mvwgetstr(win, y,x, str)
|
261
|
+
Ncurses.mvwgetnstr(win, y,x, str, Ncurses::GETSTR_LIMIT)
|
262
|
+
end
|
263
|
+
def Ncurses.wgetstr(win, str)
|
264
|
+
Ncurses.wgetnstr(win, str, Ncurses::GETSTR_LIMIT)
|
265
|
+
end
|
266
|
+
|
267
|
+
def Ncurses.scanw(format, result)
|
268
|
+
Ncurses.wscanw(Ncurses.stdscr, format, result)
|
269
|
+
end
|
270
|
+
def Ncurses.mvscanw(y,x, format, result)
|
271
|
+
Ncurses.mvwscanw(Ncurses.stdscr, y,x, format, result)
|
272
|
+
end
|
273
|
+
def Ncurses.mvwscanw(win, y,x, format, result)
|
274
|
+
if (Ncurses.wmove(win, y,x) == Ncurses::ERR)
|
275
|
+
Ncurses::ERR
|
276
|
+
else
|
277
|
+
Ncurses.wscanw(win, format, result)
|
278
|
+
end
|
279
|
+
end
|
280
|
+
def Ncurses.wscanw(win, format, result)
|
281
|
+
str = ""
|
282
|
+
if (Ncurses.wgetstr(win, str) == Ncurses::ERR)
|
283
|
+
Ncurses::ERR
|
284
|
+
else
|
285
|
+
require "scanf.rb" # Use ruby's implementation of scanf
|
286
|
+
result.replace(str.scanf(format))
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def Ncurses.mvprintw(*args)
|
291
|
+
Ncurses.mvwprintw(Ncurses.stdscr, *args)
|
292
|
+
end
|
293
|
+
def Ncurses.mvwprintw(win, y,x, *args)
|
294
|
+
if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
|
295
|
+
Ncurses::ERR
|
296
|
+
else
|
297
|
+
wprintw(win, *args)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
def Ncurses.printw(*args)
|
301
|
+
Ncurses.wprintw(Ncurses.stdscr, *args)
|
302
|
+
end
|
303
|
+
def Ncurses.touchline(win, start, count)
|
304
|
+
Ncurses.wtouchln(win, start, count, 1)
|
305
|
+
end
|
306
|
+
def Ncurses.touchwin(win)
|
307
|
+
wtouchln(win, 0, getmaxy(win), 1)
|
308
|
+
end
|
309
|
+
|
310
|
+
module Ncurses
|
311
|
+
Ncurses = self # for accessing Ncurses from a Module that includes Ncurses
|
312
|
+
|
313
|
+
# Some users like to include ncurses names despite namespace pollution
|
314
|
+
# This module is for them
|
315
|
+
module Namespace
|
316
|
+
def self.append_features(target)
|
317
|
+
# include constants
|
318
|
+
unless target.ancestors.member?(Ncurses)
|
319
|
+
target.__send__(:include, Ncurses)
|
320
|
+
end
|
321
|
+
|
322
|
+
# make methods available
|
323
|
+
unless target.respond_to?(:pre_Ncurses_method_missing)
|
324
|
+
target.module_eval{
|
325
|
+
alias pre_Ncurses_method_missing method_missing
|
326
|
+
def method_missing(name, *args)
|
327
|
+
if Ncurses.respond_to?(name)
|
328
|
+
Ncurses.send(name, *args)
|
329
|
+
else
|
330
|
+
pre_Ncurses_method_missing(name, *args)
|
331
|
+
end
|
332
|
+
end
|
333
|
+
}
|
334
|
+
end
|
335
|
+
end
|
336
|
+
def self.entend_object(object)
|
337
|
+
class << object
|
338
|
+
self
|
339
|
+
end.__send__(:include, self)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
data/lib/ncursesw.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
# ncurses-ruby is a ruby module for accessing the FSF's ncurses library
|
2
3
|
# (C) 2002, 2003, 2004 Tobias Peters <t-peters@users.berlios.de>
|
3
4
|
# (C) 2004 Simon Kaczor <skaczor@cox.net>
|
4
|
-
# (C) 2005 Tobias Herzke
|
5
|
+
# (C) 2005 2011 Tobias Herzke
|
5
6
|
#
|
6
7
|
# This module is free software; you can redistribute it and/or
|
7
8
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -17,328 +18,7 @@
|
|
17
18
|
# License along with this module; if not, write to the Free Software
|
18
19
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
20
|
|
20
|
-
# $Id:
|
21
|
+
# $Id: ncursesw.rb,v 1.1 2011-05-30 23:05:51 t-peters Exp $
|
21
22
|
|
22
23
|
require "ncursesw_bin.so"
|
23
|
-
|
24
|
-
|
25
|
-
# Ncurses constants with leading underscore
|
26
|
-
def Ncurses._XOPEN_CURSES
|
27
|
-
Ncurses::XOPEN_CURSES
|
28
|
-
end
|
29
|
-
def Ncurses._SUBWIN
|
30
|
-
Ncurses::SUBWIN
|
31
|
-
end
|
32
|
-
def Ncurses._ENDLINE
|
33
|
-
Ncurses::ENDLINE
|
34
|
-
end
|
35
|
-
def Ncurses._FULLWIN
|
36
|
-
Ncurses::FULLWIN
|
37
|
-
end
|
38
|
-
def Ncurses._SCROLLWIN
|
39
|
-
Ncurses::SCROLLWIN
|
40
|
-
end
|
41
|
-
def Ncurses._ISPAD
|
42
|
-
Ncurses::ISPAD
|
43
|
-
end
|
44
|
-
def Ncurses._HASMOVED
|
45
|
-
Ncurses::HASMOVED
|
46
|
-
end
|
47
|
-
def Ncurses._WRAPPED
|
48
|
-
Ncurses::WRAPPED
|
49
|
-
end
|
50
|
-
def Ncurses._NOCHANGE
|
51
|
-
Ncurses::NOCHANGE
|
52
|
-
end
|
53
|
-
def Ncurses._NEWINDEX
|
54
|
-
Ncurses::NEWINDEX
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
module Ncurses
|
59
|
-
module Destroy_checker; def destroyed?; @destroyed; end; end
|
60
|
-
class WINDOW
|
61
|
-
include Destroy_checker
|
62
|
-
def method_missing(name, *args)
|
63
|
-
name = name.to_s
|
64
|
-
if (name[0,2] == "mv")
|
65
|
-
test_name = name.dup
|
66
|
-
test_name[2,0] = "w" # insert "w" after"mv"
|
67
|
-
if (Ncurses.respond_to?(test_name))
|
68
|
-
return Ncurses.send(test_name, self, *args)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
test_name = "w" + name
|
72
|
-
if (Ncurses.respond_to?(test_name))
|
73
|
-
return Ncurses.send(test_name, self, *args)
|
74
|
-
end
|
75
|
-
Ncurses.send(name, self, *args)
|
76
|
-
end
|
77
|
-
def respond_to?(name)
|
78
|
-
name = name.to_s
|
79
|
-
if (name[0,2] == "mv" && Ncurses.respond_to?("mvw" + name[2..-1]))
|
80
|
-
return true
|
81
|
-
end
|
82
|
-
Ncurses.respond_to?("w" + name) || Ncurses.respond_to?(name)
|
83
|
-
end
|
84
|
-
def del
|
85
|
-
Ncurses.delwin(self)
|
86
|
-
end
|
87
|
-
alias delete del
|
88
|
-
def WINDOW.new(*args)
|
89
|
-
Ncurses.newwin(*args)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
class SCREEN
|
93
|
-
include Destroy_checker
|
94
|
-
def del
|
95
|
-
Ncurses.delscreen(self)
|
96
|
-
end
|
97
|
-
alias delete del
|
98
|
-
end
|
99
|
-
class MEVENT
|
100
|
-
attr_accessor :id, :x,:y,:z, :bstate
|
101
|
-
end
|
102
|
-
GETSTR_LIMIT = 1024
|
103
|
-
|
104
|
-
module Panel
|
105
|
-
class PANEL; end
|
106
|
-
end
|
107
|
-
|
108
|
-
module Form
|
109
|
-
class FORM
|
110
|
-
attr_reader :user_object
|
111
|
-
|
112
|
-
# This placeholder replaces the form_userptr function in curses
|
113
|
-
def user_object=(obj)
|
114
|
-
@user_object = obj
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
class FIELD
|
119
|
-
attr_reader :user_object
|
120
|
-
|
121
|
-
# This placeholder replaces the field_userptr function in curses
|
122
|
-
def user_object=(obj)
|
123
|
-
@user_object = obj
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
class FIELDTYPE
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
module Menu
|
132
|
-
class MENU
|
133
|
-
attr_reader :user_object
|
134
|
-
|
135
|
-
# This placeholder replaces the menu_userptr function in curses
|
136
|
-
def user_object=(obj)
|
137
|
-
@user_object = obj
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
class ITEM
|
142
|
-
attr_reader :user_object
|
143
|
-
|
144
|
-
# This placeholder replaces the item_userptr function in curses
|
145
|
-
def user_object=(obj)
|
146
|
-
@user_object = obj
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
def Ncurses.inchnstr(str,n)
|
152
|
-
Ncurses.winchnstr(Ncurses.stdscr, str, n)
|
153
|
-
end
|
154
|
-
def Ncurses.inchstr(str)
|
155
|
-
Ncurses.winchstr(Ncurses.stdscr, str)
|
156
|
-
end
|
157
|
-
def Ncurses.mvinchnstr(y,x, str, n)
|
158
|
-
Ncurses.mvwinchnstr(Ncurses.stdscr, y,x, str, n)
|
159
|
-
end
|
160
|
-
def Ncurses.mvinchstr(y,x, str)
|
161
|
-
Ncurses.mvwinchstr(Ncurses.stdscr, y,x, str)
|
162
|
-
end
|
163
|
-
def Ncurses.mvwinchnstr(win, y,x, str, n)
|
164
|
-
if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
|
165
|
-
Ncurses::ERR
|
166
|
-
else
|
167
|
-
Ncurses.winchnstr(win,str,n)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
def Ncurses.mvwinchstr(win, y,x, str)
|
171
|
-
maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
|
172
|
-
return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
|
173
|
-
Ncurses.mvwinchnstr(win, y,x, str, maxx[0]+1)
|
174
|
-
end
|
175
|
-
def Ncurses.winchstr(win, str)
|
176
|
-
maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
|
177
|
-
return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
|
178
|
-
Ncurses.winchnstr(win, str, maxx[0]+1)
|
179
|
-
end
|
180
|
-
|
181
|
-
def Ncurses.getnstr(str,n)
|
182
|
-
Ncurses.wgetnstr(Ncurses.stdscr, str, n)
|
183
|
-
end
|
184
|
-
def Ncurses.mvgetnstr(y,x, str, n)
|
185
|
-
Ncurses.mvwgetnstr(Ncurses.stdscr, y,x, str, n)
|
186
|
-
end
|
187
|
-
def Ncurses.mvwgetnstr(win, y,x, str, n)
|
188
|
-
if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
|
189
|
-
Ncurses::ERR
|
190
|
-
else
|
191
|
-
Ncurses.wgetnstr(win,str,n)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def Ncurses.innstr(str,n)
|
196
|
-
Ncurses.winnstr(Ncurses.stdscr, str, n)
|
197
|
-
end
|
198
|
-
def Ncurses.instr(str)
|
199
|
-
Ncurses.winstr(Ncurses.stdscr, str)
|
200
|
-
end
|
201
|
-
def Ncurses.mvinnstr(y,x, str, n)
|
202
|
-
Ncurses.mvwinnstr(Ncurses.stdscr, y,x, str, n)
|
203
|
-
end
|
204
|
-
def Ncurses.mvinstr(y,x, str)
|
205
|
-
Ncurses.mvwinstr(Ncurses.stdscr, y,x, str)
|
206
|
-
end
|
207
|
-
def Ncurses.mvwinnstr(win, y,x, str, n)
|
208
|
-
if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
|
209
|
-
Ncurses::ERR
|
210
|
-
else
|
211
|
-
Ncurses.winnstr(win,str,n)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
def Ncurses.mvwinstr(win, y,x, str)
|
215
|
-
maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
|
216
|
-
return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
|
217
|
-
Ncurses.mvwinnstr(win, y,x, str, maxx[0]+1)
|
218
|
-
end
|
219
|
-
def Ncurses.winstr(win, str)
|
220
|
-
maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
|
221
|
-
return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
|
222
|
-
Ncurses.winnstr(win, str, maxx[0]+1)
|
223
|
-
end
|
224
|
-
|
225
|
-
def Ncurses.mouse_trafo(pY, pX, to_screen)
|
226
|
-
Ncurses.wmouse_trafo(Ncurses.stdscr, pY, pX, to_screen)
|
227
|
-
end
|
228
|
-
|
229
|
-
def Ncurses.getcurx(win)
|
230
|
-
x = []; y = []; Ncurses.getyx(win, y,x); x[0]
|
231
|
-
end
|
232
|
-
def Ncurses.getcury(win)
|
233
|
-
x = []; y = []; Ncurses.getyx(win, y,x); y[0]
|
234
|
-
end
|
235
|
-
def Ncurses.getbegx(win)
|
236
|
-
x = []; y = []; Ncurses.getbegyx(win, y,x); x[0]
|
237
|
-
end
|
238
|
-
def Ncurses.getbegy(win)
|
239
|
-
x = []; y = []; Ncurses.getbegyx(win, y,x); y[0]
|
240
|
-
end
|
241
|
-
def Ncurses.getmaxx(win)
|
242
|
-
x = []; y = []; Ncurses.getmaxyx(win, y,x); x[0]
|
243
|
-
end
|
244
|
-
def Ncurses.getmaxy(win)
|
245
|
-
x = []; y = []; Ncurses.getmaxyx(win, y,x); y[0]
|
246
|
-
end
|
247
|
-
def Ncurses.getparx(win)
|
248
|
-
x = []; y = []; Ncurses.getparyx(win, y,x); x[0]
|
249
|
-
end
|
250
|
-
def Ncurses.getpary(win)
|
251
|
-
x = []; y = []; Ncurses.getparyx(win, y,x); y[0]
|
252
|
-
end
|
253
|
-
def Ncurses.erase
|
254
|
-
Ncurses.werase(Ncurses.stdscr)
|
255
|
-
end
|
256
|
-
def Ncurses.getstr(str)
|
257
|
-
Ncurses.getnstr(str, Ncurses::GETSTR_LIMIT)
|
258
|
-
end
|
259
|
-
def Ncurses.mvgetstr(y,x, str)
|
260
|
-
Ncurses.mvgetnstr(y,x, str, Ncurses::GETSTR_LIMIT)
|
261
|
-
end
|
262
|
-
def Ncurses.mvwgetstr(win, y,x, str)
|
263
|
-
Ncurses.mvwgetnstr(win, y,x, str, Ncurses::GETSTR_LIMIT)
|
264
|
-
end
|
265
|
-
def Ncurses.wgetstr(win, str)
|
266
|
-
Ncurses.wgetnstr(win, str, Ncurses::GETSTR_LIMIT)
|
267
|
-
end
|
268
|
-
|
269
|
-
def Ncurses.scanw(format, result)
|
270
|
-
Ncurses.wscanw(Ncurses.stdscr, format, result)
|
271
|
-
end
|
272
|
-
def Ncurses.mvscanw(y,x, format, result)
|
273
|
-
Ncurses.mvwscanw(Ncurses.stdscr, y,x, format, result)
|
274
|
-
end
|
275
|
-
def Ncurses.mvwscanw(win, y,x, format, result)
|
276
|
-
if (Ncurses.wmove(win, y,x) == Ncurses::ERR)
|
277
|
-
Ncurses::ERR
|
278
|
-
else
|
279
|
-
Ncurses.wscanw(win, format, result)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
def Ncurses.wscanw(win, format, result)
|
283
|
-
str = ""
|
284
|
-
if (Ncurses.wgetstr(win, str) == Ncurses::ERR)
|
285
|
-
Ncurses::ERR
|
286
|
-
else
|
287
|
-
require "scanf.rb" # Use ruby's implementation of scanf
|
288
|
-
result.replace(str.scanf(format))
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
def Ncurses.mvprintw(*args)
|
293
|
-
Ncurses.mvwprintw(Ncurses.stdscr, *args)
|
294
|
-
end
|
295
|
-
def Ncurses.mvwprintw(win, y,x, *args)
|
296
|
-
if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
|
297
|
-
Ncurses::ERR
|
298
|
-
else
|
299
|
-
wprintw(win, *args)
|
300
|
-
end
|
301
|
-
end
|
302
|
-
def Ncurses.printw(*args)
|
303
|
-
Ncurses.wprintw(Ncurses.stdscr, *args)
|
304
|
-
end
|
305
|
-
def Ncurses.touchline(win, start, count)
|
306
|
-
Ncurses.wtouchln(win, start, count, 1)
|
307
|
-
end
|
308
|
-
def Ncurses.touchwin(win)
|
309
|
-
wtouchln(win, 0, getmaxy(win), 1)
|
310
|
-
end
|
311
|
-
|
312
|
-
module Ncurses
|
313
|
-
Ncurses = self # for accessing Ncurses from a Module that includes Ncurses
|
314
|
-
|
315
|
-
# Some users like to include ncurses names despite namespace pollution
|
316
|
-
# This module is for them
|
317
|
-
module Namespace
|
318
|
-
def self.append_features(target)
|
319
|
-
# include constants
|
320
|
-
unless target.ancestors.member?(Ncurses)
|
321
|
-
target.__send__(:include, Ncurses)
|
322
|
-
end
|
323
|
-
|
324
|
-
# make methods available
|
325
|
-
unless target.respond_to?(:pre_Ncurses_method_missing)
|
326
|
-
target.module_eval{
|
327
|
-
alias pre_Ncurses_method_missing method_missing
|
328
|
-
def method_missing(name, *args)
|
329
|
-
if Ncurses.respond_to?(name)
|
330
|
-
Ncurses.send(name, *args)
|
331
|
-
else
|
332
|
-
pre_Ncurses_method_missing(name, *args)
|
333
|
-
end
|
334
|
-
end
|
335
|
-
}
|
336
|
-
end
|
337
|
-
end
|
338
|
-
def self.entend_object(object)
|
339
|
-
class << object
|
340
|
-
self
|
341
|
-
end.__send__(:include, self)
|
342
|
-
end
|
343
|
-
end
|
344
|
-
end
|
24
|
+
require "ncurses_sugar.rb"
|