Module: Curses
- Defined in:
- ext/rubysl/curses/curses.c,
ext/rubysl/curses/curses.c
Overview
Description
An implementation of the CRT screen handling and optimization library.
Structures and such
Classes
-
Curses::Window - class with the means to draw a window or box
-
Curses::MouseEvent - class for collecting mouse events
Modules
- Curses
-
The curses implementation
- Curses::Key
-
Collection of constants for keypress events
Examples
-
hello.rb
:include: sample/curses/hello.rb
-
rain.rb
:include: sample/curses/rain.rb
Defined Under Namespace
Modules: Key Classes: MouseEvent, Pad, Window
Constant Summary collapse
- VERSION =
Identifies curses library version.
-
“ncurses 5.9.20110404”
-
“PDCurses 3.4 - Public Domain 2008”
-
“curses (SVR4)” (System V curses)
-
“curses (unknown)” (The original BSD curses? NetBSD maybe.)
-
version
Class Method Summary collapse
-
.addch(ch) ⇒ Object
Add a character
ch
, with attributes, then advance the cursor. -
.addstr(str) ⇒ Object
add a string of characters
str
, to the window and advance cursor. -
.attroff(attrs) ⇒ Object
Turns on the named attributes
attrs
without affecting any others. -
.attron(attrs) ⇒ Object
Turns off the named attributes
attrs
without turning any other attributes on or off. -
.attrset(attrs) ⇒ Object
Sets the current attributes of the given window to
attrs
. -
.beep ⇒ Object
Sounds an audible alarm on the terminal, if possible; otherwise it flashes the screen (visual bell).
-
.bkgd(ch) ⇒ Object
Window background manipulation routines.
-
.bkgdset(ch) ⇒ Object
Manipulate the background of the named window with character Integer
ch
. -
.can_change_color? ⇒ Boolean
Returns
true
orfalse
depending on whether the terminal can change color attributes. -
.cbreak ⇒ Object
Put the terminal into cbreak mode.
-
.clear ⇒ Object
Clears every position on the screen completely, so that a subsequent call by Curses.refresh for the screen/window will be repainted from scratch.
-
.close_screen ⇒ Object
A program should always call Curses.close_screen before exiting or escaping from curses mode temporarily.
-
.closed? ⇒ Boolean
Returns
true
if the window/screen has been closed, without any subsequent Curses.refresh calls, returnsfalse
otherwise. -
.clrtoeol ⇒ Object
Clears to the end of line, that the cursor is currently on.
-
.color_content(color) ⇒ Object
Returns an 3 item Array of the RGB values in
color
. -
.color_pair(attrs) ⇒ Object
Sets the color pair attributes to
attrs
. -
.color_pairs ⇒ Object
Returns the COLOR_PAIRS available, if the curses library supports it.
-
.colors ⇒ Object
returns COLORS.
-
.cols ⇒ Object
Returns the number of columns on the screen.
-
.crmode ⇒ Object
Put the terminal into cbreak mode.
-
.curs_set(visibility) ⇒ Object
Sets Cursor Visibility.
-
.def_prog_mode ⇒ Object
Save the current terminal modes as the “program” state for use by the Curses.reset_prog_mode.
-
.delch ⇒ Object
Delete the character under the cursor.
-
.deleteln ⇒ Object
Delete the line under the cursor.
-
.doupdate ⇒ Object
Refreshes the windows and lines.
-
.echo ⇒ Object
Enables characters typed by the user to be echoed by Curses.getch as they are typed.
-
.ESCDELAY ⇒ Object
Returns the total time, in milliseconds, for which curses will await a character sequence, e.g., a function key.
-
.ESCDELAY=(value) ⇒ Object
Sets the ESCDELAY to Integer
value
. -
.flash ⇒ Object
Flashes the screen, for visual alarm on the terminal, if possible; otherwise it sounds the alert.
-
.getch ⇒ Object
Read and returns a character from the window.
-
.getmouse ⇒ Object
Returns coordinates of the mouse.
-
.getstr ⇒ Object
This is equivalent to a series f Curses::Window.getch calls.
-
.has_colors? ⇒ Boolean
Returns
true
orfalse
depending on whether the terminal has color capabilities. -
.inch ⇒ Object
Returns the character at the current position.
-
.init_color(color, r, g, b) ⇒ Object
Changes the definition of a color.
-
.init_pair(pair, f, b) ⇒ Object
Changes the definition of a color-pair.
-
.init_screen ⇒ Object
Initialize a standard screen.
-
.insch(ch) ⇒ Object
Insert a character
ch
, before the cursor. -
.insertln ⇒ Object
Inserts a line above the cursor, and the bottom line is lost.
-
.keyname(c) ⇒ Object
Returns the character string corresponding to key
c
. -
.lines ⇒ Object
Returns the number of lines on the screen.
-
.mouseinterval(interval) ⇒ Object
The Curses.mouseinterval function sets the maximum time (in thousands of a second) that can elapse between press and release events for them to be recognized as a click.
-
.mousemask(mask) ⇒ Object
Returns the
mask
of the reportable events. -
.nl ⇒ Object
Enable the underlying display device to translate the return key into newline on input, and whether it translates newline into return and line-feed on output (in either case, the call Curses.addch(‘n’) does the equivalent of return and line feed on the virtual screen).
-
.nocbreak ⇒ Object
Put the terminal into normal mode (out of cbreak mode).
-
.nocrmode ⇒ Object
Put the terminal into normal mode (out of cbreak mode).
-
.noecho ⇒ Object
Disables characters typed by the user to be echoed by Curses.getch as they are typed.
-
.nonl ⇒ Object
Disable the underlying display device to translate the return key into newline on input.
-
.noraw ⇒ Object
Put the terminal out of raw mode.
-
.pair_content(pair) ⇒ Object
Returns a 2 item Array, with the foreground and background color, in
pair
. -
.pair_number(attrs) ⇒ Object
Returns the Fixnum color pair number of attributes
attrs
. -
.raw ⇒ Object
Put the terminal into raw mode.
-
.refresh ⇒ Object
Refreshes the windows and lines.
-
.reset_prog_mode ⇒ Object
Reset the current terminal modes to the saved state by the Curses.def_prog_mode.
-
.resizeterm(lines, cols) ⇒ Object
Resize the current term to Fixnum
lines
and Fixnumcols
. -
.resizeterm(lines, cols) ⇒ Object
Resize the current term to Fixnum
lines
and Fixnumcols
. -
.scrl(num) ⇒ Object
Scrolls the current window Fixnum
num
lines. -
.setpos(y, x) ⇒ Object
A setter for the position of the cursor, using coordinates
x
andy
. -
.setscrreg(top, bottom) ⇒ Object
call-seq: setscrreg(top, bottom).
-
.standend ⇒ Object
Enables the Normal display (no highlight).
-
.standout ⇒ Object
Enables the best highlighting mode of the terminal.
-
.start_color ⇒ Object
Initializes the color attributes, for terminals that support it.
-
.stdscr ⇒ Object
The Standard Screen.
-
.TABSIZE ⇒ Object
Returns the number of positions in a tab.
-
.TABSIZE=(value) ⇒ Object
Sets the TABSIZE to Integer
value
. -
.timeout=(delay) ⇒ Object
Sets block and non-blocking reads for the window.
-
.ungetch(ch) ⇒ Object
Places
ch
back onto the input queue to be returned by the next call to Curses.getch. -
.ungetmouse(mevent) ⇒ Object
It pushes a KEY_MOUSE event onto the input queue, and associates with that event the given state data and screen-relative character-cell coordinates.
-
.use_default_colors ⇒ Object
tells the curses library to use terminal’s default colors.
Class Method Details
.addch(ch) ⇒ Object
Add a character ch
, with attributes, then advance the cursor.
see also the system manual for curs_addch(3)
595 596 597 598 599 600 601 |
# File 'ext/rubysl/curses/curses.c', line 595
static VALUE
curses_addch(VALUE obj, VALUE ch)
{
curses_stdscr();
addch(NUM2CH(ch));
return Qnil;
}
|
.addstr(str) ⇒ Object
add a string of characters str
, to the window and advance cursor
625 626 627 628 629 630 631 632 633 634 635 |
# File 'ext/rubysl/curses/curses.c', line 625
static VALUE
curses_addstr(VALUE obj, VALUE str)
{
StringValue(str);
str = rb_str_export_locale(str);
curses_stdscr();
if (!NIL_P(str)) {
addstr(StringValueCStr(str));
}
return Qnil;
}
|
.attroff(attrs) ⇒ Object
Turns on the named attributes attrs
without affecting any others.
See also Curses::Window.attrset for additional information.
874 875 876 877 878 879 880 |
# File 'ext/rubysl/curses/curses.c', line 874
static VALUE
curses_attroff(VALUE obj, VALUE attrs)
{
curses_stdscr();
return window_attroff(rb_stdscr,attrs);
/* return INT2FIX(attroff(NUM2INT(attrs))); */
}
|
.attron(attrs) ⇒ Object
Turns off the named attributes attrs
without turning any other attributes on or off.
See also Curses::Window.attrset for additional information.
891 892 893 894 895 896 897 |
# File 'ext/rubysl/curses/curses.c', line 891
static VALUE
curses_attron(VALUE obj, VALUE attrs)
{
curses_stdscr();
return window_attron(rb_stdscr,attrs);
/* return INT2FIX(attroff(NUM2INT(attrs))); */
}
|
.attrset(attrs) ⇒ Object
Sets the current attributes of the given window to attrs
.
see also Curses::Window.attrset
908 909 910 911 912 913 914 |
# File 'ext/rubysl/curses/curses.c', line 908
static VALUE
curses_attrset(VALUE obj, VALUE attrs)
{
curses_stdscr();
return window_attrset(rb_stdscr,attrs);
/* return INT2FIX(attroff(NUM2INT(attrs))); */
}
|
.beep ⇒ Object
Sounds an audible alarm on the terminal, if possible; otherwise it flashes the screen (visual bell).
see also Curses.flash
454 455 456 457 458 459 460 461 462 |
# File 'ext/rubysl/curses/curses.c', line 454
static VALUE
curses_beep(VALUE obj)
{
#ifdef HAVE_BEEP
curses_stdscr();
beep();
#endif
return Qnil;
}
|
.bkgd(ch) ⇒ Object
Window background manipulation routines.
Set the background property of the current and then apply the character Integer ch
setting to every character position in that window.
see also the system manual for curs_bkgd(3)
950 951 952 953 954 955 956 957 958 959 |
# File 'ext/rubysl/curses/curses.c', line 950
static VALUE
curses_bkgd(VALUE obj, VALUE ch)
{
#ifdef HAVE_BKGD
curses_stdscr();
return (bkgd(NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
}
|
.bkgdset(ch) ⇒ Object
Manipulate the background of the named window with character Integer ch
The background becomes a property of the character and moves with the character through any scrolling and insert/delete line/character operations.
see also the system manual for curs_bkgd(3)
929 930 931 932 933 934 935 936 937 |
# File 'ext/rubysl/curses/curses.c', line 929
static VALUE
curses_bkgdset(VALUE obj, VALUE ch)
{
#ifdef HAVE_BKGDSET
curses_stdscr();
bkgdset(NUM2CH(ch));
#endif
return Qnil;
}
|
.can_change_color? ⇒ Boolean
Returns true
or false
depending on whether the terminal can change color attributes
1145 1146 1147 1148 1149 1150 |
# File 'ext/rubysl/curses/curses.c', line 1145
static VALUE
curses_can_change_color(VALUE obj)
{
curses_stdscr();
return can_change_color() ? Qtrue : Qfalse;
}
|
.cbreak ⇒ Object
Put the terminal into cbreak mode.
Normally, the tty driver buffers typed characters until a newline or carriage return is typed. The Curses.cbreak routine disables line buffering and erase/kill character-processing (interrupt and flow control characters are unaffected), making characters typed by the user immediately available to the program.
The Curses.nocbreak routine returns the terminal to normal (cooked) mode.
Initially the terminal may or may not be in cbreak mode, as the mode is inherited; therefore, a program should call Curses.cbreak or Curses.nocbreak explicitly. Most interactive programs using curses set the cbreak mode. Note that Curses.cbreak overrides Curses.raw.
see also Curses.raw
385 386 387 388 389 390 391 |
# File 'ext/rubysl/curses/curses.c', line 385
static VALUE
curses_cbreak(VALUE obj)
{
curses_stdscr();
cbreak();
return Qnil;
}
|
.clear ⇒ Object
Clears every position on the screen completely, so that a subsequent call by Curses.refresh for the screen/window will be repainted from scratch.
243 244 245 246 247 248 249 |
# File 'ext/rubysl/curses/curses.c', line 243
static VALUE
curses_clear(VALUE obj)
{
curses_stdscr();
wclear(stdscr);
return Qnil;
}
|
.close_screen ⇒ Object
A program should always call Curses.close_screen before exiting or escaping from curses mode temporarily. This routine restores tty modes, moves the cursor to the lower left-hand corner of the screen and resets the terminal into the proper non-visual mode.
Calling Curses.refresh or Curses.doupdate after a temporary escape causes the program to resume visual mode.
183 184 185 186 187 188 189 190 191 192 193 |
# File 'ext/rubysl/curses/curses.c', line 183
static VALUE
curses_close_screen(void)
{
curses_stdscr();
#ifdef HAVE_ISENDWIN
if (!isendwin())
#endif
endwin();
rb_stdscr = 0;
return Qnil;
}
|
.closed? ⇒ Boolean
Returns true
if the window/screen has been closed, without any subsequent Curses.refresh calls, returns false
otherwise.
223 224 225 226 227 228 229 230 231 |
# File 'ext/rubysl/curses/curses.c', line 223
static VALUE
curses_closed(void)
{
curses_stdscr();
if (isendwin()) {
return Qtrue;
}
return Qfalse;
}
|
.clrtoeol ⇒ Object
Clears to the end of line, that the cursor is currently on.
256 257 258 259 260 261 262 |
# File 'ext/rubysl/curses/curses.c', line 256
static VALUE
curses_clrtoeol(void)
{
curses_stdscr();
clrtoeol();
return Qnil;
}
|
.color_content(color) ⇒ Object
Returns an 3 item Array of the RGB values in color
1173 1174 1175 1176 1177 1178 1179 1180 1181 |
# File 'ext/rubysl/curses/curses.c', line 1173
static VALUE
curses_color_content(VALUE obj, VALUE color)
{
short r,g,b;
curses_stdscr();
color_content(NUM2INT(color),&r,&g,&b);
return rb_ary_new3(3,INT2FIX(r),INT2FIX(g),INT2FIX(b));
}
|
.color_pair(attrs) ⇒ Object
Sets the color pair attributes to attrs
.
This should be equivalent to Curses.attrset(COLOR_PAIR(attrs
))
TODO: validate that equivalency
1226 1227 1228 1229 1230 |
# File 'ext/rubysl/curses/curses.c', line 1226
static VALUE
curses_color_pair(VALUE obj, VALUE attrs)
{
return INT2FIX(COLOR_PAIR(NUM2INT(attrs)));
}
|
.color_pairs ⇒ Object
Returns the COLOR_PAIRS available, if the curses library supports it.
1190 1191 1192 1193 1194 |
# File 'ext/rubysl/curses/curses.c', line 1190
static VALUE
curses_color_pairs(VALUE obj)
{
return INT2FIX(COLOR_PAIRS);
}
|
.colors ⇒ Object
returns COLORS
1158 1159 1160 1161 1162 |
# File 'ext/rubysl/curses/curses.c', line 1158
static VALUE
curses_colors(VALUE obj)
{
return INT2FIX(COLORS);
}
|
.cols ⇒ Object
Returns the number of columns on the screen
788 789 790 791 792 |
# File 'ext/rubysl/curses/curses.c', line 788
static VALUE
curses_cols(void)
{
return INT2FIX(COLS);
}
|
.crmode ⇒ Object
Put the terminal into cbreak mode.
Normally, the tty driver buffers typed characters until a newline or carriage return is typed. The Curses.cbreak routine disables line buffering and erase/kill character-processing (interrupt and flow control characters are unaffected), making characters typed by the user immediately available to the program.
The Curses.nocbreak routine returns the terminal to normal (cooked) mode.
Initially the terminal may or may not be in cbreak mode, as the mode is inherited; therefore, a program should call Curses.cbreak or Curses.nocbreak explicitly. Most interactive programs using curses set the cbreak mode. Note that Curses.cbreak overrides Curses.raw.
see also Curses.raw
385 386 387 388 389 390 391 |
# File 'ext/rubysl/curses/curses.c', line 385
static VALUE
curses_cbreak(VALUE obj)
{
curses_stdscr();
cbreak();
return Qnil;
}
|
.curs_set(visibility) ⇒ Object
Sets Cursor Visibility. 0: invisible 1: visible 2: very visible
803 804 805 806 807 808 809 810 811 812 813 |
# File 'ext/rubysl/curses/curses.c', line 803
static VALUE
curses_curs_set(VALUE obj, VALUE visibility)
{
#ifdef HAVE_CURS_SET
int n;
curses_stdscr();
return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil;
#else
return Qnil;
#endif
}
|
.def_prog_mode ⇒ Object
Save the current terminal modes as the “program” state for use by the Curses.reset_prog_mode
This is done automatically by Curses.init_screen
1436 1437 1438 1439 1440 1441 |
# File 'ext/rubysl/curses/curses.c', line 1436
static VALUE
curses_def_prog_mode(VALUE obj)
{
curses_stdscr();
return def_prog_mode() == OK ? Qtrue : Qfalse;
}
|
.delch ⇒ Object
Delete the character under the cursor
706 707 708 709 710 711 712 |
# File 'ext/rubysl/curses/curses.c', line 706
static VALUE
curses_delch(VALUE obj)
{
curses_stdscr();
delch();
return Qnil;
}
|
.deleteln ⇒ Object
Delete the line under the cursor.
720 721 722 723 724 725 726 727 728 |
# File 'ext/rubysl/curses/curses.c', line 720
static VALUE
curses_deleteln(VALUE obj)
{
curses_stdscr();
#if defined(HAVE_DELETELN) || defined(deleteln)
deleteln();
#endif
return Qnil;
}
|
.doupdate ⇒ Object
Refreshes the windows and lines.
Curses.doupdate allows multiple updates with more efficiency than Curses.refresh alone.
286 287 288 289 290 291 292 293 294 295 296 |
# File 'ext/rubysl/curses/curses.c', line 286
static VALUE
curses_doupdate(VALUE obj)
{
curses_stdscr();
#ifdef HAVE_DOUPDATE
doupdate();
#else
refresh();
#endif
return Qnil;
}
|
.echo ⇒ Object
Enables characters typed by the user to be echoed by Curses.getch as they are typed.
304 305 306 307 308 309 310 |
# File 'ext/rubysl/curses/curses.c', line 304
static VALUE
curses_echo(VALUE obj)
{
curses_stdscr();
echo();
return Qnil;
}
|
.ESCDELAY ⇒ Object
Returns the total time, in milliseconds, for which curses will await a character sequence, e.g., a function key
1029 1030 1031 1032 1033 |
# File 'ext/rubysl/curses/curses.c', line 1029
static VALUE
curses_escdelay_get(VALUE obj)
{
return INT2NUM(ESCDELAY);
}
|
.ESCDELAY=(value) ⇒ Object
Sets the ESCDELAY to Integer value
1014 1015 1016 1017 1018 1019 |
# File 'ext/rubysl/curses/curses.c', line 1014
static VALUE
curses_escdelay_set(VALUE obj, VALUE val)
{
ESCDELAY = NUM2INT(val);
return INT2NUM(ESCDELAY);
}
|
.flash ⇒ Object
Flashes the screen, for visual alarm on the terminal, if possible; otherwise it sounds the alert.
see also Curses.beep
472 473 474 475 476 477 478 479 480 |
# File 'ext/rubysl/curses/curses.c', line 472
static VALUE
curses_flash(VALUE obj)
{
#ifdef HAVE_FLASH
curses_stdscr();
flash();
#endif
return Qnil;
}
|
.getch ⇒ Object
Read and returns a character from the window.
See Curses::Key to all the function KEY_* available
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'ext/rubysl/curses/curses.c', line 653
static VALUE
curses_getch(VALUE obj)
{
int c;
curses_stdscr();
rb_thread_call_without_gvl(getch_func, &c, RUBY_UBF_IO, 0);
if (c == EOF) return Qnil;
if (rb_isprint(c)) {
char ch = (char)c;
return rb_locale_str_new(&ch, 1);
}
return UINT2NUM(c);
}
|
.getmouse ⇒ Object
Returns coordinates of the mouse.
This will read and pop the mouse event data off the queue
See the BUTTON*, ALL_MOUSE_EVENTS and REPORT_MOUSE_POSITION constants, to examine the mask of the event
1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
# File 'ext/rubysl/curses/curses.c', line 1296
static VALUE
curses_getmouse(VALUE obj)
{
struct mousedata *mdata;
VALUE val;
curses_stdscr();
val = TypedData_Make_Struct(cMouseEvent,struct mousedata,
&mousedata_type,mdata);
mdata->mevent = (MEVENT*)xmalloc(sizeof(MEVENT));
return (getmouse(mdata->mevent) == OK) ? val : Qnil;
}
|
.getstr ⇒ Object
This is equivalent to a series f Curses::Window.getch calls
690 691 692 693 694 695 696 697 698 |
# File 'ext/rubysl/curses/curses.c', line 690
static VALUE
curses_getstr(VALUE obj)
{
char rtn[GETSTR_BUF_SIZE];
curses_stdscr();
rb_thread_call_without_gvl(getstr_func, rtn, RUBY_UBF_IO, 0);
return rb_locale_str_new_cstr(rtn);
}
|
.has_colors? ⇒ Boolean
Returns true
or false
depending on whether the terminal has color capabilities.
1133 1134 1135 1136 1137 1138 |
# File 'ext/rubysl/curses/curses.c', line 1133
static VALUE
curses_has_colors(VALUE obj)
{
curses_stdscr();
return has_colors() ? Qtrue : Qfalse;
}
|
.inch ⇒ Object
Returns the character at the current position.
580 581 582 583 584 585 |
# File 'ext/rubysl/curses/curses.c', line 580
static VALUE
curses_inch(VALUE obj)
{
curses_stdscr();
return CH2FIX(inch());
}
|
.init_color(color, r, g, b) ⇒ Object
Changes the definition of a color. It takes four arguments:
-
the number of the color to be changed,
color
-
the amount of red,
r
-
the amount of green,
g
-
the amount of blue,
b
The value of the first argument must be between 0 and COLORS. (See the section Colors for the default color index.) Each of the last three arguments must be a value between 0 and 1000. When Curses.init_color is used, all occurrences of that color on the screen immediately change to the new definition.
1119 1120 1121 1122 1123 1124 1125 1126 |
# File 'ext/rubysl/curses/curses.c', line 1119
static VALUE
curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b)
{
/* may have to raise exception on ERR */
curses_stdscr();
return (init_color(NUM2INT(color),NUM2INT(r),
NUM2INT(g),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
}
|
.init_pair(pair, f, b) ⇒ Object
Changes the definition of a color-pair.
It takes three arguments: the number of the color-pair to be changed pair
, the foreground color number f
, and the background color number b
.
If the color-pair was previously initialized, the screen is refreshed and all occurrences of that color-pair are changed to the new definition.
1095 1096 1097 1098 1099 1100 1101 |
# File 'ext/rubysl/curses/curses.c', line 1095
static VALUE
curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b)
{
/* may have to raise exception on ERR */
curses_stdscr();
return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
}
|
.init_screen ⇒ Object
Initialize a standard screen
see also Curses.stdscr
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'ext/rubysl/curses/curses.c', line 145
static VALUE
curses_init_screen(void)
{
if (rb_stdscr) return rb_stdscr;
initscr();
if (stdscr == 0) {
rb_raise(rb_eRuntimeError, "can't initialize curses");
}
clear();
rb_stdscr = prep_window(cWindow, stdscr);
return rb_stdscr;
}
|
.insch(ch) ⇒ Object
Insert a character ch
, before the cursor.
610 611 612 613 614 615 616 |
# File 'ext/rubysl/curses/curses.c', line 610
static VALUE
curses_insch(VALUE obj, VALUE ch)
{
curses_stdscr();
insch(NUM2CH(ch));
return Qnil;
}
|
.insertln ⇒ Object
Inserts a line above the cursor, and the bottom line is lost
736 737 738 739 740 741 742 743 744 |
# File 'ext/rubysl/curses/curses.c', line 736
static VALUE
curses_insertln(VALUE obj)
{
curses_stdscr();
#if defined(HAVE_INSERTLN) || defined(insertln)
insertln();
#endif
return Qnil;
}
|
.keyname(c) ⇒ Object
Returns the character string corresponding to key c
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 |
# File 'ext/rubysl/curses/curses.c', line 752
static VALUE
curses_keyname(VALUE obj, VALUE c)
{
#ifdef HAVE_KEYNAME
int cc = curses_char(c);
const char *name;
curses_stdscr();
name = keyname(cc);
if (name) {
return rb_str_new_cstr(name);
}
else {
return Qnil;
}
#else
return Qnil;
#endif
}
|
.lines ⇒ Object
Returns the number of lines on the screen
777 778 779 780 781 |
# File 'ext/rubysl/curses/curses.c', line 777
static VALUE
curses_lines(void)
{
return INT2FIX(LINES);
}
|
.mouseinterval(interval) ⇒ Object
The Curses.mouseinterval function sets the maximum time (in thousands of a second) that can elapse between press and release events for them to be recognized as a click.
Use Curses.mouseinterval(0) to disable click resolution. This function returns the previous interval value.
Use Curses.mouseinterval(-1) to obtain the interval without altering it.
The default is one sixth of a second.
1343 1344 1345 1346 1347 1348 |
# File 'ext/rubysl/curses/curses.c', line 1343
static VALUE
curses_mouseinterval(VALUE obj, VALUE interval)
{
curses_stdscr();
return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse;
}
|
.mousemask(mask) ⇒ Object
Returns the mask
of the reportable events
1356 1357 1358 1359 1360 1361 |
# File 'ext/rubysl/curses/curses.c', line 1356
static VALUE
curses_mousemask(VALUE obj, VALUE mask)
{
curses_stdscr();
return INT2NUM(mousemask(NUM2UINT(mask),NULL));
}
|
.nl ⇒ Object
Enable the underlying display device to translate the return key into newline on input, and whether it translates newline into return and line-feed on output (in either case, the call Curses.addch(‘n’) does the equivalent of return and line feed on the virtual screen).
Initially, these translations do occur. If you disable them using Curses.nonl, curses will be able to make better use of the line-feed capability, resulting in faster cursor motion. Also, curses will then be able to detect the return key.
422 423 424 425 426 427 428 |
# File 'ext/rubysl/curses/curses.c', line 422
static VALUE
curses_nl(VALUE obj)
{
curses_stdscr();
nl();
return Qnil;
}
|
.nocbreak ⇒ Object
Put the terminal into normal mode (out of cbreak mode).
See Curses.cbreak for more detail.
400 401 402 403 404 405 406 |
# File 'ext/rubysl/curses/curses.c', line 400
static VALUE
curses_nocbreak(VALUE obj)
{
curses_stdscr();
nocbreak();
return Qnil;
}
|
.nocrmode ⇒ Object
Put the terminal into normal mode (out of cbreak mode).
See Curses.cbreak for more detail.
400 401 402 403 404 405 406 |
# File 'ext/rubysl/curses/curses.c', line 400
static VALUE
curses_nocbreak(VALUE obj)
{
curses_stdscr();
nocbreak();
return Qnil;
}
|
.noecho ⇒ Object
Disables characters typed by the user to be echoed by Curses.getch as they are typed.
318 319 320 321 322 323 324 |
# File 'ext/rubysl/curses/curses.c', line 318
static VALUE
curses_noecho(VALUE obj)
{
curses_stdscr();
noecho();
return Qnil;
}
|
.nonl ⇒ Object
Disable the underlying display device to translate the return key into newline on input
See Curses.nl for more detail
438 439 440 441 442 443 444 |
# File 'ext/rubysl/curses/curses.c', line 438
static VALUE
curses_nonl(VALUE obj)
{
curses_stdscr();
nonl();
return Qnil;
}
|
.noraw ⇒ Object
Put the terminal out of raw mode.
see Curses.raw for more detail
355 356 357 358 359 360 361 |
# File 'ext/rubysl/curses/curses.c', line 355
static VALUE
curses_noraw(VALUE obj)
{
curses_stdscr();
noraw();
return Qnil;
}
|
.pair_content(pair) ⇒ Object
Returns a 2 item Array, with the foreground and background color, in pair
1206 1207 1208 1209 1210 1211 1212 1213 1214 |
# File 'ext/rubysl/curses/curses.c', line 1206
static VALUE
curses_pair_content(VALUE obj, VALUE pair)
{
short f,b;
curses_stdscr();
pair_content(NUM2INT(pair),&f,&b);
return rb_ary_new3(2,INT2FIX(f),INT2FIX(b));
}
|
.pair_number(attrs) ⇒ Object
Returns the Fixnum color pair number of attributes attrs
.
1238 1239 1240 1241 1242 1243 |
# File 'ext/rubysl/curses/curses.c', line 1238
static VALUE
curses_pair_number(VALUE obj, VALUE attrs)
{
curses_stdscr();
return INT2FIX(PAIR_NUMBER(NUM2LONG(attrs)));
}
|
.raw ⇒ Object
Put the terminal into raw mode.
Raw mode is similar to Curses.cbreak mode, in that characters typed are immediately passed through to the user program.
The differences are that in raw mode, the interrupt, quit, suspend, and flow control characters are all passed through uninterpreted, instead of generating a signal. The behavior of the BREAK key depends on other bits in the tty driver that are not set by curses.
340 341 342 343 344 345 346 |
# File 'ext/rubysl/curses/curses.c', line 340
static VALUE
curses_raw(VALUE obj)
{
curses_stdscr();
raw();
return Qnil;
}
|
.refresh ⇒ Object
Refreshes the windows and lines.
270 271 272 273 274 275 276 |
# File 'ext/rubysl/curses/curses.c', line 270
static VALUE
curses_refresh(VALUE obj)
{
curses_stdscr();
refresh();
return Qnil;
}
|
.reset_prog_mode ⇒ Object
Reset the current terminal modes to the saved state by the Curses.def_prog_mode
This is done automatically by Curses.close_screen
1455 1456 1457 1458 1459 1460 |
# File 'ext/rubysl/curses/curses.c', line 1455
static VALUE
curses_reset_prog_mode(VALUE obj)
{
curses_stdscr();
return reset_prog_mode() == OK ? Qtrue : Qfalse;
}
|
.resizeterm(lines, cols) ⇒ Object
Resize the current term to Fixnum lines
and Fixnum cols
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
# File 'ext/rubysl/curses/curses.c', line 1053
static VALUE
curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
{
#if defined(HAVE_RESIZETERM)
curses_stdscr();
return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse;
#else
return Qnil;
#endif
}
|
.resizeterm(lines, cols) ⇒ Object
Resize the current term to Fixnum lines
and Fixnum cols
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
# File 'ext/rubysl/curses/curses.c', line 1053
static VALUE
curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
{
#if defined(HAVE_RESIZETERM)
curses_stdscr();
return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse;
#else
return Qnil;
#endif
}
|
.scrl(num) ⇒ Object
Scrolls the current window Fixnum num
lines. The current cursor position is not changed.
For positive num
, it scrolls up.
For negative num
, it scrolls down.
827 828 829 830 831 832 833 834 835 836 837 |
# File 'ext/rubysl/curses/curses.c', line 827
static VALUE
curses_scrl(VALUE obj, VALUE n)
{
/* may have to raise exception on ERR */
#ifdef HAVE_SCRL
curses_stdscr();
return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
}
|
.setpos(y, x) ⇒ Object
A setter for the position of the cursor, using coordinates x
and y
533 534 535 536 537 538 539 |
# File 'ext/rubysl/curses/curses.c', line 533
static VALUE
curses_setpos(VALUE obj, VALUE y, VALUE x)
{
curses_stdscr();
move(NUM2INT(y), NUM2INT(x));
return Qnil;
}
|
.setscrreg(top, bottom) ⇒ Object
call-seq:
setscrreg(top, bottom)
Set a software scrolling region in a window. top
and bottom
are lines numbers of the margin.
If this option and Curses.scrollok are enabled, an attempt to move off the bottom margin line causes all lines in the scrolling region to scroll one line in the direction of the first line. Only the text of the window is scrolled.
854 855 856 857 858 859 860 861 862 863 864 |
# File 'ext/rubysl/curses/curses.c', line 854
static VALUE
curses_setscrreg(VALUE obj, VALUE top, VALUE bottom)
{
/* may have to raise exception on ERR */
#ifdef HAVE_SETSCRREG
curses_stdscr();
return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
}
|
.standend ⇒ Object
Enables the Normal display (no highlight)
This is equivalent to Curses.attron(A_NORMAL)
see also Curses::Window.attrset for additional information.
567 568 569 570 571 572 573 |
# File 'ext/rubysl/curses/curses.c', line 567
static VALUE
curses_standend(VALUE obj)
{
curses_stdscr();
standend();
return Qnil;
}
|
.standout ⇒ Object
Enables the best highlighting mode of the terminal.
This is equivalent to Curses:Window.attron(A_STANDOUT)
see also Curses::Window.attrset additional information
550 551 552 553 554 555 556 |
# File 'ext/rubysl/curses/curses.c', line 550
static VALUE
curses_standout(VALUE obj)
{
curses_stdscr();
standout();
return Qnil;
}
|
.start_color ⇒ Object
Initializes the color attributes, for terminals that support it.
This must be called, in order to use color attributes. It is good practice to call it just after Curses.init_screen
1073 1074 1075 1076 1077 1078 1079 |
# File 'ext/rubysl/curses/curses.c', line 1073
static VALUE
curses_start_color(VALUE obj)
{
/* may have to raise exception on ERR */
curses_stdscr();
return (start_color() == OK) ? Qtrue : Qfalse;
}
|
.stdscr ⇒ Object
The Standard Screen.
Upon initializing curses, a default window called stdscr, which is the size of the terminal screen, is created.
Many curses functions use this window.
.TABSIZE ⇒ Object
Returns the number of positions in a tab.
999 1000 1001 1002 1003 |
# File 'ext/rubysl/curses/curses.c', line 999
static VALUE
curses_tabsize_get(VALUE ojb)
{
return INT2NUM(TABSIZE);
}
|
.TABSIZE=(value) ⇒ Object
Sets the TABSIZE to Integer value
985 986 987 988 989 990 |
# File 'ext/rubysl/curses/curses.c', line 985
static VALUE
curses_tabsize_set(VALUE obj, VALUE val)
{
TABSIZE = NUM2INT(val);
return INT2NUM(TABSIZE);
}
|
.timeout=(delay) ⇒ Object
Sets block and non-blocking reads for the window.
-
If delay is negative, blocking read is used (i.e., waits indefinitely for input).
-
If delay is zero, then non-blocking read is used (i.e., read returns ERR if no input is waiting).
-
If delay is positive, then read blocks for delay milliseconds, and returns ERR if there is still no input.
.ungetch(ch) ⇒ Object
Places ch
back onto the input queue to be returned by the next call to Curses.getch.
There is just one input queue for all windows.
513 514 515 516 517 518 519 520 |
# File 'ext/rubysl/curses/curses.c', line 513
static VALUE
curses_ungetch(VALUE obj, VALUE ch)
{
int c = curses_char(ch);
curses_stdscr();
ungetch(c);
return Qnil;
}
|
.ungetmouse(mevent) ⇒ Object
It pushes a KEY_MOUSE event onto the input queue, and associates with that event the given state data and screen-relative character-cell coordinates.
The Curses.ungetmouse function behaves analogously to Curses.ungetch.
1317 1318 1319 1320 1321 1322 1323 1324 1325 |
# File 'ext/rubysl/curses/curses.c', line 1317
static VALUE
curses_ungetmouse(VALUE obj, VALUE mevent)
{
struct mousedata *mdata;
curses_stdscr();
GetMOUSE(mevent,mdata);
return (ungetmouse(mdata->mevent) == OK) ? Qtrue : Qfalse;
}
|
.use_default_colors ⇒ Object
tells the curses library to use terminal’s default colors.
see also the system manual for default_colors(3)
967 968 969 970 971 972 973 |
# File 'ext/rubysl/curses/curses.c', line 967
static VALUE
curses_use_default_colors(VALUE obj)
{
curses_stdscr();
use_default_colors();
return Qnil;
}
|