newt 0.0.1 → 0.9.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.
- data/Manifest.txt +51 -0
- data/README.rdoc +14 -9
- data/examples/test-j.rb +117 -0
- data/examples/test.rb +94 -0
- data/examples/test_method/Button_new.rb +21 -0
- data/examples/test_method/Checkbox_get.rb +24 -0
- data/examples/test_method/Checkbox_new.rb +21 -0
- data/examples/test_method/Checkbox_set.rb +27 -0
- data/examples/test_method/Checkbox_set_flags.rb +27 -0
- data/examples/test_method/CompactButton_new.rb +21 -0
- data/examples/test_method/Entry_get.rb +25 -0
- data/examples/test_method/Entry_new.rb +22 -0
- data/examples/test_method/Entry_set.rb +25 -0
- data/examples/test_method/Entry_set_flags.rb +30 -0
- data/examples/test_method/Form_destroy.rb +32 -0
- data/examples/test_method/Form_set_background.rb +22 -0
- data/examples/test_method/Form_set_height.rb +25 -0
- data/examples/test_method/Form_set_width.rb +25 -0
- data/examples/test_method/Grid_new.rb +25 -0
- data/examples/test_method/Label_new.rb +21 -0
- data/examples/test_method/Label_setText.rb +24 -0
- data/examples/test_method/Listbox_clear.rb +24 -0
- data/examples/test_method/Listbox_current_bykey.rb +28 -0
- data/examples/test_method/Listbox_delete.rb +26 -0
- data/examples/test_method/Listbox_get_current.rb +27 -0
- data/examples/test_method/Listbox_insert.rb +23 -0
- data/examples/test_method/Listbox_new.rb +23 -0
- data/examples/test_method/Listbox_select.rb +26 -0
- data/examples/test_method/Listbox_set.rb +26 -0
- data/examples/test_method/Listbox_set_current.rb +25 -0
- data/examples/test_method/Listbox_set_width.rb +24 -0
- data/examples/test_method/Newt_FLAG_SCROLL.rb +20 -0
- data/examples/test_method/RadioButton_new.rb +21 -0
- data/examples/test_method/ReflowText.rb +26 -0
- data/examples/test_method/Scale_new.rb +21 -0
- data/examples/test_method/Scale_set.rb +21 -0
- data/examples/test_method/Screen_bell.rb +9 -0
- data/examples/test_method/Screen_cls.rb +11 -0
- data/examples/test_method/Screen_draw_roottext.rb +15 -0
- data/examples/test_method/Screen_init.rb +10 -0
- data/examples/test_method/Screen_pop_helpline.rb +17 -0
- data/examples/test_method/Screen_push_helpline.rb +15 -0
- data/examples/test_method/Screen_redraw_helpline.rb +17 -0
- data/examples/test_method/Screen_size.rb +14 -0
- data/examples/test_method/Screen_win_menu.rb +18 -0
- data/examples/test_method/TextboxReflowed_new.rb +22 -0
- data/examples/test_method/Textbox_get_num_lines.rb +26 -0
- data/examples/test_method/Textbox_new.rb +21 -0
- data/examples/test_method/Textbox_set_height.rb +24 -0
- data/examples/testgrid-j.rb +84 -0
- data/examples/testgrid.rb +82 -0
- data/examples/testtree-j.rb +54 -0
- data/examples/testtree.rb +53 -0
- data/ext/ruby_newt/ruby_newt.c +106 -104
- data/lib/newt.rb +1 -2
- metadata +57 -6
data/ext/ruby_newt/ruby_newt.c
CHANGED
@@ -55,7 +55,7 @@ rb_ext_ReflowText(VALUE self, VALUE text, VALUE width, VALUE flexDown, VALUE fle
|
|
55
55
|
char *p;
|
56
56
|
VALUE ary = rb_ary_new2(3);
|
57
57
|
|
58
|
-
p = newtReflowText(
|
58
|
+
p = newtReflowText(StringValuePtr(text), NUM2INT(width), NUM2INT(flexDown), NUM2INT(flexUp),
|
59
59
|
&actualWidth, &actualHeight);
|
60
60
|
|
61
61
|
rb_ary_push(ary, rb_str_new2(p));
|
@@ -116,13 +116,13 @@ rb_ext_Screen_OpenWindow(VALUE self, VALUE left, VALUE top,
|
|
116
116
|
VALUE width, VALUE height, VALUE title)
|
117
117
|
{
|
118
118
|
return INT2NUM(newtOpenWindow(NUM2INT(left), NUM2INT(top),
|
119
|
-
NUM2INT(width), NUM2INT(height),
|
119
|
+
NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
|
120
120
|
}
|
121
121
|
|
122
122
|
static VALUE
|
123
123
|
rb_ext_Screen_CenteredWindow(VALUE self, VALUE width, VALUE height, VALUE title)
|
124
124
|
{
|
125
|
-
return INT2NUM(newtCenteredWindow(NUM2INT(width), NUM2INT(height),
|
125
|
+
return INT2NUM(newtCenteredWindow(NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
|
126
126
|
}
|
127
127
|
|
128
128
|
static VALUE
|
@@ -161,14 +161,14 @@ static VALUE
|
|
161
161
|
rb_ext_Screen_DrawRootText(VALUE self, VALUE col, VALUE row, VALUE text)
|
162
162
|
{
|
163
163
|
|
164
|
-
newtDrawRootText(NUM2INT(col), NUM2INT(row),
|
164
|
+
newtDrawRootText(NUM2INT(col), NUM2INT(row), StringValuePtr(text));
|
165
165
|
return Qnil;
|
166
166
|
}
|
167
167
|
|
168
168
|
static VALUE
|
169
169
|
rb_ext_Screen_PushHelpLine(VALUE self, VALUE text)
|
170
170
|
{
|
171
|
-
newtPushHelpLine(
|
171
|
+
newtPushHelpLine(StringValuePtr(text));
|
172
172
|
|
173
173
|
return Qnil;
|
174
174
|
}
|
@@ -213,11 +213,11 @@ rb_ext_Screen_Size(VALUE self)
|
|
213
213
|
static VALUE
|
214
214
|
rb_ext_Screen_WinMessage(VALUE self, VALUE args)
|
215
215
|
{
|
216
|
-
if (
|
216
|
+
if (RARRAY_LEN(args) < 3) {
|
217
217
|
rb_raise(rb_eArgError, "3 arguments required");
|
218
218
|
} else {
|
219
219
|
|
220
|
-
newtWinMessage(
|
220
|
+
newtWinMessage(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]), StringValuePtr(RARRAY_PTR(args)[2]));
|
221
221
|
}
|
222
222
|
|
223
223
|
return Qnil;
|
@@ -226,12 +226,12 @@ rb_ext_Screen_WinMessage(VALUE self, VALUE args)
|
|
226
226
|
static VALUE
|
227
227
|
rb_ext_Screen_WinChoice(VALUE self, VALUE args)
|
228
228
|
{
|
229
|
-
if (
|
229
|
+
if (RARRAY_LEN(args) < 4) {
|
230
230
|
rb_raise(rb_eArgError, "4 arguments required");
|
231
231
|
} else {
|
232
232
|
|
233
|
-
newtWinChoice(
|
234
|
-
|
233
|
+
newtWinChoice(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
|
234
|
+
StringValuePtr(RARRAY_PTR(args)[2]), StringValuePtr(RARRAY_PTR(args)[3]));
|
235
235
|
}
|
236
236
|
|
237
237
|
return Qnil;
|
@@ -240,43 +240,44 @@ rb_ext_Screen_WinChoice(VALUE self, VALUE args)
|
|
240
240
|
static VALUE
|
241
241
|
rb_ext_Screen_WinMenu(VALUE self, VALUE args)
|
242
242
|
{
|
243
|
-
|
243
|
+
long len;
|
244
|
+
int i, listItem;
|
244
245
|
char **cptr;
|
245
246
|
|
246
|
-
len =
|
247
|
+
len = RARRAY_LEN(args);
|
247
248
|
if (len == 8) {
|
248
|
-
Check_Type(
|
249
|
+
Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
|
249
250
|
|
250
|
-
len =
|
251
|
+
len = RARRAY_LEN(RARRAY_PTR(args)[6]);
|
251
252
|
cptr = ALLOCA_N(char*, len + 1);
|
252
253
|
for (i = 0; i < len; i++) {
|
253
|
-
Check_Type(
|
254
|
-
cptr[i] =
|
254
|
+
Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
|
255
|
+
cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
|
255
256
|
}
|
256
257
|
cptr[len] = NULL;
|
257
258
|
|
258
|
-
newtWinMenu(
|
259
|
-
NUM2INT(
|
260
|
-
NUM2INT(
|
261
|
-
NUM2INT(
|
262
|
-
cptr, &listItem,
|
259
|
+
newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
|
260
|
+
NUM2INT(RARRAY_PTR(args)[2]),
|
261
|
+
NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
|
262
|
+
NUM2INT(RARRAY_PTR(args)[5]),
|
263
|
+
cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
|
263
264
|
return INT2NUM(listItem);
|
264
265
|
} else if (len == 9) {
|
265
|
-
Check_Type(
|
266
|
+
Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
|
266
267
|
|
267
|
-
len =
|
268
|
+
len = RARRAY_LEN(RARRAY_PTR(args)[6]);
|
268
269
|
cptr = ALLOCA_N(char*, len + 1);
|
269
270
|
for (i = 0; i < len; i++) {
|
270
|
-
Check_Type(
|
271
|
-
cptr[i] =
|
271
|
+
Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
|
272
|
+
cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
|
272
273
|
}
|
273
274
|
cptr[len] = NULL;
|
274
275
|
|
275
|
-
newtWinMenu(
|
276
|
-
NUM2INT(
|
277
|
-
NUM2INT(
|
278
|
-
NUM2INT(
|
279
|
-
cptr, &listItem,
|
276
|
+
newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
|
277
|
+
NUM2INT(RARRAY_PTR(args)[2]),
|
278
|
+
NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
|
279
|
+
NUM2INT(RARRAY_PTR(args)[5]),
|
280
|
+
cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
|
280
281
|
return INT2NUM(listItem);
|
281
282
|
} else {
|
282
283
|
rb_raise(rb_eArgError, "8 or 9 arguments required");
|
@@ -288,7 +289,8 @@ rb_ext_Screen_WinMenu(VALUE self, VALUE args)
|
|
288
289
|
static VALUE
|
289
290
|
rb_ext_Screen_WinEntries(VALUE self, VALUE args)
|
290
291
|
{
|
291
|
-
|
292
|
+
long len;
|
293
|
+
int i;
|
292
294
|
struct newtWinEntry *items;
|
293
295
|
char * entries[10];
|
294
296
|
VALUE ary;
|
@@ -296,16 +298,16 @@ rb_ext_Screen_WinEntries(VALUE self, VALUE args)
|
|
296
298
|
memset(entries, 0, sizeof(entries));
|
297
299
|
ary = rb_ary_new();
|
298
300
|
|
299
|
-
len =
|
301
|
+
len = RARRAY_LEN(args);
|
300
302
|
if (len == 8) {
|
301
|
-
Check_Type(
|
303
|
+
Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
|
302
304
|
|
303
|
-
len =
|
305
|
+
len = RARRAY_LEN(RARRAY_PTR(args)[6]);
|
304
306
|
if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
|
305
307
|
items = ALLOCA_N(struct newtWinEntry, len + 1);
|
306
308
|
for (i = 0; i < len; i++) {
|
307
|
-
Check_Type(
|
308
|
-
items[i].text =
|
309
|
+
Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
|
310
|
+
items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
|
309
311
|
items[i].value = entries + i;
|
310
312
|
items[i].flags = 0;
|
311
313
|
}
|
@@ -313,24 +315,24 @@ rb_ext_Screen_WinEntries(VALUE self, VALUE args)
|
|
313
315
|
items[len].value = NULL;
|
314
316
|
items[len].flags = 0;
|
315
317
|
|
316
|
-
newtWinEntries(
|
317
|
-
NUM2INT(
|
318
|
-
NUM2INT(
|
319
|
-
NUM2INT(
|
320
|
-
items,
|
318
|
+
newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
|
319
|
+
NUM2INT(RARRAY_PTR(args)[2]),
|
320
|
+
NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
|
321
|
+
NUM2INT(RARRAY_PTR(args)[5]),
|
322
|
+
items, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
|
321
323
|
for (i = 0; i < len; i++) {
|
322
324
|
rb_ary_push(ary, rb_str_new2(entries[i]));
|
323
325
|
}
|
324
326
|
return ary;
|
325
327
|
} else if (len == 9) {
|
326
|
-
Check_Type(
|
328
|
+
Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
|
327
329
|
|
328
|
-
len =
|
330
|
+
len = RARRAY_LEN(RARRAY_PTR(args)[6]);
|
329
331
|
if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
|
330
332
|
items = ALLOCA_N(struct newtWinEntry, len + 1);
|
331
333
|
for (i = 0; i < len; i++) {
|
332
|
-
Check_Type(
|
333
|
-
items[i].text =
|
334
|
+
Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
|
335
|
+
items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
|
334
336
|
items[i].value = entries + i;
|
335
337
|
items[i].flags = 0;
|
336
338
|
}
|
@@ -338,11 +340,11 @@ rb_ext_Screen_WinEntries(VALUE self, VALUE args)
|
|
338
340
|
items[len].value = NULL;
|
339
341
|
items[len].flags = 0;
|
340
342
|
|
341
|
-
newtWinEntries(
|
342
|
-
NUM2INT(
|
343
|
-
NUM2INT(
|
344
|
-
NUM2INT(
|
345
|
-
items,
|
343
|
+
newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
|
344
|
+
NUM2INT(RARRAY_PTR(args)[2]),
|
345
|
+
NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
|
346
|
+
NUM2INT(RARRAY_PTR(args)[5]),
|
347
|
+
items, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
|
346
348
|
for (i = 0; i < len; i++) {
|
347
349
|
rb_ary_push(ary, rb_str_new2(entries[i]));
|
348
350
|
}
|
@@ -411,7 +413,7 @@ rb_ext_Label_new(VALUE self, VALUE left, VALUE top, VALUE text)
|
|
411
413
|
{
|
412
414
|
newtComponent co;
|
413
415
|
|
414
|
-
co = newtLabel(NUM2INT(left), NUM2INT(top),
|
416
|
+
co = newtLabel(NUM2INT(left), NUM2INT(top), StringValuePtr(text));
|
415
417
|
return Data_Wrap_Struct(self, 0, 0, co);
|
416
418
|
}
|
417
419
|
|
@@ -421,7 +423,7 @@ rb_ext_Label_SetText(VALUE self, VALUE text)
|
|
421
423
|
newtComponent co;
|
422
424
|
|
423
425
|
Data_Get_Struct(self, struct newtComponent_struct, co);
|
424
|
-
newtLabelSetText(co,
|
426
|
+
newtLabelSetText(co, StringValuePtr(text));
|
425
427
|
return Qnil;
|
426
428
|
}
|
427
429
|
|
@@ -430,7 +432,7 @@ rb_ext_CompactButton_new(VALUE self, VALUE left, VALUE top, VALUE text)
|
|
430
432
|
{
|
431
433
|
newtComponent co;
|
432
434
|
|
433
|
-
co = newtCompactButton(NUM2INT(left), NUM2INT(top),
|
435
|
+
co = newtCompactButton(NUM2INT(left), NUM2INT(top), StringValuePtr(text));
|
434
436
|
return Data_Wrap_Struct(self, 0, 0, co);
|
435
437
|
}
|
436
438
|
|
@@ -439,7 +441,7 @@ rb_ext_Button_new(VALUE self, VALUE left, VALUE top, VALUE text)
|
|
439
441
|
{
|
440
442
|
newtComponent co;
|
441
443
|
|
442
|
-
co = newtButton(NUM2INT(left), NUM2INT(top),
|
444
|
+
co = newtButton(NUM2INT(left), NUM2INT(top), StringValuePtr(text));
|
443
445
|
return Data_Wrap_Struct(self, 0, 0, co);
|
444
446
|
}
|
445
447
|
|
@@ -450,11 +452,11 @@ rb_ext_Checkbox_new(VALUE self, VALUE left, VALUE top, VALUE text,
|
|
450
452
|
newtComponent co;
|
451
453
|
|
452
454
|
if (NIL_P(seq)) {
|
453
|
-
co = newtCheckbox(NUM2INT(left), NUM2INT(top),
|
454
|
-
|
455
|
+
co = newtCheckbox(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
|
456
|
+
StringValuePtr(defValue)[0], NULL, NULL);
|
455
457
|
} else {
|
456
|
-
co = newtCheckbox(NUM2INT(left), NUM2INT(top),
|
457
|
-
|
458
|
+
co = newtCheckbox(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
|
459
|
+
StringValuePtr(defValue)[0], StringValuePtr(seq), NULL);
|
458
460
|
}
|
459
461
|
return Data_Wrap_Struct(self, 0, 0, co);
|
460
462
|
}
|
@@ -478,7 +480,7 @@ rb_ext_Checkbox_SetValue(VALUE self, VALUE value)
|
|
478
480
|
|
479
481
|
Data_Get_Struct(self, struct newtComponent_struct, co);
|
480
482
|
if (RSTRING(value)->len > 0) {
|
481
|
-
newtCheckboxSetValue(co,
|
483
|
+
newtCheckboxSetValue(co, StringValuePtr(value)[0]);
|
482
484
|
}
|
483
485
|
return Qnil;
|
484
486
|
}
|
@@ -487,15 +489,15 @@ static VALUE
|
|
487
489
|
rb_ext_Checkbox_SetFlags(VALUE self, VALUE args)
|
488
490
|
{
|
489
491
|
newtComponent co;
|
490
|
-
|
492
|
+
long len;
|
491
493
|
|
492
|
-
len =
|
494
|
+
len = RARRAY_LEN(args);
|
493
495
|
if (len == 1) {
|
494
496
|
Data_Get_Struct(self, struct newtComponent_struct, co);
|
495
|
-
newtCheckboxSetFlags(co, NUM2INT(
|
497
|
+
newtCheckboxSetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NEWT_FLAGS_SET);
|
496
498
|
} else if (len == 2) {
|
497
499
|
Data_Get_Struct(self, struct newtComponent_struct, co);
|
498
|
-
newtCheckboxSetFlags(co, NUM2INT(
|
500
|
+
newtCheckboxSetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NUM2INT(RARRAY_PTR(args)[1]));
|
499
501
|
} else {
|
500
502
|
rb_raise(rb_eArgError, "1 argument or 2 arguments required");
|
501
503
|
}
|
@@ -510,11 +512,11 @@ rb_ext_RadioButton_new(VALUE self, VALUE left, VALUE top, VALUE text,
|
|
510
512
|
newtComponent co, cco;
|
511
513
|
|
512
514
|
if (NIL_P(prevButton)) {
|
513
|
-
co = newtRadiobutton(NUM2INT(left), NUM2INT(top),
|
515
|
+
co = newtRadiobutton(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
|
514
516
|
NUM2INT(isDefault), NULL);
|
515
517
|
} else {
|
516
518
|
Data_Get_Struct(prevButton, struct newtComponent_struct, cco);
|
517
|
-
co = newtRadiobutton(NUM2INT(left), NUM2INT(top),
|
519
|
+
co = newtRadiobutton(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
|
518
520
|
NUM2INT(isDefault), cco);
|
519
521
|
}
|
520
522
|
return Data_Wrap_Struct(self, 0, 0, co);
|
@@ -533,7 +535,7 @@ static VALUE
|
|
533
535
|
rb_ext_Listbox_GetCurrent(VALUE self)
|
534
536
|
{
|
535
537
|
newtComponent co;
|
536
|
-
int i;
|
538
|
+
int i = 0;
|
537
539
|
int *ip;
|
538
540
|
char *p;
|
539
541
|
|
@@ -565,7 +567,7 @@ rb_ext_Listbox_SetCurrentByKey(VALUE self, VALUE key)
|
|
565
567
|
|
566
568
|
switch(TYPE(key)) {
|
567
569
|
case T_STRING:
|
568
|
-
newtListboxSetCurrentByKey(co, (void *)
|
570
|
+
newtListboxSetCurrentByKey(co, (void *)StringValuePtr(key));
|
569
571
|
break;
|
570
572
|
case T_FIXNUM:
|
571
573
|
newtListboxSetCurrentByKey(co, (void *)NUM2INT(key));
|
@@ -583,7 +585,7 @@ rb_ext_Listbox_SetEntry(VALUE self, VALUE num, VALUE text)
|
|
583
585
|
newtComponent co;
|
584
586
|
|
585
587
|
Data_Get_Struct(self, struct newtComponent_struct, co);
|
586
|
-
newtListboxSetEntry(co, NUM2INT(num),
|
588
|
+
newtListboxSetEntry(co, NUM2INT(num), StringValuePtr(text));
|
587
589
|
return Qnil;
|
588
590
|
}
|
589
591
|
|
@@ -606,7 +608,7 @@ rb_ext_Listbox_SetData(VALUE self, VALUE num, VALUE data)
|
|
606
608
|
|
607
609
|
switch(TYPE(data)) {
|
608
610
|
case T_STRING:
|
609
|
-
newtListboxSetData(co, NUM2INT(num), (void *)
|
611
|
+
newtListboxSetData(co, NUM2INT(num), (void *)StringValuePtr(data));
|
610
612
|
break;
|
611
613
|
case T_FIXNUM:
|
612
614
|
newtListboxSetData(co, NUM2INT(num), (void *)NUM2INT(data));
|
@@ -627,10 +629,10 @@ rb_ext_Listbox_AppendEntry(VALUE self, VALUE text, VALUE data)
|
|
627
629
|
|
628
630
|
switch(TYPE(data)) {
|
629
631
|
case T_STRING:
|
630
|
-
newtListboxAppendEntry(co,
|
632
|
+
newtListboxAppendEntry(co, StringValuePtr(text), (void *)StringValuePtr(data));
|
631
633
|
break;
|
632
634
|
case T_FIXNUM:
|
633
|
-
newtListboxAppendEntry(co,
|
635
|
+
newtListboxAppendEntry(co, StringValuePtr(text), (void *)NUM2INT(data));
|
634
636
|
break;
|
635
637
|
default:
|
636
638
|
rb_raise(rb_eTypeError, "String or Fixnum expected");
|
@@ -650,10 +652,10 @@ rb_ext_Listbox_InsertEntry(VALUE self, VALUE text, VALUE data, VALUE key)
|
|
650
652
|
case T_STRING:
|
651
653
|
switch(TYPE(key)) {
|
652
654
|
case T_STRING:
|
653
|
-
newtListboxInsertEntry(co,
|
655
|
+
newtListboxInsertEntry(co, StringValuePtr(text), (void *)StringValuePtr(data), (void *)StringValuePtr(key));
|
654
656
|
break;
|
655
657
|
case T_FIXNUM:
|
656
|
-
newtListboxInsertEntry(co,
|
658
|
+
newtListboxInsertEntry(co, StringValuePtr(text), (void *)StringValuePtr(data), (void *)NUM2INT(key));
|
657
659
|
break;
|
658
660
|
default:
|
659
661
|
rb_raise(rb_eTypeError, "String or Fixnum expected");
|
@@ -662,10 +664,10 @@ rb_ext_Listbox_InsertEntry(VALUE self, VALUE text, VALUE data, VALUE key)
|
|
662
664
|
case T_FIXNUM:
|
663
665
|
switch(TYPE(key)) {
|
664
666
|
case T_STRING:
|
665
|
-
newtListboxInsertEntry(co,
|
667
|
+
newtListboxInsertEntry(co, StringValuePtr(text), (void *)NUM2INT(data), (void *)StringValuePtr(key));
|
666
668
|
break;
|
667
669
|
case T_FIXNUM:
|
668
|
-
newtListboxInsertEntry(co,
|
670
|
+
newtListboxInsertEntry(co, StringValuePtr(text), (void *)NUM2INT(data), (void *)NUM2INT(key));
|
669
671
|
break;
|
670
672
|
default:
|
671
673
|
rb_raise(rb_eTypeError, "String or Fixnum expected");
|
@@ -688,7 +690,7 @@ rb_ext_Listbox_DeleteEntry(VALUE self, VALUE data)
|
|
688
690
|
|
689
691
|
switch(TYPE(data)) {
|
690
692
|
case T_STRING:
|
691
|
-
newtListboxDeleteEntry(co, (void *)
|
693
|
+
newtListboxDeleteEntry(co, (void *)StringValuePtr(data));
|
692
694
|
break;
|
693
695
|
case T_FIXNUM:
|
694
696
|
newtListboxDeleteEntry(co, (void *)NUM2INT(data));
|
@@ -731,7 +733,7 @@ rb_ext_Listbox_SelectItem(VALUE self, VALUE key, VALUE sense)
|
|
731
733
|
|
732
734
|
switch(TYPE(key)) {
|
733
735
|
case T_STRING:
|
734
|
-
newtListboxSelectItem(co, (void *)
|
736
|
+
newtListboxSelectItem(co, (void *)StringValuePtr(key), NUM2INT(sense));
|
735
737
|
break;
|
736
738
|
case T_FIXNUM:
|
737
739
|
newtListboxSelectItem(co, (void *)NUM2INT(key), NUM2INT(sense));
|
@@ -762,7 +764,7 @@ rb_ext_CheckboxTree_AddItem(VALUE self, VALUE args)
|
|
762
764
|
int i, len;
|
763
765
|
int *indexes;
|
764
766
|
|
765
|
-
len =
|
767
|
+
len = RARRAY_LEN(args);
|
766
768
|
if (len < 4) {
|
767
769
|
rb_raise(rb_eArgError, "4 arguments required");
|
768
770
|
} else {
|
@@ -770,18 +772,18 @@ rb_ext_CheckboxTree_AddItem(VALUE self, VALUE args)
|
|
770
772
|
|
771
773
|
indexes = ALLOCA_N(int, (len - 4) + 2);
|
772
774
|
for (i = 0; i < (len - 4) + 1; i++) {
|
773
|
-
indexes[i] = NUM2INT(
|
775
|
+
indexes[i] = NUM2INT(RARRAY_PTR(args)[i+3]);
|
774
776
|
}
|
775
777
|
indexes[(len - 4) + 1] = NEWT_ARG_LAST;
|
776
778
|
|
777
|
-
switch(TYPE(
|
779
|
+
switch(TYPE(RARRAY_PTR(args)[1])) {
|
778
780
|
case T_STRING:
|
779
|
-
newtCheckboxTreeAddArray(co,
|
780
|
-
NUM2INT(
|
781
|
+
newtCheckboxTreeAddArray(co, StringValuePtr(RARRAY_PTR(args)[0]), (void *)StringValuePtr(RARRAY_PTR(args)[1]),
|
782
|
+
NUM2INT(RARRAY_PTR(args)[2]), indexes);
|
781
783
|
break;
|
782
784
|
case T_FIXNUM:
|
783
|
-
newtCheckboxTreeAddArray(co,
|
784
|
-
NUM2INT(
|
785
|
+
newtCheckboxTreeAddArray(co, StringValuePtr(RARRAY_PTR(args)[0]), (void *)NUM2INT(RARRAY_PTR(args)[1]),
|
786
|
+
NUM2INT(RARRAY_PTR(args)[2]), indexes);
|
785
787
|
break;
|
786
788
|
default:
|
787
789
|
rb_raise(rb_eTypeError, "String or Fixnum expected");
|
@@ -794,10 +796,10 @@ rb_ext_CheckboxTree_AddItem(VALUE self, VALUE args)
|
|
794
796
|
|
795
797
|
switch(TYPE(data)) {
|
796
798
|
case T_STRING:
|
797
|
-
newtCheckboxTreeAddItem(co,
|
799
|
+
newtCheckboxTreeAddItem(co, StringValuePtr(text), (void *)StringValuePtr(data), NUM2INT(flags), NEWT_ARG_APPEND, NEWT_ARG_LAST);
|
798
800
|
break;
|
799
801
|
case T_FIXNUM:
|
800
|
-
newtCheckboxTreeAddItem(co,
|
802
|
+
newtCheckboxTreeAddItem(co, StringValuePtr(text), (void *)NUM2INT(data), NUM2INT(flags), NEWT_ARG_APPEND, NEWT_ARG_LAST);
|
801
803
|
break;
|
802
804
|
default:
|
803
805
|
rb_raise(rb_eTypeError, "String or Fixnum expected");
|
@@ -815,7 +817,7 @@ rb_ext_CheckboxTreeMulti_new(VALUE self, VALUE left, VALUE top, VALUE height, VA
|
|
815
817
|
if (NIL_P(seq)) {
|
816
818
|
co = newtCheckboxTreeMulti(NUM2INT(left), NUM2INT(top), NUM2INT(height), NULL, NUM2INT(flags));
|
817
819
|
} else {
|
818
|
-
co = newtCheckboxTreeMulti(NUM2INT(left), NUM2INT(top), NUM2INT(height),
|
820
|
+
co = newtCheckboxTreeMulti(NUM2INT(left), NUM2INT(top), NUM2INT(height), StringValuePtr(seq), NUM2INT(flags));
|
819
821
|
}
|
820
822
|
return Data_Wrap_Struct(self, 0, 0, co);
|
821
823
|
}
|
@@ -835,7 +837,7 @@ rb_ext_Textbox_SetText(VALUE self, VALUE text)
|
|
835
837
|
newtComponent co;
|
836
838
|
|
837
839
|
Data_Get_Struct(self, struct newtComponent_struct, co);
|
838
|
-
newtTextboxSetText(co,
|
840
|
+
newtTextboxSetText(co, StringValuePtr(text));
|
839
841
|
return Qnil;
|
840
842
|
}
|
841
843
|
|
@@ -863,7 +865,7 @@ rb_ext_TextboxReflowed_new(VALUE self, VALUE left, VALUE top, VALUE text, VALUE
|
|
863
865
|
{
|
864
866
|
newtComponent co;
|
865
867
|
|
866
|
-
co = newtTextboxReflowed(NUM2INT(left), NUM2INT(top),
|
868
|
+
co = newtTextboxReflowed(NUM2INT(left), NUM2INT(top), StringValuePtr(text), NUM2INT(width),
|
867
869
|
NUM2INT(flexDown), NUM2INT(flexUp), NUM2INT(flags));
|
868
870
|
return Data_Wrap_Struct(self, 0, 0, co);
|
869
871
|
}
|
@@ -919,8 +921,8 @@ rb_ext_Form_AddComponents(VALUE self, VALUE co)
|
|
919
921
|
|
920
922
|
Data_Get_Struct(self, struct newtComponent_struct, form);
|
921
923
|
|
922
|
-
for (i = 0; i <
|
923
|
-
Data_Get_Struct(
|
924
|
+
for (i = 0; i < RARRAY_LEN(co); i++) {
|
925
|
+
Data_Get_Struct(RARRAY_PTR(co)[i], struct newtComponent_struct, cco);
|
924
926
|
newtFormAddComponent(form, cco);
|
925
927
|
}
|
926
928
|
return Qnil;
|
@@ -981,7 +983,7 @@ rb_ext_Entry_new(VALUE self, VALUE left, VALUE top, VALUE initialValue, VALUE wi
|
|
981
983
|
{
|
982
984
|
newtComponent co;
|
983
985
|
|
984
|
-
co = newtEntry(NUM2INT(left), NUM2INT(top),
|
986
|
+
co = newtEntry(NUM2INT(left), NUM2INT(top), StringValuePtr(initialValue), NUM2INT(width),
|
985
987
|
NULL, NUM2INT(flags));
|
986
988
|
return Data_Wrap_Struct(self, 0, 0, co);
|
987
989
|
}
|
@@ -994,13 +996,13 @@ rb_ext_Entry_Set(VALUE self, VALUE value, VALUE cursorAtEnd)
|
|
994
996
|
Data_Get_Struct(self, struct newtComponent_struct, co);
|
995
997
|
switch(TYPE(cursorAtEnd)) {
|
996
998
|
case T_TRUE:
|
997
|
-
newtEntrySet(co,
|
999
|
+
newtEntrySet(co, StringValuePtr(value), 1);
|
998
1000
|
break;
|
999
1001
|
case T_FALSE:
|
1000
|
-
newtEntrySet(co,
|
1002
|
+
newtEntrySet(co, StringValuePtr(value), 0);
|
1001
1003
|
break;
|
1002
1004
|
case T_FIXNUM:
|
1003
|
-
newtEntrySet(co,
|
1005
|
+
newtEntrySet(co, StringValuePtr(value), NUM2INT(cursorAtEnd));
|
1004
1006
|
break;
|
1005
1007
|
default:
|
1006
1008
|
rb_raise(rb_eTypeError, "Boolean or Fixnum expected");
|
@@ -1023,15 +1025,15 @@ static VALUE
|
|
1023
1025
|
rb_ext_Entry_SetFlags(VALUE self, VALUE args)
|
1024
1026
|
{
|
1025
1027
|
newtComponent co;
|
1026
|
-
|
1028
|
+
long len;
|
1027
1029
|
|
1028
|
-
len =
|
1030
|
+
len = RARRAY_LEN(args);
|
1029
1031
|
if (len == 1) {
|
1030
1032
|
Data_Get_Struct(self, struct newtComponent_struct, co);
|
1031
|
-
newtEntrySetFlags(co, NUM2INT(
|
1033
|
+
newtEntrySetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NEWT_FLAGS_SET);
|
1032
1034
|
} else if (len == 2) {
|
1033
1035
|
Data_Get_Struct(self, struct newtComponent_struct, co);
|
1034
|
-
newtEntrySetFlags(co, NUM2INT(
|
1036
|
+
newtEntrySetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NUM2INT(RARRAY_PTR(args)[1]));
|
1035
1037
|
} else {
|
1036
1038
|
rb_raise(rb_eArgError, "1 argument or 2 arguments required");
|
1037
1039
|
}
|
@@ -1098,16 +1100,16 @@ static VALUE
|
|
1098
1100
|
rb_ext_Grid_WrappedWindow(VALUE self, VALUE args)
|
1099
1101
|
{
|
1100
1102
|
newtGrid grid;
|
1101
|
-
|
1103
|
+
long len;
|
1102
1104
|
|
1103
|
-
len =
|
1105
|
+
len = RARRAY_LEN(args);
|
1104
1106
|
if (len == 1) {
|
1105
1107
|
Data_Get_Struct(self, struct grid_s, grid);
|
1106
|
-
newtGridWrappedWindow(grid,
|
1108
|
+
newtGridWrappedWindow(grid, StringValuePtr(RARRAY_PTR(args)[0]));
|
1107
1109
|
} else if (len == 3) {
|
1108
1110
|
Data_Get_Struct(self, struct grid_s, grid);
|
1109
|
-
newtGridWrappedWindowAt(grid,
|
1110
|
-
NUM2INT(
|
1111
|
+
newtGridWrappedWindowAt(grid, StringValuePtr(RARRAY_PTR(args)[0]),
|
1112
|
+
NUM2INT(StringValuePtr(RARRAY_PTR(args)[1])), NUM2INT(StringValuePtr(RARRAY_PTR(args)[2])));
|
1111
1113
|
} else {
|
1112
1114
|
rb_raise(rb_eArgError, "1 argument or 3 arguments required");
|
1113
1115
|
}
|
data/lib/newt.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 9
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.1
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric Sperano
|
@@ -63,7 +63,7 @@ dependencies:
|
|
63
63
|
version: "2.14"
|
64
64
|
type: :development
|
65
65
|
version_requirements: *id003
|
66
|
-
description:
|
66
|
+
description: Ruby Bindings for the Newt Library
|
67
67
|
email:
|
68
68
|
- eric@sperano.org
|
69
69
|
executables: []
|
@@ -82,6 +82,57 @@ files:
|
|
82
82
|
- PostInstall.txt
|
83
83
|
- README.rdoc
|
84
84
|
- Rakefile
|
85
|
+
- examples/test-j.rb
|
86
|
+
- examples/test.rb
|
87
|
+
- examples/test_method/Button_new.rb
|
88
|
+
- examples/test_method/Checkbox_get.rb
|
89
|
+
- examples/test_method/Checkbox_new.rb
|
90
|
+
- examples/test_method/Checkbox_set.rb
|
91
|
+
- examples/test_method/Checkbox_set_flags.rb
|
92
|
+
- examples/test_method/CompactButton_new.rb
|
93
|
+
- examples/test_method/Entry_get.rb
|
94
|
+
- examples/test_method/Entry_new.rb
|
95
|
+
- examples/test_method/Entry_set.rb
|
96
|
+
- examples/test_method/Entry_set_flags.rb
|
97
|
+
- examples/test_method/Form_destroy.rb
|
98
|
+
- examples/test_method/Form_set_background.rb
|
99
|
+
- examples/test_method/Form_set_height.rb
|
100
|
+
- examples/test_method/Form_set_width.rb
|
101
|
+
- examples/test_method/Grid_new.rb
|
102
|
+
- examples/test_method/Label_new.rb
|
103
|
+
- examples/test_method/Label_setText.rb
|
104
|
+
- examples/test_method/Listbox_clear.rb
|
105
|
+
- examples/test_method/Listbox_current_bykey.rb
|
106
|
+
- examples/test_method/Listbox_delete.rb
|
107
|
+
- examples/test_method/Listbox_get_current.rb
|
108
|
+
- examples/test_method/Listbox_insert.rb
|
109
|
+
- examples/test_method/Listbox_new.rb
|
110
|
+
- examples/test_method/Listbox_select.rb
|
111
|
+
- examples/test_method/Listbox_set.rb
|
112
|
+
- examples/test_method/Listbox_set_current.rb
|
113
|
+
- examples/test_method/Listbox_set_width.rb
|
114
|
+
- examples/test_method/Newt_FLAG_SCROLL.rb
|
115
|
+
- examples/test_method/RadioButton_new.rb
|
116
|
+
- examples/test_method/ReflowText.rb
|
117
|
+
- examples/test_method/Scale_new.rb
|
118
|
+
- examples/test_method/Scale_set.rb
|
119
|
+
- examples/test_method/Screen_bell.rb
|
120
|
+
- examples/test_method/Screen_cls.rb
|
121
|
+
- examples/test_method/Screen_draw_roottext.rb
|
122
|
+
- examples/test_method/Screen_init.rb
|
123
|
+
- examples/test_method/Screen_pop_helpline.rb
|
124
|
+
- examples/test_method/Screen_push_helpline.rb
|
125
|
+
- examples/test_method/Screen_redraw_helpline.rb
|
126
|
+
- examples/test_method/Screen_size.rb
|
127
|
+
- examples/test_method/Screen_win_menu.rb
|
128
|
+
- examples/test_method/TextboxReflowed_new.rb
|
129
|
+
- examples/test_method/Textbox_get_num_lines.rb
|
130
|
+
- examples/test_method/Textbox_new.rb
|
131
|
+
- examples/test_method/Textbox_set_height.rb
|
132
|
+
- examples/testgrid-j.rb
|
133
|
+
- examples/testgrid.rb
|
134
|
+
- examples/testtree-j.rb
|
135
|
+
- examples/testtree.rb
|
85
136
|
- ext/ruby_newt/extconf.rb
|
86
137
|
- ext/ruby_newt/ruby_newt.c
|
87
138
|
- lib/newt.rb
|
@@ -94,7 +145,7 @@ files:
|
|
94
145
|
- test/test_newt.rb
|
95
146
|
- test/test_ruby_newt_extn.rb
|
96
147
|
- .gemtest
|
97
|
-
homepage: http://github.com
|
148
|
+
homepage: http://github.com/esperano/ruby-newt
|
98
149
|
licenses: []
|
99
150
|
|
100
151
|
post_install_message: PostInstall.txt
|
@@ -128,7 +179,7 @@ rubyforge_project: newt
|
|
128
179
|
rubygems_version: 1.8.6
|
129
180
|
signing_key:
|
130
181
|
specification_version: 3
|
131
|
-
summary:
|
182
|
+
summary: Ruby Bindings for the Newt Library
|
132
183
|
test_files:
|
133
184
|
- test/test_helper.rb
|
134
185
|
- test/test_newt.rb
|