63 |
63 |
static VALUE mCurses;
|
64 |
64 |
static VALUE mKey;
|
65 |
65 |
static VALUE cWindow;
|
|
66 |
static VALUE cPad;
|
66 |
67 |
#ifdef USE_MOUSE
|
67 |
68 |
static VALUE cMouseEvent;
|
68 |
69 |
#endif
|
... | ... | |
2455 |
2456 |
#define window_timeout rb_f_notimplement
|
2456 |
2457 |
#endif
|
2457 |
2458 |
|
|
2459 |
/*--------------------------- class Pad ----------------------------*/
|
|
2460 |
|
|
2461 |
#ifdef HAVE_NEWPAD
|
|
2462 |
/* returns a Curses::Pad object */
|
|
2463 |
static VALUE
|
|
2464 |
pad_s_allocate(VALUE class)
|
|
2465 |
{
|
|
2466 |
struct windata *padp;
|
|
2467 |
|
|
2468 |
return Data_Make_Struct(class, struct windata, 0, free_window, padp);
|
|
2469 |
}
|
|
2470 |
|
|
2471 |
/*
|
|
2472 |
* Document-method: Curses::Pad.new
|
|
2473 |
*
|
|
2474 |
* call-seq:
|
|
2475 |
* new(height, width)
|
|
2476 |
*
|
|
2477 |
* Contruct a new Curses::Pad with constraints of +height+ lines, +width+
|
|
2478 |
* columns
|
|
2479 |
*
|
|
2480 |
*/
|
|
2481 |
static VALUE
|
|
2482 |
pad_initialize(VALUE obj, VALUE h, VALUE w)
|
|
2483 |
{
|
|
2484 |
struct windata *padp;
|
|
2485 |
WINDOW *window;
|
|
2486 |
|
|
2487 |
rb_secure(4);
|
|
2488 |
curses_init_screen();
|
|
2489 |
Data_Get_Struct(obj, struct windata, padp);
|
|
2490 |
if (padp->window) delwin(padp->window);
|
|
2491 |
window = newpad(NUM2INT(h), NUM2INT(w));
|
|
2492 |
wclear(window);
|
|
2493 |
padp->window = window;
|
|
2494 |
|
|
2495 |
return obj;
|
|
2496 |
}
|
|
2497 |
|
|
2498 |
/*
|
|
2499 |
* Document-method: Curses::Pad.subwin
|
|
2500 |
* call-seq:
|
|
2501 |
* subpad(height, width, begin_x, begin_y)
|
|
2502 |
*
|
|
2503 |
* Contruct a new subpad with constraints of +height+ lines, +width+ columns,
|
|
2504 |
* begin at +begin_x+ line, and +begin_y+ columns on the pad.
|
|
2505 |
*
|
|
2506 |
*/
|
|
2507 |
static VALUE
|
|
2508 |
pad_subpad(VALUE obj, VALUE height, VALUE width, VALUE begin_x, VALUE begin_y)
|
|
2509 |
{
|
|
2510 |
struct windata *padp;
|
|
2511 |
WINDOW *subpad;
|
|
2512 |
VALUE pad;
|
|
2513 |
int h, w, x, y;
|
|
2514 |
|
|
2515 |
h = NUM2INT(height);
|
|
2516 |
w = NUM2INT(width);
|
|
2517 |
x = NUM2INT(begin_x);
|
|
2518 |
y = NUM2INT(begin_y);
|
|
2519 |
GetWINDOW(obj, padp);
|
|
2520 |
subpad = subwin(padp->window, h, w, x, y);
|
|
2521 |
pad = prep_window(rb_obj_class(obj), subpad);
|
|
2522 |
|
|
2523 |
return pad;
|
|
2524 |
}
|
|
2525 |
|
|
2526 |
/*
|
|
2527 |
* Document-method: Curses::Pad.refresh
|
|
2528 |
*
|
|
2529 |
* call-seq:
|
|
2530 |
* pad.refresh(pad_minrow, pad_mincol, screen_minrow, screen_mincol, screen_maxrow, screen_maxcol)
|
|
2531 |
*
|
|
2532 |
* Refreshes the pad. +pad_minrow+ and pad_mincol+ define the upper-left
|
|
2533 |
* corner of the rectangle to be displayed. +screen_minrow+, +screen_mincol+,
|
|
2534 |
* +screen_maxrow+, +screen_maxcol+ define the edges of the rectangle to be
|
|
2535 |
* displayed on the screen.
|
|
2536 |
*
|
|
2537 |
*/
|
|
2538 |
static VALUE
|
|
2539 |
pad_refresh(VALUE obj, VALUE pminrow, VALUE pmincol, VALUE sminrow,
|
|
2540 |
VALUE smincol, VALUE smaxrow, VALUE smaxcol)
|
|
2541 |
{
|
|
2542 |
struct windata *padp;
|
|
2543 |
int pmr, pmc, smr, smc, sxr, sxc;
|
|
2544 |
|
|
2545 |
pmr = NUM2INT(pminrow);
|
|
2546 |
pmc = NUM2INT(pmincol);
|
|
2547 |
smr = NUM2INT(sminrow);
|
|
2548 |
smc = NUM2INT(smincol);
|
|
2549 |
sxr = NUM2INT(smaxrow);
|
|
2550 |
sxc = NUM2INT(smaxcol);
|
|
2551 |
|
|
2552 |
GetWINDOW(obj, padp);
|
|
2553 |
prefresh(padp->window, pmr, pmc, smr, smc, sxr, sxc);
|
|
2554 |
|
|
2555 |
return Qnil;
|
|
2556 |
}
|
|
2557 |
|
|
2558 |
/*
|
|
2559 |
* Document-method: Curses::Pad.noutrefresh
|
|
2560 |
*
|
|
2561 |
* call-seq:
|
|
2562 |
* pad.noutrefresh(pad_minrow, pad_mincol, screen_minrow, screen_mincol, screen_maxrow, screen_maxcol)
|
|
2563 |
*
|
|
2564 |
* Refreshes the pad. +pad_minrow+ and pad_mincol+ define the upper-left
|
|
2565 |
* corner of the rectangle to be displayed. +screen_minrow+, +screen_mincol+,
|
|
2566 |
* +screen_maxrow+, +screen_maxcol+ define the edges of the rectangle to be
|
|
2567 |
* displayed on the screen.
|
|
2568 |
*
|
|
2569 |
*/
|
|
2570 |
static VALUE
|
|
2571 |
pad_noutrefresh(VALUE obj, VALUE pminrow, VALUE pmincol, VALUE sminrow,
|
|
2572 |
VALUE smincol, VALUE smaxrow, VALUE smaxcol)
|
|
2573 |
{
|
|
2574 |
struct windata *padp;
|
|
2575 |
int pmr, pmc, smr, smc, sxr, sxc;
|
|
2576 |
|
|
2577 |
pmr = NUM2INT(pminrow);
|
|
2578 |
pmc = NUM2INT(pmincol);
|
|
2579 |
smr = NUM2INT(sminrow);
|
|
2580 |
smc = NUM2INT(smincol);
|
|
2581 |
sxr = NUM2INT(smaxrow);
|
|
2582 |
sxc = NUM2INT(smaxcol);
|
|
2583 |
|
|
2584 |
GetWINDOW(obj, padp);
|
|
2585 |
#ifdef HAVE_DOUPDATE
|
|
2586 |
pnoutrefresh(padp->window, pmr, pmc, smr, smc, sxr, sxc);
|
|
2587 |
#else
|
|
2588 |
prefresh(padp->window, pmr, pmc, smr, smc, sxr, sxc);
|
|
2589 |
#endif
|
|
2590 |
|
|
2591 |
return Qnil;
|
|
2592 |
}
|
|
2593 |
#endif /* HAVE_NEWPAD */
|
|
2594 |
|
2458 |
2595 |
/*------------------------- Initialization -------------------------*/
|
2459 |
2596 |
|
2460 |
2597 |
/*
|
... | ... | |
2686 |
2823 |
rb_define_method(cWindow, "nodelay=", window_nodelay, 1);
|
2687 |
2824 |
rb_define_method(cWindow, "timeout=", window_timeout, 1);
|
2688 |
2825 |
|
|
2826 |
#ifdef HAVE_NEWPAD
|
|
2827 |
/*
|
|
2828 |
* Document-class: Curses::Pad
|
|
2829 |
*
|
|
2830 |
* == Description
|
|
2831 |
*
|
|
2832 |
* A Pad is like a Window but allows for scrolling of contents that cannot
|
|
2833 |
* fit on the screen. Pads do not refresh automatically, use Pad#refresh
|
|
2834 |
* or Pad#noutrefresh instead.
|
|
2835 |
*
|
|
2836 |
*/
|
|
2837 |
cPad = rb_define_class_under(mCurses, "Pad", cWindow);
|
|
2838 |
rb_define_alloc_func(cPad, pad_s_allocate);
|
|
2839 |
rb_define_method(cPad, "initialize", pad_initialize, 2);
|
|
2840 |
rb_define_method(cPad, "subpad", pad_subpad, 4);
|
|
2841 |
rb_define_method(cPad, "refresh", pad_refresh, 6);
|
|
2842 |
rb_define_method(cPad, "noutrefresh", pad_noutrefresh, 6);
|
|
2843 |
rb_undef_method(cPad, "subwin");
|
|
2844 |
#endif
|
|
2845 |
|
2689 |
2846 |
#define rb_curses_define_const(c) rb_define_const(mCurses,#c,UINT2NUM(c))
|
2690 |
2847 |
|
2691 |
2848 |
#ifdef USE_COLOR
|