Class: Curses::Screen
- Inherits:
-
Object
- Object
- Curses::Screen
- Defined in:
- ext/curses/curses.c,
ext/curses/curses.c
Overview
Description
A Screen represents a terminal. A program that outputs to more than one terminal should create a Screen
for each terminal instead of calling Curses.init_screen.
Usage
require "curses"
screen = Screen.new(STDOUT, STDIN, "xterm")
screen.set_term
Curses.addstr("Hit any key")
Curses.refresh
Curses.getch
Curses.close_screen
Instance Method Summary collapse
-
#new(outf, inf, type = nil) ⇒ Object
constructor
Construct a new Curses::Screen.
-
#set_term ⇒ Object
Set the current terminal.
Constructor Details
#new(outf, inf, type = nil) ⇒ Object
Construct a new Curses::Screen.
1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 |
# File 'ext/curses/curses.c', line 1827
static VALUE
screen_initialize(int argc, VALUE *argv, VALUE obj)
{
VALUE outf, inf, type;
struct screendata *screenp;
rb_io_t *outfptr, *infptr;
rb_scan_args(argc, argv, "21", &outf, &inf, &type);
TypedData_Get_Struct(obj, struct screendata, &screendata_type, screenp);
if (screenp->screen) delscreen(screenp->screen);
Check_Type(outf, T_FILE);
RB_IO_POINTER(outf, outfptr);
rb_io_check_writable(outfptr);
Check_Type(inf, T_FILE);
RB_IO_POINTER(inf, infptr);
rb_io_check_readable(infptr);
screenp->screen = newterm(NIL_P(type) ? NULL : StringValueCStr(type),
rb_io_stdio_file(outfptr),
rb_io_stdio_file(infptr));
screenp->stdscr_value = Qnil;
return obj;
}
|
Instance Method Details
#set_term ⇒ Object
Set the current terminal.
1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 |
# File 'ext/curses/curses.c', line 1857
static VALUE
screen_set_term(VALUE obj)
{
struct screendata *screenp;
GetSCREEN(obj, screenp);
set_term(screenp->screen);
if (NIL_P(screenp->stdscr_value)) {
screenp->stdscr_value = prep_window(cWindow, stdscr, 1);
}
rb_stdscr = screenp->stdscr_value;
return Qnil;
}
|