newt 1.0.0.pre1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +6 -1
- data/examples/test-e.rb +9 -5
- data/examples/test-j.rb +9 -5
- data/examples/test_method/Checkbox.rb +7 -1
- data/examples/test_method/CheckboxTree.rb +2 -1
- data/examples/test_method/CheckboxTreeMulti.rb +2 -1
- data/examples/test_method/Entry.rb +5 -1
- data/examples/test_method/Form_ExitStruct.rb +2 -1
- data/examples/test_method/Listbox.rb +2 -1
- data/examples/test_method/RadioButton.rb +3 -1
- data/examples/test_method/ReflowText.rb +6 -16
- data/examples/testgrid-e.rb +0 -2
- data/ext/ruby_newt/extconf.rb +2 -0
- data/ext/ruby_newt/ruby_newt.c +175 -62
- data/lib/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfea6e7753c0686afc0a58ad7f83c8a3e0c364ef7eeeb92e1073106d74b82286
|
4
|
+
data.tar.gz: ace1bcde9cc75ea4bd3183b671acea3a2cc2f89062d709195f99665b978e0e01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29641680f8695cc982d04735eeb7b02ebbdeca99e1c54972868ac5f6bcd5b328ffba84478611459b99e38f2677f71a0254185a89f0326e6692fbecd148b4d359
|
7
|
+
data.tar.gz: 7e3436704b5649ca1c67f8e81077c51c08760f46cd8fc196e3f412a48bbf68c38bf6e7c9e67582282a6670a1fc466d3a74b39d8f76d806899c830fc765bbcb73
|
data/README.rdoc
CHANGED
@@ -21,6 +21,7 @@ See http://github.com/theforeman/ruby-newt/tree/master/examples for usage exampl
|
|
21
21
|
|
22
22
|
=== From source
|
23
23
|
|
24
|
+
$ gem install rake rake-compiler
|
24
25
|
$ git clone git://github.com/theforeman/ruby-newt
|
25
26
|
$ cd ruby-newt
|
26
27
|
$ gem build newt.gemspec
|
@@ -28,7 +29,9 @@ See http://github.com/theforeman/ruby-newt/tree/master/examples for usage exampl
|
|
28
29
|
|
29
30
|
=== Development
|
30
31
|
|
31
|
-
$
|
32
|
+
$ bundle install
|
33
|
+
$ bundle exec rake compile
|
34
|
+
$ bundle exec rake test
|
32
35
|
|
33
36
|
== REQUIREMENTS
|
34
37
|
|
@@ -77,6 +80,8 @@ programs using the ruby-newt library may need to be changed.
|
|
77
80
|
modify this hash directly will break.
|
78
81
|
* The various _add_callback_ methods no longer return the previously set
|
79
82
|
callback when called with no parameters.
|
83
|
+
* Use +get_current+ instead of +get+ for radiobuttons.
|
84
|
+
* Use +set_current+ instead of +set+ for radiobuttons.
|
80
85
|
|
81
86
|
== AUTHORS
|
82
87
|
|
data/examples/test-e.rb
CHANGED
@@ -49,7 +49,7 @@ e1 = Newt::Entry.new(12, 6, '', 20, 0)
|
|
49
49
|
e2 = Newt::Entry.new(12, 7, 'Default', 20, Newt::FLAG_SCROLL)
|
50
50
|
e3 = Newt::Entry.new(12, 8, '', 20, Newt::FLAG_HIDDEN)
|
51
51
|
|
52
|
-
cs[0].callback( proc {
|
52
|
+
cs[0].callback( proc { disable_callback(cs[0], e1) } )
|
53
53
|
scale = Newt::Scale.new(3, 14, 32, 100)
|
54
54
|
|
55
55
|
chklist.set_height(3)
|
@@ -93,13 +93,17 @@ end
|
|
93
93
|
Newt::Screen.pop_window
|
94
94
|
Newt::Screen.pop_window
|
95
95
|
|
96
|
+
e1 = e1.get
|
97
|
+
e2 = e2.get
|
98
|
+
e3 = e3.get
|
99
|
+
selected_list = lb.get_selection
|
100
|
+
|
96
101
|
Newt::Screen.finish
|
97
102
|
|
98
|
-
printf "got string 1: %s\n", e1
|
99
|
-
printf "got string 2: %s\n", e2
|
100
|
-
printf "got string 3: %s\n", e3
|
103
|
+
printf "got string 1: %s\n", e1
|
104
|
+
printf "got string 2: %s\n", e2
|
105
|
+
printf "got string 3: %s\n", e3
|
101
106
|
|
102
|
-
selected_list = lb.get_selection
|
103
107
|
if selected_list.count > 0
|
104
108
|
print "\nSelected listbox items:\n"
|
105
109
|
selected_list.each do |item|
|
data/examples/test-j.rb
CHANGED
@@ -49,7 +49,7 @@ e1 = Newt::Entry.new(12, 6, '', 20, 0)
|
|
49
49
|
e2 = Newt::Entry.new(12, 7, 'ɸ½à', 20, Newt::FLAG_SCROLL)
|
50
50
|
e3 = Newt::Entry.new(12, 8, '', 20, Newt::FLAG_HIDDEN)
|
51
51
|
|
52
|
-
cs[0].callback( proc {
|
52
|
+
cs[0].callback( proc { disable_callback(cs[0], e1) } )
|
53
53
|
scale = Newt::Scale.new(3, 14, 32, 100)
|
54
54
|
|
55
55
|
chklist.set_height(3)
|
@@ -93,13 +93,17 @@ end
|
|
93
93
|
Newt::Screen.pop_window
|
94
94
|
Newt::Screen.pop_window
|
95
95
|
|
96
|
+
e1 = e1.get
|
97
|
+
e2 = e2.get
|
98
|
+
e3 = e3.get
|
99
|
+
selected_list = lb.get_selection
|
100
|
+
|
96
101
|
Newt::Screen.finish
|
97
102
|
|
98
|
-
printf "got string 1: %s\n", e1
|
99
|
-
printf "got string 2: %s\n", e2
|
100
|
-
printf "got string 3: %s\n", e3
|
103
|
+
printf "got string 1: %s\n", e1
|
104
|
+
printf "got string 2: %s\n", e2
|
105
|
+
printf "got string 3: %s\n", e3
|
101
106
|
|
102
|
-
selected_list = lb.get_selection
|
103
107
|
if selected_list.count > 0
|
104
108
|
print "\nSelected listbox items:\n"
|
105
109
|
selected_list.each do |item|
|
@@ -20,8 +20,14 @@ begin
|
|
20
20
|
f.add(cb1, cb2, cb3, cb4, cb5, b)
|
21
21
|
|
22
22
|
f.run
|
23
|
+
|
24
|
+
cb1 = cb1.get
|
25
|
+
cb2 = cb2.get
|
26
|
+
cb3 = cb3.get
|
27
|
+
cb4 = cb4.get
|
28
|
+
cb5 = cb5.get
|
23
29
|
ensure
|
24
30
|
Newt::Screen.finish
|
25
31
|
end
|
26
32
|
|
27
|
-
p cb1
|
33
|
+
p cb1, cb2, cb3, cb4, cb5
|
@@ -49,11 +49,15 @@ begin
|
|
49
49
|
f.add(e1, e2, e3, b)
|
50
50
|
|
51
51
|
f.run
|
52
|
+
|
53
|
+
e1 = e1.get
|
54
|
+
e2 = e2.get
|
55
|
+
e3 = e3.get
|
52
56
|
ensure
|
53
57
|
Newt::Screen.finish
|
54
58
|
end
|
55
59
|
|
56
|
-
p e1
|
60
|
+
p e1, e2, e3
|
57
61
|
puts
|
58
62
|
puts "$widget = #{$widget}"
|
59
63
|
puts "$data = #{$data}"
|
@@ -21,6 +21,7 @@ begin
|
|
21
21
|
f.add(b1, b2, b)
|
22
22
|
|
23
23
|
rv = f.run
|
24
|
+
current = f.get_current
|
24
25
|
ensure
|
25
26
|
Newt::Screen.finish
|
26
27
|
end
|
@@ -29,7 +30,7 @@ puts rv.inspect
|
|
29
30
|
puts 'Button1' if rv == b1
|
30
31
|
puts 'Button2' if b2 == rv
|
31
32
|
puts 'Exit' if rv == b
|
32
|
-
puts 'Exit button is current button' if b ==
|
33
|
+
puts 'Exit button is current button' if b == current
|
33
34
|
puts 'Escape' if rv.reason == Newt::EXIT_HOTKEY && rv.key == ?\e.ord
|
34
35
|
puts 'Timeout' if rv.reason == Newt::EXIT_TIMER
|
35
36
|
puts 'FD Watch' if rv.reason == Newt::EXIT_FDREADY
|
@@ -3,22 +3,12 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'newt'
|
5
5
|
|
6
|
-
text = ''
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
text, width, height = Newt.reflow_text('This is a quite a bit of text. It is 40 ' \
|
14
|
-
'columns long, so some wrapping should be ' \
|
15
|
-
'done. Did you know that the quick, brown ' \
|
16
|
-
"fox jumped over the lazy dog?\n\n" \
|
17
|
-
"In other news, it's pretty important that we " \
|
18
|
-
'can properly force a line break.', 40, 5, 5)
|
19
|
-
ensure
|
20
|
-
Newt::Screen.finish
|
21
|
-
end
|
6
|
+
text, width, height = Newt.reflow_text('This is a quite a bit of text. It is 40 ' \
|
7
|
+
'columns long, so some wrapping should be ' \
|
8
|
+
'done. Did you know that the quick, brown ' \
|
9
|
+
"fox jumped over the lazy dog?\n\n" \
|
10
|
+
"In other news, it's pretty important that we " \
|
11
|
+
'can properly force a line break.', 40, 5, 5)
|
22
12
|
|
23
13
|
p text
|
24
14
|
p width
|
data/examples/testgrid-e.rb
CHANGED
@@ -26,7 +26,6 @@ f.add(b1, b2, b3, b4)
|
|
26
26
|
grid.wrapped_window('first window')
|
27
27
|
f.run
|
28
28
|
|
29
|
-
# f.destroy
|
30
29
|
Newt::Screen.pop_window
|
31
30
|
|
32
31
|
flowed_text, text_width, text_height = Newt.reflow_text('This is a quite a bit of text. It is 40 ' \
|
@@ -58,7 +57,6 @@ f.add(b1, t, b2)
|
|
58
57
|
f.run
|
59
58
|
|
60
59
|
Newt::Screen.pop_window
|
61
|
-
# f.destroy
|
62
60
|
|
63
61
|
Newt::Screen.win_message('Simple', 'Ok', 'This is a simple message window')
|
64
62
|
result = Newt::Screen.win_choice('Simple', 'Ok', 'Cancel', 'This is a simple choice window')
|
data/ext/ruby_newt/extconf.rb
CHANGED
data/ext/ruby_newt/ruby_newt.c
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
#include <ruby.h>
|
7
7
|
#include <newt.h>
|
8
8
|
|
9
|
+
static VALUE initialized = Qfalse;
|
10
|
+
|
9
11
|
static VALUE mNewt;
|
10
12
|
static VALUE mScreen;
|
11
13
|
static VALUE cWidget;
|
@@ -29,6 +31,7 @@ static VALUE cGrid;
|
|
29
31
|
static VALUE rb_ext_sCallback;
|
30
32
|
static struct newtColors newtColors;
|
31
33
|
|
34
|
+
#define PTR2NUM(ptr) (SIZET2NUM((size_t)(ptr)))
|
32
35
|
#define SYMBOL(str) (ID2SYM(rb_intern(str)))
|
33
36
|
#define PROC_CALL (rb_intern("call"))
|
34
37
|
#define RECEIVER(context) (rb_funcall((context), rb_intern("receiver"), 0))
|
@@ -36,14 +39,20 @@ static struct newtColors newtColors;
|
|
36
39
|
#define IVAR_COLS (rb_intern("newt_ivar_cols"))
|
37
40
|
#define IVAR_ROWS (rb_intern("newt_ivar_rows"))
|
38
41
|
#define IVAR_FILTER_CALLBACK (rb_intern("newt_ivar_filter_callback"))
|
39
|
-
#define
|
40
|
-
#define
|
41
|
-
#define
|
42
|
+
#define CVAR_SUSPEND_CALLBACK (rb_intern("newt_cvar_suspend_callback"))
|
43
|
+
#define CVAR_HELP_CALLBACK (rb_intern("newt_cvar_help_callback"))
|
44
|
+
#define CVAR_WIDGET_CALLBACK (rb_intern("newt_cvar_widget_callback"))
|
42
45
|
|
43
46
|
#define ARG_ERROR(given, expected) \
|
44
47
|
rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected %s)", \
|
45
48
|
(given), (expected))
|
46
49
|
|
50
|
+
#define INIT_GUARD() do { \
|
51
|
+
if (initialized == Qfalse) { \
|
52
|
+
rb_raise(rb_eRuntimeError, "libnewt is not initialized"); \
|
53
|
+
} \
|
54
|
+
} while (0)
|
55
|
+
|
47
56
|
#define FLAG_GC_FREE (1 << 0)
|
48
57
|
#define FLAG_ADDED_TO_FORM (1 << 1)
|
49
58
|
|
@@ -55,6 +64,12 @@ struct Widget_data_s {
|
|
55
64
|
int flags;
|
56
65
|
};
|
57
66
|
|
67
|
+
typedef struct rb_newt_ExitStruct_s rb_newt_ExitStruct;
|
68
|
+
struct rb_newt_ExitStruct_s {
|
69
|
+
struct newtExitStruct es;
|
70
|
+
VALUE components;
|
71
|
+
};
|
72
|
+
|
58
73
|
static void free_widget(void *ptr);
|
59
74
|
static void form_destroy(Widget_data *form);
|
60
75
|
|
@@ -76,6 +91,7 @@ static const rb_data_type_t Widget_type = {
|
|
76
91
|
|
77
92
|
#define Get_newtComponent(self, component) do { \
|
78
93
|
Widget_data *data; \
|
94
|
+
INIT_GUARD(); \
|
79
95
|
Get_Widget_Data((self), data); \
|
80
96
|
(component) = data->co; \
|
81
97
|
} while (0)
|
@@ -85,6 +101,7 @@ static inline VALUE widget_data_make(VALUE klass, newtComponent co, bool gc_free
|
|
85
101
|
Widget_data *data;
|
86
102
|
VALUE self = TypedData_Make_Struct(klass, Widget_data, &Widget_type, data);
|
87
103
|
data->self = self;
|
104
|
+
data->components = Qnil;
|
88
105
|
data->co = co;
|
89
106
|
data->flags |= gc_free;
|
90
107
|
return self;
|
@@ -122,6 +139,12 @@ static void form_destroy(Widget_data *form)
|
|
122
139
|
rb_gc_unregister_address(&form->components);
|
123
140
|
}
|
124
141
|
|
142
|
+
static void rb_newt_es_free(rb_newt_ExitStruct *rb_es)
|
143
|
+
{
|
144
|
+
rb_gc_unregister_address(&rb_es->components);
|
145
|
+
xfree(rb_es);
|
146
|
+
}
|
147
|
+
|
125
148
|
#define Data_Attach(self, data) do { \
|
126
149
|
VALUE ivar = get_newt_ivar((self)); \
|
127
150
|
rb_ary_push(ivar, (data)); \
|
@@ -161,23 +184,27 @@ static VALUE rb_ext_ColorSetCustom(VALUE self, VALUE id)
|
|
161
184
|
return INT2NUM(NEWT_COLORSET_CUSTOM(NUM2INT(id)));
|
162
185
|
}
|
163
186
|
|
164
|
-
static VALUE
|
187
|
+
static VALUE rb_ext_Screen_Init()
|
165
188
|
{
|
189
|
+
if (initialized == Qtrue)
|
190
|
+
return Qnil;
|
191
|
+
|
166
192
|
newtInit();
|
167
|
-
newtCls();
|
168
193
|
memcpy(&newtColors, &newtDefaultColorPalette, sizeof(struct newtColors));
|
194
|
+
initialized = Qtrue;
|
169
195
|
return Qnil;
|
170
196
|
}
|
171
197
|
|
172
|
-
static VALUE
|
198
|
+
static VALUE rb_ext_Screen_new()
|
173
199
|
{
|
174
|
-
|
175
|
-
|
200
|
+
rb_ext_Screen_Init();
|
201
|
+
newtCls();
|
176
202
|
return Qnil;
|
177
203
|
}
|
178
204
|
|
179
205
|
static VALUE rb_ext_Screen_Cls()
|
180
206
|
{
|
207
|
+
INIT_GUARD();
|
181
208
|
newtCls();
|
182
209
|
return Qnil;
|
183
210
|
}
|
@@ -185,17 +212,20 @@ static VALUE rb_ext_Screen_Cls()
|
|
185
212
|
static VALUE rb_ext_Screen_Finished()
|
186
213
|
{
|
187
214
|
newtFinished();
|
215
|
+
initialized = Qfalse;
|
188
216
|
return Qnil;
|
189
217
|
}
|
190
218
|
|
191
219
|
static VALUE rb_ext_Screen_WaitForKey()
|
192
220
|
{
|
221
|
+
INIT_GUARD();
|
193
222
|
newtWaitForKey();
|
194
223
|
return Qnil;
|
195
224
|
}
|
196
225
|
|
197
226
|
static VALUE rb_ext_Screen_ClearKeyBuffer()
|
198
227
|
{
|
228
|
+
INIT_GUARD();
|
199
229
|
newtClearKeyBuffer();
|
200
230
|
return Qnil;
|
201
231
|
}
|
@@ -203,17 +233,20 @@ static VALUE rb_ext_Screen_ClearKeyBuffer()
|
|
203
233
|
static VALUE rb_ext_Screen_OpenWindow(VALUE self, VALUE left, VALUE top,
|
204
234
|
VALUE width, VALUE height, VALUE title)
|
205
235
|
{
|
236
|
+
INIT_GUARD();
|
206
237
|
return INT2NUM(newtOpenWindow(NUM2INT(left), NUM2INT(top), NUM2INT(width),
|
207
238
|
NUM2INT(height), StringValuePtr(title)));
|
208
239
|
}
|
209
240
|
|
210
241
|
static VALUE rb_ext_Screen_CenteredWindow(VALUE self, VALUE width, VALUE height, VALUE title)
|
211
242
|
{
|
243
|
+
INIT_GUARD();
|
212
244
|
return INT2NUM(newtCenteredWindow(NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
|
213
245
|
}
|
214
246
|
|
215
247
|
static VALUE rb_ext_Screen_PopWindow(VALUE self)
|
216
248
|
{
|
249
|
+
INIT_GUARD();
|
217
250
|
newtPopWindow();
|
218
251
|
return Qnil;
|
219
252
|
}
|
@@ -361,43 +394,50 @@ static VALUE rb_ext_Screen_SetColors(VALUE self, VALUE colors)
|
|
361
394
|
{
|
362
395
|
Check_Type(colors, T_HASH);
|
363
396
|
rb_hash_foreach(colors, rb_ext_Colors_callback_function, (VALUE) &newtColors);
|
397
|
+
|
398
|
+
INIT_GUARD();
|
364
399
|
newtSetColors(newtColors);
|
365
400
|
return Qnil;
|
366
401
|
}
|
367
402
|
|
368
403
|
static VALUE rb_ext_Screen_SetColor(VALUE self, VALUE colorset, VALUE fg, VALUE bg)
|
369
404
|
{
|
405
|
+
INIT_GUARD();
|
370
406
|
newtSetColor(NUM2INT(colorset), StringValuePtr(fg), StringValuePtr(bg));
|
371
407
|
return Qnil;
|
372
408
|
}
|
373
409
|
|
374
410
|
static VALUE rb_ext_Screen_Resume()
|
375
411
|
{
|
412
|
+
INIT_GUARD();
|
376
413
|
newtResume();
|
377
414
|
return Qnil;
|
378
415
|
}
|
379
416
|
|
380
417
|
static VALUE rb_ext_Screen_Suspend()
|
381
418
|
{
|
419
|
+
INIT_GUARD();
|
382
420
|
newtSuspend();
|
383
421
|
return Qnil;
|
384
422
|
}
|
385
423
|
|
386
424
|
static VALUE rb_ext_Screen_Refresh()
|
387
425
|
{
|
426
|
+
INIT_GUARD();
|
388
427
|
newtRefresh();
|
389
428
|
return Qnil;
|
390
429
|
}
|
391
430
|
|
392
431
|
static VALUE rb_ext_Screen_DrawRootText(VALUE self, VALUE col, VALUE row, VALUE text)
|
393
432
|
{
|
394
|
-
|
433
|
+
INIT_GUARD();
|
395
434
|
newtDrawRootText(NUM2INT(col), NUM2INT(row), StringValuePtr(text));
|
396
435
|
return Qnil;
|
397
436
|
}
|
398
437
|
|
399
438
|
static VALUE rb_ext_Screen_PushHelpLine(VALUE self, VALUE text)
|
400
439
|
{
|
440
|
+
INIT_GUARD();
|
401
441
|
newtPushHelpLine(StringValuePtr(text));
|
402
442
|
|
403
443
|
return Qnil;
|
@@ -405,30 +445,35 @@ static VALUE rb_ext_Screen_PushHelpLine(VALUE self, VALUE text)
|
|
405
445
|
|
406
446
|
static VALUE rb_ext_Screen_RedrawHelpLine(VALUE self)
|
407
447
|
{
|
448
|
+
INIT_GUARD();
|
408
449
|
newtRedrawHelpLine();
|
409
450
|
return Qnil;
|
410
451
|
}
|
411
452
|
|
412
453
|
static VALUE rb_ext_Screen_PopHelpLine(VALUE self)
|
413
454
|
{
|
455
|
+
INIT_GUARD();
|
414
456
|
newtPopHelpLine();
|
415
457
|
return Qnil;
|
416
458
|
}
|
417
459
|
|
418
460
|
static VALUE rb_ext_Screen_Bell(VALUE self)
|
419
461
|
{
|
462
|
+
INIT_GUARD();
|
420
463
|
newtBell();
|
421
464
|
return Qnil;
|
422
465
|
}
|
423
466
|
|
424
467
|
static VALUE rb_ext_Screen_CursorOff(VALUE self)
|
425
468
|
{
|
469
|
+
INIT_GUARD();
|
426
470
|
newtCursorOff();
|
427
471
|
return Qnil;
|
428
472
|
}
|
429
473
|
|
430
474
|
static VALUE rb_ext_Screen_CursorOn(VALUE self)
|
431
475
|
{
|
476
|
+
INIT_GUARD();
|
432
477
|
newtCursorOn();
|
433
478
|
return Qnil;
|
434
479
|
}
|
@@ -437,12 +482,14 @@ static VALUE rb_ext_Screen_Size(VALUE self)
|
|
437
482
|
{
|
438
483
|
int cols, rows;
|
439
484
|
|
485
|
+
INIT_GUARD();
|
440
486
|
newtGetScreenSize(&cols, &rows);
|
441
487
|
return rb_ary_new_from_args(2, INT2NUM(cols), INT2NUM(rows));
|
442
488
|
}
|
443
489
|
|
444
490
|
static VALUE rb_ext_Screen_WinMessage(VALUE self, VALUE title, VALUE button, VALUE text)
|
445
491
|
{
|
492
|
+
INIT_GUARD();
|
446
493
|
newtWinMessage(StringValuePtr(title), StringValuePtr(button), StringValuePtr(text));
|
447
494
|
return Qnil;
|
448
495
|
}
|
@@ -450,6 +497,8 @@ static VALUE rb_ext_Screen_WinMessage(VALUE self, VALUE title, VALUE button, VAL
|
|
450
497
|
static VALUE rb_ext_Screen_WinChoice(VALUE self, VALUE title, VALUE button1, VALUE button2, VALUE text)
|
451
498
|
{
|
452
499
|
int result;
|
500
|
+
|
501
|
+
INIT_GUARD();
|
453
502
|
result = newtWinChoice(StringValuePtr(title), StringValuePtr(button1),
|
454
503
|
StringValuePtr(button2), StringValuePtr(text));
|
455
504
|
return INT2NUM(result);
|
@@ -467,6 +516,7 @@ static VALUE rb_ext_Screen_WinMenu(VALUE self, VALUE args)
|
|
467
516
|
if (len < 8 || len > 9)
|
468
517
|
ARG_ERROR(len, "8..9");
|
469
518
|
|
519
|
+
INIT_GUARD();
|
470
520
|
title = StringValuePtr(RARRAY_PTR(args)[0]);
|
471
521
|
text = StringValuePtr(RARRAY_PTR(args)[1]);
|
472
522
|
width = NUM2INT(RARRAY_PTR(args)[2]);
|
@@ -504,6 +554,7 @@ static VALUE rb_ext_Screen_WinEntries(VALUE self, VALUE args)
|
|
504
554
|
if (len < 8 || len > 9)
|
505
555
|
ARG_ERROR(len, "8..9");
|
506
556
|
|
557
|
+
INIT_GUARD();
|
507
558
|
title = StringValuePtr(RARRAY_PTR(args)[0]);
|
508
559
|
text = StringValuePtr(RARRAY_PTR(args)[1]);
|
509
560
|
width = NUM2INT(RARRAY_PTR(args)[2]);
|
@@ -555,7 +606,7 @@ void rb_ext_Screen_help_callback_function(newtComponent co, void *data)
|
|
555
606
|
VALUE context, callback;
|
556
607
|
|
557
608
|
widget = Make_Widget_Ref(cForm, co);
|
558
|
-
cb =
|
609
|
+
cb = rb_cvar_get(mScreen, CVAR_HELP_CALLBACK);
|
559
610
|
context = RSTRUCT_GET((VALUE) cb, 1);
|
560
611
|
callback = RSTRUCT_GET((VALUE) cb, 2);
|
561
612
|
|
@@ -610,19 +661,23 @@ static VALUE rb_ext_Screen_SuspendCallback(int argc, VALUE *argv, VALUE self)
|
|
610
661
|
if (argc < 1 || argc > 2)
|
611
662
|
ARG_ERROR(argc, "1 or 2");
|
612
663
|
|
664
|
+
INIT_GUARD();
|
613
665
|
if (argc == 2)
|
614
666
|
data = argv[1];
|
615
667
|
|
616
668
|
cb = rb_struct_new(rb_ext_sCallback, self, rb_binding_new(), argv[0], data, NULL);
|
617
|
-
|
669
|
+
rb_obj_freeze(cb);
|
670
|
+
rb_cvar_set(self, CVAR_SUSPEND_CALLBACK, cb);
|
618
671
|
newtSetSuspendCallback(rb_ext_Screen_suspend_callback_function, (void *) cb);
|
619
672
|
return Qnil;
|
620
673
|
}
|
621
674
|
|
622
675
|
static VALUE rb_ext_Screen_HelpCallback(VALUE self, VALUE cb)
|
623
676
|
{
|
677
|
+
INIT_GUARD();
|
624
678
|
cb = rb_struct_new(rb_ext_sCallback, Qnil, rb_binding_new(), cb, Qnil, NULL);
|
625
|
-
|
679
|
+
rb_obj_freeze(cb);
|
680
|
+
rb_cvar_set(self, CVAR_HELP_CALLBACK, cb);
|
626
681
|
newtSetHelpCallback(rb_ext_Screen_help_callback_function);
|
627
682
|
return Qnil;
|
628
683
|
}
|
@@ -635,12 +690,14 @@ static VALUE rb_ext_Widget_callback(int argc, VALUE *argv, VALUE self)
|
|
635
690
|
if (argc < 1 || argc > 2)
|
636
691
|
ARG_ERROR(argc, "1 or 2");
|
637
692
|
|
693
|
+
INIT_GUARD();
|
638
694
|
if (argc == 2)
|
639
695
|
data = argv[1];
|
640
696
|
|
641
697
|
Get_newtComponent(self, co);
|
642
698
|
cb = rb_struct_new(rb_ext_sCallback, self, rb_binding_new(), argv[0], data, NULL);
|
643
|
-
|
699
|
+
rb_obj_freeze(cb);
|
700
|
+
rb_cvar_set(self, CVAR_WIDGET_CALLBACK, cb);
|
644
701
|
newtComponentAddCallback(co, rb_ext_Widget_callback_function, (void *) cb);
|
645
702
|
return Qnil;
|
646
703
|
}
|
@@ -683,94 +740,117 @@ static VALUE rb_ext_Widget_equal(VALUE self, VALUE obj)
|
|
683
740
|
if (self == obj) return Qtrue;
|
684
741
|
|
685
742
|
if (rb_obj_is_kind_of(obj, cWidget) || rb_obj_is_kind_of(obj, cExitStruct)) {
|
686
|
-
|
743
|
+
Get_Widget_Data(self, data);
|
744
|
+
co = ((Widget_data *) data)->co;
|
687
745
|
if (rb_obj_is_kind_of(obj, cExitStruct)) {
|
688
|
-
Data_Get_Struct(obj,
|
689
|
-
if (co == ((
|
746
|
+
Data_Get_Struct(obj, rb_newt_ExitStruct, data);
|
747
|
+
if (co == (((rb_newt_ExitStruct *) data)->es.u.co))
|
690
748
|
return Qtrue;
|
691
749
|
} else {
|
692
|
-
|
750
|
+
Get_Widget_Data(obj, data);
|
751
|
+
cco = ((Widget_data *) data)->co;
|
693
752
|
if (co == cco) return Qtrue;
|
694
753
|
}
|
695
754
|
}
|
696
755
|
return Qfalse;
|
697
756
|
}
|
698
757
|
|
758
|
+
static VALUE rb_ext_Widget_inspect(VALUE self)
|
759
|
+
{
|
760
|
+
newtComponent co;
|
761
|
+
void *data;
|
762
|
+
|
763
|
+
VALUE classname = rb_class_name(rb_obj_class(self));
|
764
|
+
char *class = StringValuePtr(classname);
|
765
|
+
|
766
|
+
Get_Widget_Data(self, data);
|
767
|
+
co = ((Widget_data *) data)->co;
|
768
|
+
return rb_sprintf("#<%s:%p component=%p>", class, (void *) self, co);
|
769
|
+
}
|
770
|
+
|
699
771
|
static VALUE rb_ext_ExitStruct_reason(VALUE self)
|
700
772
|
{
|
701
|
-
|
773
|
+
rb_newt_ExitStruct *rb_es;
|
702
774
|
|
703
|
-
Data_Get_Struct(self,
|
704
|
-
return INT2NUM(es
|
775
|
+
Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
|
776
|
+
return INT2NUM(rb_es->es.reason);
|
705
777
|
}
|
706
778
|
|
707
779
|
static VALUE rb_ext_ExitStruct_watch(VALUE self)
|
708
780
|
{
|
709
|
-
|
781
|
+
rb_newt_ExitStruct *rb_es;
|
710
782
|
|
711
|
-
Data_Get_Struct(self,
|
712
|
-
if (es
|
713
|
-
return INT2NUM(es
|
783
|
+
Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
|
784
|
+
if (rb_es->es.reason == NEWT_EXIT_FDREADY)
|
785
|
+
return INT2NUM(rb_es->es.u.watch);
|
714
786
|
else
|
715
787
|
return Qnil;
|
716
788
|
}
|
717
789
|
|
718
790
|
static VALUE rb_ext_ExitStruct_key(VALUE self)
|
719
791
|
{
|
720
|
-
|
792
|
+
rb_newt_ExitStruct *rb_es;
|
721
793
|
|
722
|
-
Data_Get_Struct(self,
|
723
|
-
if (es
|
724
|
-
return INT2NUM(es
|
794
|
+
Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
|
795
|
+
if (rb_es->es.reason == NEWT_EXIT_HOTKEY)
|
796
|
+
return INT2NUM(rb_es->es.u.key);
|
725
797
|
else
|
726
798
|
return Qnil;
|
727
799
|
}
|
728
800
|
|
729
801
|
static VALUE rb_ext_ExitStruct_component(VALUE self)
|
730
802
|
{
|
731
|
-
|
803
|
+
rb_newt_ExitStruct *rb_es;
|
732
804
|
|
733
|
-
Data_Get_Struct(self,
|
734
|
-
if (es
|
735
|
-
|
736
|
-
else
|
737
|
-
|
805
|
+
Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
|
806
|
+
if (rb_es->es.reason == NEWT_EXIT_COMPONENT) {
|
807
|
+
return rb_hash_aref(rb_es->components, PTR2NUM(rb_es->es.u.co));
|
808
|
+
} else {
|
809
|
+
return Qnil;
|
810
|
+
}
|
738
811
|
}
|
739
812
|
|
740
813
|
static VALUE rb_ext_ExitStruct_equal(VALUE self, VALUE obj)
|
741
814
|
{
|
742
|
-
|
815
|
+
rb_newt_ExitStruct *rb_es;
|
743
816
|
newtComponent co;
|
817
|
+
void *data;
|
744
818
|
|
745
819
|
if (NIL_P(obj)) return Qfalse;
|
746
820
|
if (self == obj) return Qtrue;
|
747
821
|
|
748
822
|
/* Compare components for backwards compatibility with newtRunForm(). */
|
749
823
|
if (rb_obj_is_kind_of(obj, cWidget)) {
|
750
|
-
Data_Get_Struct(self,
|
751
|
-
|
752
|
-
|
824
|
+
Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
|
825
|
+
Get_Widget_Data(obj, data);
|
826
|
+
co = ((Widget_data *) data)->co;
|
827
|
+
if (rb_es->es.reason == NEWT_EXIT_COMPONENT
|
828
|
+
&& rb_es->es.u.co == co) return Qtrue;
|
753
829
|
}
|
754
830
|
return Qfalse;
|
755
831
|
}
|
756
832
|
|
757
833
|
static VALUE rb_ext_ExitStruct_inspect(VALUE self)
|
758
834
|
{
|
759
|
-
|
835
|
+
rb_newt_ExitStruct *rb_es;
|
760
836
|
VALUE classname = rb_class_name(rb_obj_class(self));
|
761
837
|
char *class = StringValuePtr(classname);
|
762
838
|
|
763
|
-
Data_Get_Struct(self,
|
764
|
-
switch(es
|
839
|
+
Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
|
840
|
+
switch(rb_es->es.reason) {
|
765
841
|
case NEWT_EXIT_HOTKEY:
|
766
|
-
return rb_sprintf("#<%s reason=%d, key=%d>", class,
|
842
|
+
return rb_sprintf("#<%s:%p reason=%d, key=%d>", class, (void *) self,
|
843
|
+
rb_es->es.reason, rb_es->es.u.key);
|
767
844
|
case NEWT_EXIT_COMPONENT:
|
768
|
-
return rb_sprintf("#<%s reason=%d, component=%p>", class,
|
845
|
+
return rb_sprintf("#<%s:%p reason=%d, component=%p>", class, (void *) self,
|
846
|
+
rb_es->es.reason, rb_es->es.u.co);
|
769
847
|
case NEWT_EXIT_FDREADY:
|
770
|
-
return rb_sprintf("#<%s reason=%d, watch=%d>", class,
|
848
|
+
return rb_sprintf("#<%s:%p reason=%d, watch=%d>", class, (void *) self,
|
849
|
+
rb_es->es.reason, rb_es->es.u.watch);
|
771
850
|
case NEWT_EXIT_TIMER:
|
772
851
|
case NEWT_EXIT_ERROR:
|
773
|
-
return rb_sprintf("#<%s reason=%d>", class,
|
852
|
+
return rb_sprintf("#<%s:%p reason=%d>", class, (void *) self,
|
853
|
+
rb_es->es.reason);
|
774
854
|
default:
|
775
855
|
return rb_call_super(0, NULL);
|
776
856
|
}
|
@@ -780,16 +860,17 @@ static VALUE rb_ext_Label_new(VALUE self, VALUE left, VALUE top, VALUE text)
|
|
780
860
|
{
|
781
861
|
newtComponent co;
|
782
862
|
|
863
|
+
INIT_GUARD();
|
783
864
|
co = newtLabel(NUM2INT(left), NUM2INT(top), StringValuePtr(text));
|
784
865
|
return Make_Widget(self, co);
|
785
866
|
}
|
786
867
|
|
787
868
|
static VALUE rb_ext_Label_SetText(VALUE self, VALUE text)
|
788
869
|
{
|
789
|
-
|
870
|
+
newtComponent co;
|
790
871
|
|
791
|
-
|
792
|
-
newtLabelSetText(
|
872
|
+
Get_newtComponent(self, co);
|
873
|
+
newtLabelSetText(co, StringValuePtr(text));
|
793
874
|
return Qnil;
|
794
875
|
}
|
795
876
|
|
@@ -806,6 +887,7 @@ static VALUE rb_ext_CompactButton_new(VALUE self, VALUE left, VALUE top, VALUE t
|
|
806
887
|
{
|
807
888
|
newtComponent co;
|
808
889
|
|
890
|
+
INIT_GUARD();
|
809
891
|
co = newtCompactButton(NUM2INT(left), NUM2INT(top), StringValuePtr(text));
|
810
892
|
return Make_Widget(self, co);
|
811
893
|
}
|
@@ -814,6 +896,7 @@ static VALUE rb_ext_Button_new(VALUE self, VALUE left, VALUE top, VALUE text)
|
|
814
896
|
{
|
815
897
|
newtComponent co;
|
816
898
|
|
899
|
+
INIT_GUARD();
|
817
900
|
co = newtButton(NUM2INT(left), NUM2INT(top), StringValuePtr(text));
|
818
901
|
return Make_Widget(self, co);
|
819
902
|
}
|
@@ -827,6 +910,7 @@ static VALUE rb_ext_Checkbox_new(int argc, VALUE *argv, VALUE self)
|
|
827
910
|
if (argc < 3 || argc > 5)
|
828
911
|
ARG_ERROR(argc, "3..5");
|
829
912
|
|
913
|
+
INIT_GUARD();
|
830
914
|
if (argc > 3 && !NIL_P(argv[3]))
|
831
915
|
defValue = StringValuePtr(argv[3])[0];
|
832
916
|
|
@@ -883,6 +967,7 @@ static VALUE rb_ext_RadioButton_new(int argc, VALUE *argv, VALUE self)
|
|
883
967
|
if (argc < 3 || argc > 5)
|
884
968
|
ARG_ERROR(argc, "3..5");
|
885
969
|
|
970
|
+
INIT_GUARD();
|
886
971
|
if (argc >= 4)
|
887
972
|
is_default = NUM2INT(argv[3]);
|
888
973
|
|
@@ -919,7 +1004,9 @@ static VALUE rb_ext_Listbox_new(int argc, VALUE *argv, VALUE self)
|
|
919
1004
|
if (argc < 3 || argc > 4)
|
920
1005
|
ARG_ERROR(argc, "3..4");
|
921
1006
|
|
1007
|
+
INIT_GUARD();
|
922
1008
|
flags = (argc == 4) ? NUM2INT(argv[3]) : 0;
|
1009
|
+
|
923
1010
|
co = newtListbox(NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]), flags);
|
924
1011
|
return Make_Widget(self, co);
|
925
1012
|
}
|
@@ -1091,7 +1178,9 @@ static VALUE rb_ext_CheckboxTree_new(int argc, VALUE *argv, VALUE self)
|
|
1091
1178
|
if (argc < 3 || argc > 4)
|
1092
1179
|
ARG_ERROR(argc, "3..4");
|
1093
1180
|
|
1181
|
+
INIT_GUARD();
|
1094
1182
|
flags = (argc == 4) ? NUM2INT(argv[3]) : 0;
|
1183
|
+
|
1095
1184
|
co = newtCheckboxTree(NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]), flags);
|
1096
1185
|
return Make_Widget(self, co);
|
1097
1186
|
}
|
@@ -1213,11 +1302,13 @@ static VALUE rb_ext_CheckboxTreeMulti_new(int argc, VALUE *argv, VALUE self)
|
|
1213
1302
|
if (argc < 3 || argc > 5)
|
1214
1303
|
ARG_ERROR(argc, "3..5");
|
1215
1304
|
|
1305
|
+
INIT_GUARD();
|
1216
1306
|
seq = NULL;
|
1217
1307
|
if (argc >= 4 && !NIL_P(argv[3]) && RSTRING_LEN(argv[3]))
|
1218
1308
|
seq = StringValuePtr(argv[3]);
|
1219
1309
|
|
1220
1310
|
flags = (argc == 5) ? NUM2INT(argv[4]) : 0;
|
1311
|
+
|
1221
1312
|
co = newtCheckboxTreeMulti(NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]), seq, flags);
|
1222
1313
|
return Make_Widget(self, co);
|
1223
1314
|
}
|
@@ -1241,7 +1332,9 @@ static VALUE rb_ext_Textbox_new(int argc, VALUE *argv, VALUE self)
|
|
1241
1332
|
if (argc < 4 || argc > 5)
|
1242
1333
|
ARG_ERROR(argc, "4..5");
|
1243
1334
|
|
1335
|
+
INIT_GUARD();
|
1244
1336
|
flags = (argc == 5) ? NUM2INT(argv[4]) : 0;
|
1337
|
+
|
1245
1338
|
co = newtTextbox(NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]), NUM2INT(argv[3]), flags);
|
1246
1339
|
return Make_Widget(self, co);
|
1247
1340
|
}
|
@@ -1289,7 +1382,9 @@ static VALUE rb_ext_TextboxReflowed_new(int argc, VALUE *argv, VALUE self)
|
|
1289
1382
|
if (argc < 6 || argc > 7)
|
1290
1383
|
ARG_ERROR(argc, "6..7");
|
1291
1384
|
|
1385
|
+
INIT_GUARD();
|
1292
1386
|
flags = (argc == 7) ? NUM2INT(argv[6]) : 0;
|
1387
|
+
|
1293
1388
|
co = newtTextboxReflowed(NUM2INT(argv[0]), NUM2INT(argv[1]),
|
1294
1389
|
StringValuePtr(argv[2]), NUM2INT(argv[3]),
|
1295
1390
|
NUM2INT(argv[4]), NUM2INT(argv[5]), flags);
|
@@ -1306,6 +1401,7 @@ static VALUE rb_ext_Form_new(int argc, VALUE *argv, VALUE self)
|
|
1306
1401
|
if (argc > 3)
|
1307
1402
|
ARG_ERROR(argc, "0..3");
|
1308
1403
|
|
1404
|
+
INIT_GUARD();
|
1309
1405
|
helpTag = (argc >= 2) ? argv[1] : Qnil;
|
1310
1406
|
flags = (argc == 3) ? NUM2INT(argv[2]) : 0;
|
1311
1407
|
|
@@ -1329,9 +1425,10 @@ static VALUE rb_ext_Form_AddComponents(VALUE self, VALUE components)
|
|
1329
1425
|
VALUE str;
|
1330
1426
|
int i;
|
1331
1427
|
|
1428
|
+
INIT_GUARD();
|
1332
1429
|
Get_Widget_Data(self, form);
|
1333
|
-
if (RARRAY_LEN(components) > 0 &&
|
1334
|
-
form->components =
|
1430
|
+
if (RARRAY_LEN(components) > 0 && form->components == Qnil) {
|
1431
|
+
form->components = rb_hash_new();
|
1335
1432
|
rb_gc_register_address(&form->components);
|
1336
1433
|
}
|
1337
1434
|
|
@@ -1345,7 +1442,7 @@ static VALUE rb_ext_Form_AddComponents(VALUE self, VALUE components)
|
|
1345
1442
|
|
1346
1443
|
co->flags ^= FLAG_GC_FREE;
|
1347
1444
|
co->flags |= FLAG_ADDED_TO_FORM;
|
1348
|
-
|
1445
|
+
rb_hash_aset(form->components, PTR2NUM(co->co), RARRAY_PTR(components)[i]);
|
1349
1446
|
newtFormAddComponent(form->co, co->co);
|
1350
1447
|
}
|
1351
1448
|
return Qnil;
|
@@ -1399,13 +1496,16 @@ static VALUE rb_ext_Form_SetWidth(VALUE self, VALUE width)
|
|
1399
1496
|
|
1400
1497
|
static VALUE rb_ext_Form_Run(VALUE self)
|
1401
1498
|
{
|
1402
|
-
|
1403
|
-
|
1499
|
+
Widget_data *data;
|
1500
|
+
rb_newt_ExitStruct *rb_es;
|
1404
1501
|
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1502
|
+
INIT_GUARD();
|
1503
|
+
Get_Widget_Data(self, data);
|
1504
|
+
rb_es = ALLOC(rb_newt_ExitStruct);
|
1505
|
+
newtFormRun(data->co, &rb_es->es);
|
1506
|
+
rb_es->components = data->components;
|
1507
|
+
rb_gc_register_address(&rb_es->components);
|
1508
|
+
return Data_Wrap_Struct(cExitStruct, 0, rb_newt_es_free, rb_es);
|
1409
1509
|
}
|
1410
1510
|
|
1411
1511
|
static VALUE rb_ext_Form_DrawForm(VALUE self)
|
@@ -1457,7 +1557,9 @@ static VALUE rb_ext_Entry_new(int argc, VALUE *argv, VALUE self)
|
|
1457
1557
|
if (argc < 4 || argc > 5)
|
1458
1558
|
ARG_ERROR(argc, "4..5");
|
1459
1559
|
|
1560
|
+
INIT_GUARD();
|
1460
1561
|
flags = (argc == 5) ? NUM2INT(argv[4]) : 0;
|
1562
|
+
|
1461
1563
|
co = newtEntry(NUM2INT(argv[0]), NUM2INT(argv[1]), StringValuePtr(argv[2]),
|
1462
1564
|
NUM2INT(argv[3]), NULL, flags);
|
1463
1565
|
|
@@ -1507,6 +1609,7 @@ static VALUE rb_ext_Entry_SetFilter(int argc, VALUE *argv, VALUE self)
|
|
1507
1609
|
|
1508
1610
|
Get_newtComponent(self, co);
|
1509
1611
|
cb = rb_struct_new(rb_ext_sCallback, self, rb_binding_new(), argv[0], data, NULL);
|
1612
|
+
rb_obj_freeze(cb);
|
1510
1613
|
rb_ivar_set(self, IVAR_FILTER_CALLBACK, cb);
|
1511
1614
|
newtEntrySetFilter(co, rb_ext_Entry_filter_function, (void *) cb);
|
1512
1615
|
return Qnil;
|
@@ -1558,6 +1661,7 @@ static VALUE rb_ext_Scale_new(VALUE self, VALUE left, VALUE top, VALUE width, VA
|
|
1558
1661
|
{
|
1559
1662
|
newtComponent co;
|
1560
1663
|
|
1664
|
+
INIT_GUARD();
|
1561
1665
|
co = newtScale(NUM2INT(left), NUM2INT(top), NUM2INT(width), NUM2INT(fullValue));
|
1562
1666
|
return Make_Widget(self, co);
|
1563
1667
|
}
|
@@ -1592,6 +1696,7 @@ static VALUE rb_ext_Grid_new(VALUE self, VALUE cols, VALUE rows)
|
|
1592
1696
|
if (num_cols <= 0 || num_rows <= 0)
|
1593
1697
|
rb_raise(rb_eRuntimeError, "specified number of columns or rows should be greater than 0");
|
1594
1698
|
|
1699
|
+
INIT_GUARD();
|
1595
1700
|
grid = newtCreateGrid(num_cols, num_rows);
|
1596
1701
|
widget = Data_Wrap_Struct(self, 0, 0, grid);
|
1597
1702
|
rb_ivar_set(widget, IVAR_COLS, cols);
|
@@ -1615,10 +1720,13 @@ static VALUE rb_ext_Grid_SetField(VALUE self, VALUE col, VALUE row, VALUE type,
|
|
1615
1720
|
if (icol >= cols || irow >= rows)
|
1616
1721
|
rb_raise(rb_eRuntimeError, "attempting to set a field at an invalid position (%d, %d)", icol, irow);
|
1617
1722
|
|
1618
|
-
|
1723
|
+
INIT_GUARD();
|
1724
|
+
if (itype == NEWT_GRID_SUBGRID) {
|
1619
1725
|
Data_Get_Struct(val, struct grid_s, co);
|
1620
|
-
else
|
1621
|
-
|
1726
|
+
} else {
|
1727
|
+
Get_Widget_Data(val, co);
|
1728
|
+
co = ((Widget_data *) co)->co;
|
1729
|
+
}
|
1622
1730
|
|
1623
1731
|
Data_Get_Struct(self, struct grid_s, grid);
|
1624
1732
|
newtGridSetField(grid, icol, irow, itype, co, NUM2INT(padLeft),
|
@@ -1636,6 +1744,7 @@ static VALUE rb_ext_Grid_WrappedWindow(int argc, VALUE *argv, VALUE self)
|
|
1636
1744
|
if (argc != 1 && argc != 3)
|
1637
1745
|
ARG_ERROR(argc, "1 or 3");
|
1638
1746
|
|
1747
|
+
INIT_GUARD();
|
1639
1748
|
title = StringValuePtr(argv[0]);
|
1640
1749
|
Data_Get_Struct(self, struct grid_s, grid);
|
1641
1750
|
if (argc == 1) {
|
@@ -1651,6 +1760,7 @@ static VALUE rb_ext_Grid_GetSize(VALUE self)
|
|
1651
1760
|
newtGrid grid;
|
1652
1761
|
int width, height;
|
1653
1762
|
|
1763
|
+
INIT_GUARD();
|
1654
1764
|
Data_Get_Struct(self, struct grid_s, grid);
|
1655
1765
|
newtGridGetSize(grid, &width, &height);
|
1656
1766
|
return rb_ary_new_from_args(2, INT2NUM(width), INT2NUM(height));
|
@@ -1658,12 +1768,14 @@ static VALUE rb_ext_Grid_GetSize(VALUE self)
|
|
1658
1768
|
|
1659
1769
|
void Init_ruby_newt(){
|
1660
1770
|
mNewt = rb_define_module("Newt");
|
1771
|
+
rb_define_module_function(mNewt, "init", rb_ext_Screen_Init, 0);
|
1772
|
+
rb_define_module_function(mNewt, "finish", rb_ext_Screen_Finished, 0);
|
1661
1773
|
rb_define_module_function(mNewt, "delay", rb_ext_Delay, 1);
|
1662
1774
|
rb_define_module_function(mNewt, "reflow_text", rb_ext_ReflowText, 4);
|
1663
1775
|
|
1664
1776
|
mScreen = rb_define_class_under(mNewt, "Screen", rb_cObject);
|
1665
|
-
rb_define_module_function(mScreen, "new", rb_ext_Screen_new, 0);
|
1666
1777
|
rb_define_module_function(mScreen, "init", rb_ext_Screen_Init, 0);
|
1778
|
+
rb_define_module_function(mScreen, "new", rb_ext_Screen_new, 0);
|
1667
1779
|
rb_define_module_function(mScreen, "cls", rb_ext_Screen_Cls, 0);
|
1668
1780
|
rb_define_module_function(mScreen, "finish", rb_ext_Screen_Finished, 0);
|
1669
1781
|
rb_define_module_function(mScreen, "wait_for_key", rb_ext_Screen_WaitForKey, 0);
|
@@ -1691,7 +1803,7 @@ void Init_ruby_newt(){
|
|
1691
1803
|
rb_define_module_function(mScreen, "win_menu", rb_ext_Screen_WinMenu, -2);
|
1692
1804
|
rb_define_module_function(mScreen, "win_entries", rb_ext_Screen_WinEntries, -2);
|
1693
1805
|
|
1694
|
-
rb_ext_sCallback = rb_struct_define(
|
1806
|
+
rb_ext_sCallback = rb_struct_define("NewtCallback", "widget", "context", "callback", "data", NULL);
|
1695
1807
|
|
1696
1808
|
cWidget = rb_define_class_under(mNewt, "Widget", rb_cObject);
|
1697
1809
|
rb_define_method(cWidget, "callback", rb_ext_Widget_callback, -1);
|
@@ -1699,6 +1811,7 @@ void Init_ruby_newt(){
|
|
1699
1811
|
rb_define_method(cWidget, "get_position", rb_ext_Widget_GetPosition, 0);
|
1700
1812
|
rb_define_method(cWidget, "get_size", rb_ext_Widget_GetSize, 0);
|
1701
1813
|
rb_define_method(cWidget, "==", rb_ext_Widget_equal, 1);
|
1814
|
+
rb_define_method(cWidget, "inspect", rb_ext_Widget_inspect, 0);
|
1702
1815
|
|
1703
1816
|
cCompactButton = rb_define_class_under(mNewt, "CompactButton", cWidget);
|
1704
1817
|
rb_define_singleton_method(cCompactButton, "new", rb_ext_CompactButton_new, 3);
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noritsugu Nakamura
|
8
8
|
- Eric Sperano
|
9
9
|
- Lukas Zapletal
|
10
|
-
|
10
|
+
- Robert Gill
|
11
|
+
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date:
|
14
|
+
date: 2022-03-02 00:00:00.000000000 Z
|
14
15
|
dependencies: []
|
15
16
|
description: Ruby bindings for newt TUI library
|
16
17
|
email: foreman-dev@googlegroups.com
|
@@ -66,7 +67,7 @@ homepage: https://github.com/theforeman/ruby-newt
|
|
66
67
|
licenses:
|
67
68
|
- MIT
|
68
69
|
metadata: {}
|
69
|
-
post_install_message:
|
70
|
+
post_install_message:
|
70
71
|
rdoc_options: []
|
71
72
|
require_paths:
|
72
73
|
- lib
|
@@ -78,13 +79,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
79
|
version: '0'
|
79
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
|
-
- - "
|
82
|
+
- - ">="
|
82
83
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
84
|
+
version: '0'
|
84
85
|
requirements: []
|
85
|
-
|
86
|
-
|
87
|
-
signing_key:
|
86
|
+
rubygems_version: 3.1.6
|
87
|
+
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Ruby bindings for newt
|
90
90
|
test_files: []
|