Class: Newt::Screen
- Inherits:
-
Object
- Object
- Newt::Screen
- Defined in:
- ext/ruby_newt/ruby_newt.c
Class Method Summary collapse
- .bell ⇒ Object
- .centered_window(width, height, title) ⇒ Object
- .clear_keybuffer ⇒ Object
- .cls ⇒ Object
- .draw_roottext(col, row, text) ⇒ Object
- .finish ⇒ Object
- .init ⇒ Object
- .new ⇒ Object
- .open_window(left, top, width, height, title) ⇒ Object
- .pop_helpline ⇒ Object
- .pop_window ⇒ Object
- .push_helpline(text) ⇒ Object
- .redraw_helpline ⇒ Object
- .refresh ⇒ Object
- .resume ⇒ Object
- .set_color(colorset, fg, bg) ⇒ Object
- .set_colors(colors) ⇒ Object
- .size ⇒ Object
- .suspend ⇒ Object
- .wait_for_key ⇒ Object
- .win_choice(args) ⇒ Object
- .win_entries(args) ⇒ Object
- .win_menu(args) ⇒ Object
- .win_message(args) ⇒ Object
Class Method Details
.bell ⇒ Object
332 333 334 335 336 337 |
# File 'ext/ruby_newt/ruby_newt.c', line 332
static VALUE rb_ext_Screen_Bell(VALUE self)
{
newtBell();
return Qnil;
}
|
.centered_window(width, height, title) ⇒ Object
119 120 121 122 |
# File 'ext/ruby_newt/ruby_newt.c', line 119
static VALUE rb_ext_Screen_CenteredWindow(VALUE self, VALUE width, VALUE height, VALUE title)
{
return INT2NUM(newtCenteredWindow(NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
}
|
.clear_keybuffer ⇒ Object
105 106 107 108 109 110 |
# File 'ext/ruby_newt/ruby_newt.c', line 105
static VALUE rb_ext_Screen_ClearKeyBuffer()
{
newtClearKeyBuffer();
return Qnil;
}
|
.cls ⇒ Object
85 86 87 88 89 |
# File 'ext/ruby_newt/ruby_newt.c', line 85
static VALUE rb_ext_Screen_Cls()
{
newtCls();
return Qnil;
}
|
.draw_roottext(col, row, text) ⇒ Object
304 305 306 307 308 309 |
# File 'ext/ruby_newt/ruby_newt.c', line 304
static VALUE rb_ext_Screen_DrawRootText(VALUE self, VALUE col, VALUE row, VALUE text)
{
newtDrawRootText(NUM2INT(col), NUM2INT(row), StringValuePtr(text));
return Qnil;
}
|
.finish ⇒ Object
91 92 93 94 95 96 |
# File 'ext/ruby_newt/ruby_newt.c', line 91
static VALUE rb_ext_Screen_Finished()
{
newtFinished();
return Qnil;
}
|
.init ⇒ Object
78 79 80 81 82 83 |
# File 'ext/ruby_newt/ruby_newt.c', line 78
static VALUE rb_ext_Screen_Init()
{
newtInit();
memcpy(&newtColors, &newtDefaultColorPalette, sizeof(struct newtColors));
return Qnil;
}
|
.new ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'ext/ruby_newt/ruby_newt.c', line 69
static VALUE rb_ext_Screen_new()
{
newtInit();
newtCls();
memcpy(&newtColors, &newtDefaultColorPalette, sizeof(struct newtColors));
return Qnil;
}
|
.open_window(left, top, width, height, title) ⇒ Object
112 113 114 115 116 117 |
# File 'ext/ruby_newt/ruby_newt.c', line 112
static VALUE rb_ext_Screen_OpenWindow(VALUE self, VALUE left, VALUE top,
VALUE width, VALUE height, VALUE title)
{
return INT2NUM(newtOpenWindow(NUM2INT(left), NUM2INT(top),
NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
}
|
.pop_helpline ⇒ Object
325 326 327 328 329 330 |
# File 'ext/ruby_newt/ruby_newt.c', line 325
static VALUE rb_ext_Screen_PopHelpLine(VALUE self)
{
newtPopHelpLine();
return Qnil;
}
|
.pop_window ⇒ Object
124 125 126 127 128 |
# File 'ext/ruby_newt/ruby_newt.c', line 124
static VALUE rb_ext_Screen_PopWindow(VALUE self)
{
newtPopWindow();
return Qnil;
}
|
.push_helpline(text) ⇒ Object
311 312 313 314 315 316 |
# File 'ext/ruby_newt/ruby_newt.c', line 311
static VALUE rb_ext_Screen_PushHelpLine(VALUE self, VALUE text)
{
newtPushHelpLine(StringValuePtr(text));
return Qnil;
}
|
.redraw_helpline ⇒ Object
318 319 320 321 322 323 |
# File 'ext/ruby_newt/ruby_newt.c', line 318
static VALUE rb_ext_Screen_RedrawHelpLine(VALUE self)
{
newtRedrawHelpLine();
return Qnil;
}
|
.refresh ⇒ Object
297 298 299 300 301 302 |
# File 'ext/ruby_newt/ruby_newt.c', line 297
static VALUE rb_ext_Screen_Refresh()
{
newtRefresh();
return Qnil;
}
|
.resume ⇒ Object
283 284 285 286 287 288 |
# File 'ext/ruby_newt/ruby_newt.c', line 283
static VALUE rb_ext_Screen_Resume()
{
newtResume();
return Qnil;
}
|
.set_color(colorset, fg, bg) ⇒ Object
277 278 279 280 281 |
# File 'ext/ruby_newt/ruby_newt.c', line 277
static VALUE rb_ext_Screen_SetColor(VALUE self, VALUE colorset, VALUE fg, VALUE bg)
{
newtSetColor(NUM2INT(colorset), StringValuePtr(fg), StringValuePtr(bg));
return Qnil;
}
|
.set_colors(colors) ⇒ Object
269 270 271 272 273 274 275 |
# File 'ext/ruby_newt/ruby_newt.c', line 269
static VALUE rb_ext_Screen_SetColors(VALUE self, VALUE colors)
{
Check_Type(colors, T_HASH);
rb_hash_foreach(colors, rb_ext_Colors_callback_function, (VALUE) &newtColors);
newtSetColors(newtColors);
return Qnil;
}
|
.size ⇒ Object
339 340 341 342 343 344 345 346 347 348 349 |
# File 'ext/ruby_newt/ruby_newt.c', line 339
static VALUE rb_ext_Screen_Size(VALUE self)
{
int cols, rows;
VALUE ary = rb_ary_new2(2);
newtGetScreenSize(&cols, &rows);
rb_ary_push(ary, INT2NUM(cols));
rb_ary_push(ary, INT2NUM(rows));
return ary;
}
|
.suspend ⇒ Object
290 291 292 293 294 295 |
# File 'ext/ruby_newt/ruby_newt.c', line 290
static VALUE rb_ext_Screen_Suspend()
{
newtSuspend();
return Qnil;
}
|
.wait_for_key ⇒ Object
98 99 100 101 102 103 |
# File 'ext/ruby_newt/ruby_newt.c', line 98
static VALUE rb_ext_Screen_WaitForKey()
{
newtWaitForKey();
return Qnil;
}
|
.win_choice(args) ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'ext/ruby_newt/ruby_newt.c', line 363
static VALUE rb_ext_Screen_WinChoice(VALUE self, VALUE args)
{
int result = 0;
if (RARRAY_LEN(args) < 4) {
rb_raise(rb_eArgError, "4 arguments required");
} else {
result = newtWinChoice(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
StringValuePtr(RARRAY_PTR(args)[2]), StringValuePtr(RARRAY_PTR(args)[3]));
}
return INT2NUM(result);
}
|
.win_entries(args) ⇒ Object
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'ext/ruby_newt/ruby_newt.c', line 425
static VALUE rb_ext_Screen_WinEntries(VALUE self, VALUE args)
{
long len;
int i;
struct newtWinEntry *items;
char * entries[10];
VALUE ary;
memset(entries, 0, sizeof(entries));
ary = rb_ary_new();
len = RARRAY_LEN(args);
if (len == 8) {
Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
len = RARRAY_LEN(RARRAY_PTR(args)[6]);
if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
items = ALLOCA_N(struct newtWinEntry, len + 1);
for (i = 0; i < len; i++) {
Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
items[i].value = entries + i;
items[i].flags = 0;
}
items[len].text = NULL;
items[len].value = NULL;
items[len].flags = 0;
newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
NUM2INT(RARRAY_PTR(args)[2]),
NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
NUM2INT(RARRAY_PTR(args)[5]),
items, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
for (i = 0; i < len; i++) {
rb_ary_push(ary, rb_str_new2(entries[i]));
}
return ary;
} else if (len == 9) {
Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
len = RARRAY_LEN(RARRAY_PTR(args)[6]);
if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
items = ALLOCA_N(struct newtWinEntry, len + 1);
for (i = 0; i < len; i++) {
Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
items[i].value = entries + i;
items[i].flags = 0;
}
items[len].text = NULL;
items[len].value = NULL;
items[len].flags = 0;
newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
NUM2INT(RARRAY_PTR(args)[2]),
NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
NUM2INT(RARRAY_PTR(args)[5]),
items, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
for (i = 0; i < len; i++) {
rb_ary_push(ary, rb_str_new2(entries[i]));
}
return ary;
} else {
rb_raise(rb_eArgError, "8 or 9 arguments required");
}
return Qnil;
}
|
.win_menu(args) ⇒ Object
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'ext/ruby_newt/ruby_newt.c', line 377
static VALUE rb_ext_Screen_WinMenu(VALUE self, VALUE args)
{
long len;
int i, listItem;
char **cptr;
len = RARRAY_LEN(args);
if (len == 8) {
Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
len = RARRAY_LEN(RARRAY_PTR(args)[6]);
cptr = ALLOCA_N(char*, len + 1);
for (i = 0; i < len; i++) {
Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
}
cptr[len] = NULL;
newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
NUM2INT(RARRAY_PTR(args)[2]),
NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
NUM2INT(RARRAY_PTR(args)[5]),
cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
return INT2NUM(listItem);
} else if (len == 9) {
Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
len = RARRAY_LEN(RARRAY_PTR(args)[6]);
cptr = ALLOCA_N(char*, len + 1);
for (i = 0; i < len; i++) {
Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
}
cptr[len] = NULL;
newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
NUM2INT(RARRAY_PTR(args)[2]),
NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
NUM2INT(RARRAY_PTR(args)[5]),
cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
return INT2NUM(listItem);
} else {
rb_raise(rb_eArgError, "8 or 9 arguments required");
}
return Qnil;
}
|
.win_message(args) ⇒ Object
351 352 353 354 355 356 357 358 359 360 361 |
# File 'ext/ruby_newt/ruby_newt.c', line 351
static VALUE rb_ext_Screen_WinMessage(VALUE self, VALUE args)
{
if (RARRAY_LEN(args) < 3) {
rb_raise(rb_eArgError, "3 arguments required");
} else {
newtWinMessage(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]), StringValuePtr(RARRAY_PTR(args)[2]));
}
return Qnil;
}
|