Method: Curses::Window#box

Defined in:
ext/curses/curses.c

#box(vert = nil, hor = nil, corn = nil) ⇒ Object

set the characters to frame the window in. The vertical vert and horizontal hor character.

win = Curses::Window.new(5,5,5,5) win.box(?|, ?-)


2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
# File 'ext/curses/curses.c', line 2342

static VALUE
window_box(int argc, VALUE *argv, VALUE self)
{
    struct windata *winp;
    VALUE vert, hor, corn;

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

    GetWINDOW(self, winp);
    box(winp->window,
	NIL_P(vert) ? 0 : OBJ2CHTYPE(vert),
	NIL_P(hor) ? 0 : OBJ2CHTYPE(hor));

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

	c = OBJ2CHTYPE(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;
}