| Class | Curses::Window |
| In: |
curses/curses.c
|
| Parent: | Data |
def initialize(h, w, top, left)
/* 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;
}
def <<(str)
/* def <<(str) */
static VALUE
window_addstr2(obj, str)
VALUE obj;
VALUE str;
{
window_addstr(obj, str);
return obj;
}
def box(vert, hor)
/* 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, NUM2CH(vert), NUM2CH(hor));
if (!NIL_P(corn)) {
int cur_x, cur_y, x, y;
chtype c;
c = NUM2CH(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 delelteln
/* 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;
}
def getstr
/* 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);
}
def maxx
/* 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
/* 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 noutrefresh
/* 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;
}
USE_COLOR
/* USE_COLOR */
static VALUE
window_scroll(VALUE obj)
{
struct windata *winp;
GetWINDOW(obj, winp);
/* may have to raise exception on ERR */
return (scroll(winp->window) == OK) ? Qtrue : Qfalse;
}
def subwin(height, width, top, left)
/* def subwin(height, width, top, left) */
static VALUE
window_subwin(obj, height, width, top, left)
VALUE obj;
VALUE height;
VALUE width;
VALUE top;
VALUE left;
{
struct windata *winp;
WINDOW *window;
VALUE win;
int h, w, t, l;
h = NUM2INT(height);
w = NUM2INT(width);
t = NUM2INT(top);
l = NUM2INT(left);
GetWINDOW(obj, winp);
window = subwin(winp->window, h, w, t, l);
win = prep_window(rb_obj_class(obj), window);
return win;
}
ruby-doc.org is hosted and run by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. Ruby-doc.org was created in 2002 to promote the Ruby language and to help other Ruby hackers.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.