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(?|, ?-)



2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
# File 'ext/curses/curses.c', line 2408

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;
}