Curses::Window (Class)

In: curses/curses.c
Parent: Data

Methods

<<   addch   addstr   attroff   attron   attrset   begx   begy   bkgd   bkgdset   box   clear   close   curx   cury   delch   deleteln   getbkgd   getch   getstr   idlok   inch   insch   keypad   keypad=   maxx   maxy   move   new   nodelay=   noutrefresh   refresh   resize   scrl   scroll   scrollok   setpos   setscrreg   standend   standout   subwin   timeout=  

Public Class methods

def initialize(h, w, top, left)

[Source]

/* def initialize(h, w, top, left) */
static VALUE
window_initialize(obj, h, w, top, left)
    VALUE obj;
    VALUE h;
    VALUE w;
    VALUE top;
    VALUE left;
{
    struct windata *winp;
    WINDOW *window;

    rb_secure(4);
    curses_init_screen();
    Data_Get_Struct(obj, struct windata, winp);
    if (winp->window) delwin(winp->window);
    window = newwin(NUM2INT(h), NUM2INT(w), NUM2INT(top), NUM2INT(left));
    wclear(window);
    winp->window = window;

    return obj;
}

Public Instance methods

def <<(str)

[Source]

/* def <<(str) */
static VALUE
window_addstr2(obj, str)
    VALUE obj;
    VALUE str;
{
    window_addstr(obj, str);
    return obj;
}

def addch(ch)

[Source]

/* def addch(ch) */
static VALUE
window_addch(obj, ch)
    VALUE obj;
    VALUE ch;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    waddch(winp->window, NUM2CHR(ch));
    
    return Qnil;
}

def addstr(str)

[Source]

/* def addstr(str) */
static VALUE
window_addstr(obj, str)
    VALUE obj;
    VALUE str;
{
    if (!NIL_P(str)) {
	struct windata *winp;

	GetWINDOW(obj, winp);
	waddstr(winp->window, STR2CSTR(str));
    }
    return Qnil;
}
attroff(p1)
attron(p1)
attrset(p1)

def begx

[Source]

/* def begx */
static VALUE
window_begx(obj)
    VALUE obj;
{
    struct windata *winp;
    int x, y;

    GetWINDOW(obj, winp);
#ifdef getbegyx
    getbegyx(winp->window, y, x);
    return INT2FIX(x);
#else
    return INT2FIX(winp->window->_begx);
#endif
}

def begy

[Source]

/* def begy */
static VALUE
window_begy(obj)
    VALUE obj;
{
    struct windata *winp;
    int x, y;

    GetWINDOW(obj, winp);
#ifdef getbegyx
    getbegyx(winp->window, y, x);
    return INT2FIX(y);
#else
    return INT2FIX(winp->window->_begy);
#endif
}
bkgd(p1)
bkgdset(p1)

def box(vert, hor)

[Source]

/* def box(vert, hor) */
static VALUE
window_box(argc, argv, self)
    int argc;
    VALUE argv[], self;
{
    struct windata *winp; 
    VALUE vert, hor, corn;

    rb_scan_args(argc, argv, "21", &vert, &hor, &corn);

    GetWINDOW(self, winp);
    box(winp->window, NUM2CHR(vert), NUM2CHR(hor));

    if (!NIL_P(corn)) {
      int cur_x, cur_y, x, y;
      char c;

      c = NUM2CHR(corn);
      getyx(winp->window, cur_y, cur_x);
      x = NUM2INT(window_maxx(self)) - 1;
      y = NUM2INT(window_maxy(self)) - 1;
      wmove(winp->window, 0, 0);
      waddch(winp->window, c);
      wmove(winp->window, y, 0);
      waddch(winp->window, c);
      wmove(winp->window, y, x);
      waddch(winp->window, c);
      wmove(winp->window, 0, x);
      waddch(winp->window, c);
      wmove(winp->window, cur_y, cur_x);
    }
    
    return Qnil;
}

def clear

[Source]

/* def clear */
static VALUE
window_clear(obj)
    VALUE obj;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    wclear(winp->window);
    
    return Qnil;
}

def close

[Source]

/* def close */
static VALUE
window_close(obj)
    VALUE obj;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    delwin(winp->window);
    winp->window = 0;

    return Qnil;
}

def curx

[Source]

/* def curx */
static VALUE
window_curx(obj)
    VALUE obj;
{
    struct windata *winp;
    int x, y;

    GetWINDOW(obj, winp);
    getyx(winp->window, y, x);
    return INT2FIX(x);
}

def cury

[Source]

/* def cury */
static VALUE
window_cury(obj)
    VALUE obj;
{
    struct windata *winp;
    int x, y;

    GetWINDOW(obj, winp);
    getyx(winp->window, y, x);
    return INT2FIX(y);
}

def delch

[Source]

/* def delch */
static VALUE
window_delch(obj)
    VALUE obj;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    wdelch(winp->window);
    return Qnil;
}

def delelteln

[Source]

/* def delelteln */
static VALUE
window_deleteln(obj)
    VALUE obj;
{
#if defined(HAVE_WDELETELN) || defined(wdeleteln)
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    wdeleteln(winp->window);
#endif
    return Qnil;
}
getbkgd()

def getch

[Source]

/* def getch */
static VALUE
window_getch(obj)
    VALUE obj;
{
    struct windata *winp;
    
    rb_read_check(stdin);
    GetWINDOW(obj, winp);
    return UINT2NUM(wgetch(winp->window));
}

def getstr

[Source]

/* def getstr */
static VALUE
window_getstr(obj)
    VALUE obj;
{
    struct windata *winp;
    char rtn[1024]; /* This should be big enough.. I hope */
    
    GetWINDOW(obj, winp);
    rb_read_check(stdin);
#if defined(HAVE_WGETNSTR)
    wgetnstr(winp->window, rtn, 1023);
#else
    wgetstr(winp->window, rtn);
#endif
    return rb_tainted_str_new2(rtn);
}
idlok(p1)

def inch

[Source]

/* def inch */
static VALUE
window_inch(obj)
    VALUE obj;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    return CHR2FIX(winch(winp->window));
}

def insch(ch)

[Source]

/* def insch(ch) */
static VALUE
window_insch(obj, ch)
    VALUE obj;
    VALUE ch;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    winsch(winp->window, NUM2CHR(ch));
    
    return Qnil;
}
keypad(p1)
keypad=(p1)

def maxx

[Source]

/* def maxx */
static VALUE
window_maxx(obj)
    VALUE obj;
{
    struct windata *winp;

    GetWINDOW(obj, winp);
#if defined(getmaxx)
    return INT2FIX(getmaxx(winp->window));
#elif defined(getmaxyx)
    {
	int x, y;
	getmaxyx(winp->window, y, x);
	return INT2FIX(x);
    }
#else
    return INT2FIX(winp->window->_maxx+1);
#endif
}

def maxy

[Source]

/* def maxy */
static VALUE
window_maxy(obj)
    VALUE obj;
{
    struct windata *winp;

    GetWINDOW(obj, winp);
#if defined(getmaxy)
    return INT2FIX(getmaxy(winp->window));
#elif defined(getmaxyx)
    {
	int x, y;
	getmaxyx(winp->window, y, x);
	return INT2FIX(y);
    }
#else
    return INT2FIX(winp->window->_maxy+1);
#endif
}

def move(y, x)

[Source]

/* def move(y, x) */
static VALUE
window_move(obj, y, x)
    VALUE obj;
    VALUE y;
    VALUE x;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    mvwin(winp->window, NUM2INT(y), NUM2INT(x));

    return Qnil;
}
nodelay=(p1)

def noutrefresh

[Source]

/* def noutrefresh */
static VALUE
window_noutrefresh(obj)
    VALUE obj;
{
    struct windata *winp;

    GetWINDOW(obj, winp);
#ifdef HAVE_DOUPDATE
    wnoutrefresh(winp->window);
#else
    wrefresh(winp->window);
#endif

    return Qnil;
}

def refresh

[Source]

/* def refresh */
static VALUE
window_refresh(obj)
    VALUE obj;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    wrefresh(winp->window);
    
    return Qnil;
}
resize(p1, p2)
scrl(p1)
scroll()
scrollok(p1)

def setpos(y, x)

[Source]

/* def setpos(y, x) */
static VALUE
window_setpos(obj, y, x)
    VALUE obj;
    VALUE y;
    VALUE x;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    wmove(winp->window, NUM2INT(y), NUM2INT(x));
    return Qnil;
}
setscrreg(p1, p2)

def standend

[Source]

/* def standend */
static VALUE
window_standend(obj)
    VALUE obj;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    wstandend(winp->window);
    return Qnil;
}

def standout

[Source]

/* def standout */
static VALUE
window_standout(obj)
    VALUE obj;
{
    struct windata *winp;
    
    GetWINDOW(obj, winp);
    wstandout(winp->window);
    return Qnil;
}

def subwin(h, w, top, left)

[Source]

/* def subwin(h, w, top, left) */
static VALUE
window_subwin(obj, h, w, top, left)
    VALUE obj;
    VALUE h;
    VALUE w;
    VALUE top;
    VALUE left;
{
    struct windata *winp;
    WINDOW *window;
    VALUE win;

    GetWINDOW(obj, winp);
    window = subwin(winp->window, NUM2INT(h), NUM2INT(w),
		                  NUM2INT(top), NUM2INT(left));
    win = prep_window(rb_obj_class(obj), window);

    return win;
}
timeout=(p1)

[Validate]