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
- .cursor_off ⇒ Object
- .cursor_on ⇒ Object
- .draw_roottext(col, row, text) ⇒ Object
- .finish ⇒ Object
- .help_callback(cb) ⇒ 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
- .suspend_callback(*args) ⇒ Object
- .wait_for_key ⇒ Object
- .win_choice(title, button1, button2, text) ⇒ Object
- .win_entries(args) ⇒ Object
- .win_menu(args) ⇒ Object
- .win_message(title, button, text) ⇒ Object
Class Method Details
.bell ⇒ Object
467 468 469 470 471 472 |
# File 'ext/ruby_newt/ruby_newt.c', line 467 static VALUE rb_ext_Screen_Bell(VALUE self) { INIT_GUARD(); newtBell(); return Qnil; } |
.centered_window(width, height, title) ⇒ Object
248 249 250 251 252 |
# File 'ext/ruby_newt/ruby_newt.c', line 248 static VALUE rb_ext_Screen_CenteredWindow(VALUE self, VALUE width, VALUE height, VALUE title) { INIT_GUARD(); return INT2NUM(newtCenteredWindow(NUM2INT(width), NUM2INT(height), StringValuePtr(title))); } |
.clear_keybuffer ⇒ Object
233 234 235 236 237 238 |
# File 'ext/ruby_newt/ruby_newt.c', line 233 static VALUE rb_ext_Screen_ClearKeyBuffer() { INIT_GUARD(); newtClearKeyBuffer(); return Qnil; } |
.cls ⇒ Object
212 213 214 215 216 217 |
# File 'ext/ruby_newt/ruby_newt.c', line 212 static VALUE rb_ext_Screen_Cls() { INIT_GUARD(); newtCls(); return Qnil; } |
.cursor_off ⇒ Object
474 475 476 477 478 479 |
# File 'ext/ruby_newt/ruby_newt.c', line 474 static VALUE rb_ext_Screen_CursorOff(VALUE self) { INIT_GUARD(); newtCursorOff(); return Qnil; } |
.cursor_on ⇒ Object
481 482 483 484 485 486 |
# File 'ext/ruby_newt/ruby_newt.c', line 481 static VALUE rb_ext_Screen_CursorOn(VALUE self) { INIT_GUARD(); newtCursorOn(); return Qnil; } |
.draw_roottext(col, row, text) ⇒ Object
438 439 440 441 442 443 |
# File 'ext/ruby_newt/ruby_newt.c', line 438 static VALUE rb_ext_Screen_DrawRootText(VALUE self, VALUE col, VALUE row, VALUE text) { INIT_GUARD(); newtDrawRootText(NUM2INT(col), NUM2INT(row), StringValuePtr(text)); return Qnil; } |
.finish ⇒ Object
219 220 221 222 223 224 |
# File 'ext/ruby_newt/ruby_newt.c', line 219 static VALUE rb_ext_Screen_Finished() { newtFinished(); initialized = Qfalse; return Qnil; } |
.help_callback(cb) ⇒ Object
682 683 684 685 686 687 688 689 690 |
# File 'ext/ruby_newt/ruby_newt.c', line 682 static VALUE rb_ext_Screen_HelpCallback(VALUE self, VALUE cb) { INIT_GUARD(); cb = rb_struct_new(rb_ext_sCallback, Qnil, rb_binding_new(), cb, Qnil, NULL); rb_obj_freeze(cb); rb_cvar_set(self, CVAR_HELP_CALLBACK, cb); newtSetHelpCallback(rb_ext_Screen_help_callback_function); return Qnil; } |
.init ⇒ Object
194 195 196 197 198 199 200 201 202 203 |
# File 'ext/ruby_newt/ruby_newt.c', line 194 static VALUE rb_ext_Screen_Init() { if (initialized == Qtrue) return Qnil; newtInit(); memcpy(&newtColors, &newtDefaultColorPalette, sizeof(struct newtColors)); initialized = Qtrue; return Qnil; } |
.new ⇒ Object
205 206 207 208 209 210 |
# File 'ext/ruby_newt/ruby_newt.c', line 205 static VALUE rb_ext_Screen_new() { rb_ext_Screen_Init(); newtCls(); return Qnil; } |
.open_window(left, top, width, height, title) ⇒ Object
240 241 242 243 244 245 246 |
# File 'ext/ruby_newt/ruby_newt.c', line 240 static VALUE rb_ext_Screen_OpenWindow(VALUE self, VALUE left, VALUE top, VALUE width, VALUE height, VALUE title) { INIT_GUARD(); return INT2NUM(newtOpenWindow(NUM2INT(left), NUM2INT(top), NUM2INT(width), NUM2INT(height), StringValuePtr(title))); } |
.pop_helpline ⇒ Object
460 461 462 463 464 465 |
# File 'ext/ruby_newt/ruby_newt.c', line 460 static VALUE rb_ext_Screen_PopHelpLine(VALUE self) { INIT_GUARD(); newtPopHelpLine(); return Qnil; } |
.pop_window ⇒ Object
254 255 256 257 258 259 |
# File 'ext/ruby_newt/ruby_newt.c', line 254 static VALUE rb_ext_Screen_PopWindow(VALUE self) { INIT_GUARD(); newtPopWindow(); return Qnil; } |
.push_helpline(text) ⇒ Object
445 446 447 448 449 450 451 |
# File 'ext/ruby_newt/ruby_newt.c', line 445 static VALUE rb_ext_Screen_PushHelpLine(VALUE self, VALUE text) { INIT_GUARD(); newtPushHelpLine(StringValuePtr(text)); return Qnil; } |
.redraw_helpline ⇒ Object
453 454 455 456 457 458 |
# File 'ext/ruby_newt/ruby_newt.c', line 453 static VALUE rb_ext_Screen_RedrawHelpLine(VALUE self) { INIT_GUARD(); newtRedrawHelpLine(); return Qnil; } |
.refresh ⇒ Object
431 432 433 434 435 436 |
# File 'ext/ruby_newt/ruby_newt.c', line 431 static VALUE rb_ext_Screen_Refresh() { INIT_GUARD(); newtRefresh(); return Qnil; } |
.resume ⇒ Object
417 418 419 420 421 422 |
# File 'ext/ruby_newt/ruby_newt.c', line 417 static VALUE rb_ext_Screen_Resume() { INIT_GUARD(); newtResume(); return Qnil; } |
.set_color(colorset, fg, bg) ⇒ Object
410 411 412 413 414 415 |
# File 'ext/ruby_newt/ruby_newt.c', line 410 static VALUE rb_ext_Screen_SetColor(VALUE self, VALUE colorset, VALUE fg, VALUE bg) { INIT_GUARD(); newtSetColor(NUM2INT(colorset), StringValuePtr(fg), StringValuePtr(bg)); return Qnil; } |
.set_colors(colors) ⇒ Object
400 401 402 403 404 405 406 407 408 |
# File 'ext/ruby_newt/ruby_newt.c', line 400 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); INIT_GUARD(); newtSetColors(newtColors); return Qnil; } |
.size ⇒ Object
488 489 490 491 492 493 494 495 |
# File 'ext/ruby_newt/ruby_newt.c', line 488 static VALUE rb_ext_Screen_Size(VALUE self) { int cols, rows; INIT_GUARD(); newtGetScreenSize(&cols, &rows); return rb_ary_new_from_args(2, INT2NUM(cols), INT2NUM(rows)); } |
.suspend ⇒ Object
424 425 426 427 428 429 |
# File 'ext/ruby_newt/ruby_newt.c', line 424 static VALUE rb_ext_Screen_Suspend() { INIT_GUARD(); newtSuspend(); return Qnil; } |
.suspend_callback(*args) ⇒ Object
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
# File 'ext/ruby_newt/ruby_newt.c', line 664 static VALUE rb_ext_Screen_SuspendCallback(int argc, VALUE *argv, VALUE self) { VALUE cb, data = Qnil; if (argc < 1 || argc > 2) ARG_ERROR(argc, "1 or 2"); INIT_GUARD(); if (argc == 2) data = argv[1]; cb = rb_struct_new(rb_ext_sCallback, self, rb_binding_new(), argv[0], data, NULL); rb_obj_freeze(cb); rb_cvar_set(self, CVAR_SUSPEND_CALLBACK, cb); newtSetSuspendCallback(rb_ext_Screen_suspend_callback_function, (void *) cb); return Qnil; } |
.wait_for_key ⇒ Object
226 227 228 229 230 231 |
# File 'ext/ruby_newt/ruby_newt.c', line 226 static VALUE rb_ext_Screen_WaitForKey() { INIT_GUARD(); newtWaitForKey(); return Qnil; } |
.win_choice(title, button1, button2, text) ⇒ Object
504 505 506 507 508 509 510 511 512 |
# File 'ext/ruby_newt/ruby_newt.c', line 504 static VALUE rb_ext_Screen_WinChoice(VALUE self, VALUE title, VALUE , VALUE , VALUE text) { int result; INIT_GUARD(); result = newtWinChoice(StringValuePtr(title), StringValuePtr(), StringValuePtr(), StringValuePtr(text)); return INT2NUM(result); } |
.win_entries(args) ⇒ Object
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
# File 'ext/ruby_newt/ruby_newt.c', line 551 static VALUE rb_ext_Screen_WinEntries(VALUE self, VALUE args) { VALUE ary; struct newtWinEntry *items; char *title, *text, *, *; int len, i; int width, flexDown, flexUp, dataWidth; char *entries[10]; len = RARRAY_LENINT(args); if (len < 8 || len > 9) ARG_ERROR(len, "8..9"); INIT_GUARD(); title = StringValuePtr(RARRAY_PTR(args)[0]); text = StringValuePtr(RARRAY_PTR(args)[1]); width = NUM2INT(RARRAY_PTR(args)[2]); flexDown = NUM2INT(RARRAY_PTR(args)[3]); flexUp = NUM2INT(RARRAY_PTR(args)[4]); dataWidth = NUM2INT(RARRAY_PTR(args)[5]); = StringValuePtr(RARRAY_PTR(args)[7]); = (len == 9) ? StringValuePtr(RARRAY_PTR(args)[8]) : NULL; Check_Type(RARRAY_PTR(args)[6], T_ARRAY); len = RARRAY_LENINT(RARRAY_PTR(args)[6]); if (len > 8) ARG_ERROR(len, "8 or less"); memset(entries, 0, sizeof(entries)); 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; ary = rb_ary_new(); newtWinEntries(title, text, width, flexDown, flexUp, dataWidth, items, , , NULL); for (i = 0; i < len; i++) { rb_ary_push(ary, rb_str_new2(entries[i])); } return ary; } |
.win_menu(args) ⇒ Object
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
# File 'ext/ruby_newt/ruby_newt.c', line 514 static VALUE rb_ext_Screen_WinMenu(VALUE self, VALUE args) { char **cptr; char *title, *text, *, *; int len, i, listItem; int width, flexDown, flexUp, maxHeight; len = RARRAY_LENINT(args); if (len < 8 || len > 9) ARG_ERROR(len, "8..9"); INIT_GUARD(); title = StringValuePtr(RARRAY_PTR(args)[0]); text = StringValuePtr(RARRAY_PTR(args)[1]); width = NUM2INT(RARRAY_PTR(args)[2]); flexDown = NUM2INT(RARRAY_PTR(args)[3]); flexUp = NUM2INT(RARRAY_PTR(args)[4]); maxHeight = NUM2INT(RARRAY_PTR(args)[5]); Check_Type(RARRAY_PTR(args)[6], T_ARRAY); len = RARRAY_LENINT(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; = StringValuePtr(RARRAY_PTR(args)[7]); = (len == 9) ? StringValuePtr(RARRAY_PTR(args)[8]) : NULL; newtWinMenu(title, text, width, flexDown, flexUp, maxHeight, cptr, &listItem, , , NULL); return INT2NUM(listItem); } |
.win_message(title, button, text) ⇒ Object
497 498 499 500 501 502 |
# File 'ext/ruby_newt/ruby_newt.c', line 497 static VALUE rb_ext_Screen_WinMessage(VALUE self, VALUE title, VALUE , VALUE text) { INIT_GUARD(); newtWinMessage(StringValuePtr(title), StringValuePtr(), StringValuePtr(text)); return Qnil; } |