Class: Curses::Pad

Inherits:
Window
  • Object
show all
Defined in:
ext/curses/curses.c,
ext/curses/curses.c

Overview

Description

A Pad is like a Window but allows for scrolling of contents that cannot fit on the screen. Pads do not refresh automatically, use Pad#refresh or Pad#noutrefresh instead.

Instance Method Summary collapse

Methods inherited from Window

#<<, #addch, #addstr, #attroff, #attron, #attrset, #begx, #begy, #bkgd, #bkgdset, #box, #clear, #close, #clrtoeol, #color_set, #curx, #cury, #delch, #deleteln, #derwin, #erase, #get_char, #getbkgd, #getch, #getstr, #idlok, #inch, #insch, #insertln, #keypad, #keypad=, #line_touched?, #maxx, #maxy, #move, #move_relative, #nodelay=, #redraw, #resize, #scrl, #scroll, #scrollok, #setpos, #setscrreg, #standend, #standout, #subwin, #timeout=, #touch, #touch_line, #touched?, #untouch

Constructor Details

#initialize(h, w) ⇒ Object

call-seq:

new(height, width)

Construct a new Curses::Pad with constraints of height lines, width columns



2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
# File 'ext/curses/curses.c', line 2789

static VALUE
pad_initialize(VALUE obj, VALUE h, VALUE w)
{
    struct windata *padp;
    WINDOW *window;

    curses_init_screen();
    TypedData_Get_Struct(obj, struct windata, &windata_type, padp);
    if (padp->window) delwin(padp->window);
    window = newpad(NUM2INT(h), NUM2INT(w));
    wclear(window);
    padp->window = window;

    return obj;
}

Instance Method Details

#noutrefresh(pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) ⇒ Object

call-seq:

pad.noutrefresh(pad_minrow, pad_mincol, screen_minrow, screen_mincol, screen_maxrow, screen_maxcol)

Refreshes the pad. pad_minrow and pad_mincol+ define the upper-left corner of the rectangle to be displayed. screen_minrow, screen_mincol, screen_maxrow, screen_maxcol define the edges of the rectangle to be displayed on the screen.



2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
# File 'ext/curses/curses.c', line 2877

static VALUE
pad_noutrefresh(VALUE obj, VALUE pminrow, VALUE pmincol, VALUE sminrow,
    VALUE smincol, VALUE smaxrow, VALUE smaxcol)
{
    struct windata *padp;
    int pmr, pmc, smr, smc, sxr, sxc;

    pmr = NUM2INT(pminrow);
    pmc = NUM2INT(pmincol);
    smr = NUM2INT(sminrow);
    smc = NUM2INT(smincol);
    sxr = NUM2INT(smaxrow);
    sxc = NUM2INT(smaxcol);

    GetWINDOW(obj, padp);
#ifdef HAVE_DOUPDATE
    pnoutrefresh(padp->window, pmr, pmc, smr, smc, sxr, sxc);
#else
    prefresh(padp->window, pmr, pmc, smr, smc, sxr, sxc);
#endif

    return Qnil;
}

#refresh(pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) ⇒ Object

call-seq:

pad.refresh(pad_minrow, pad_mincol, screen_minrow, screen_mincol, screen_maxrow, screen_maxcol)

Refreshes the pad. pad_minrow and pad_mincol+ define the upper-left corner of the rectangle to be displayed. screen_minrow, screen_mincol, screen_maxrow, screen_maxcol define the edges of the rectangle to be displayed on the screen.



2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
# File 'ext/curses/curses.c', line 2845

static VALUE
pad_refresh(VALUE obj, VALUE pminrow, VALUE pmincol, VALUE sminrow,
      VALUE smincol, VALUE smaxrow, VALUE smaxcol)
{
    struct windata *padp;
    int pmr, pmc, smr, smc, sxr, sxc;

    pmr = NUM2INT(pminrow);
    pmc = NUM2INT(pmincol);
    smr = NUM2INT(sminrow);
    smc = NUM2INT(smincol);
    sxr = NUM2INT(smaxrow);
    sxc = NUM2INT(smaxcol);

    GetWINDOW(obj, padp);
    prefresh(padp->window, pmr, pmc, smr, smc, sxr, sxc);

    return Qnil;
}

#subpad(height, width, begin_x, begin_y) ⇒ Object

Construct a new subpad with constraints of height lines, width columns, begin at begin_x line, and begin_y columns on the pad.



2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
# File 'ext/curses/curses.c', line 2814

static VALUE
pad_subpad(VALUE obj, VALUE height, VALUE width, VALUE begin_x, VALUE begin_y)
{
    struct windata *padp;
    WINDOW *sub_pad;
    VALUE pad;
    int h, w, x, y;

    h = NUM2INT(height);
    w = NUM2INT(width);
    x = NUM2INT(begin_x);
    y = NUM2INT(begin_y);
    GetWINDOW(obj, padp);
    sub_pad = subpad(padp->window, h, w, x, y);
    pad = prep_window(rb_obj_class(obj), sub_pad);

    return pad;
}