Project

General

Profile

Bug #4748 » ruby_doc_updates-20110520_1648-curses_vbatts.patch

vbatts (Vincent Batts), 05/21/2011 05:55 AM

View differences:

ext/curses/curses.c
*/
#define curses_stdscr curses_init_screen
/*
* Document-method: Curses.close_screen
*
* 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.
*
*/
static VALUE
curses_close_screen(void)
{
......
return Qnil;
}
/*
* This is no runtime method,
* but a function called before the proc ends
*
* Similar to Curses.close_screen, except that it also
* garbage collects/unregisters the Curses.stdscr
*/
static void
curses_finalize(VALUE dummy)
{
......
}
#ifdef HAVE_ISENDWIN
/*
* Document-method: Curses.closed?
*
* Returns +true+ if the window/screen has been closed,
* without any subsequent Curses.refresh calls,
* returns +false+ otherwise.
*/
static VALUE
curses_closed(void)
{
......
#define curses_closed rb_f_notimplement
#endif
/*
* Document-method: Curses.clear
*
* Clears every position on the screen completely,
* so that a subsequent call by Curses.refresh for the screen/window
* will be repainted from scratch.
*/
static VALUE
curses_clear(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.clrtoeol
*
* Clears to the end of line, that the cursor is currently on.
*/
static VALUE
curses_clrtoeol(void)
{
......
return Qnil;
}
/*
* Document-method: Curses.refresh
*
* Refreshes the windows and lines.
*
*/
static VALUE
curses_refresh(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.doupdate
*
* Refreshes the windows and lines.
*
* Curses.doupdate allows multiple updates with
* more efficiency than Curses.refresh alone.
*/
static VALUE
curses_doupdate(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.echo
*
* Enables characters typed by the user
* to be echoed by Curses.getch as they are typed.
*/
static VALUE
curses_echo(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.noecho
*
* Disables characters typed by the user
* to be echoed by Curses.getch as they are typed.
*/
static VALUE
curses_noecho(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.raw
*
* 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.
*/
static VALUE
curses_raw(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.noraw
*
* Put the terminal out of raw mode.
*
* see Curses.raw for more detail
*/
static VALUE
curses_noraw(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.cbreak
*
* 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
*/
static VALUE
curses_cbreak(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.nocbreak
*
* Put the terminal into normal mode (out of cbreak mode).
*
* See Curses.cbreak for more detail.
*/
static VALUE
curses_nocbreak(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.nl
*
* 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.
*/
static VALUE
curses_nl(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.nl
*
* Disable the underlying display device to translate
* the return key into newline on input
*
* See Curses.nl for more detail
*/
static VALUE
curses_nonl(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.beep
*
* Sounds an audible alarm on the terminal, if possible;
* otherwise it flashes the screen (visual bell).
*
* see also Curses.flash
*/
static VALUE
curses_beep(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.flash
*
* Flashs the screen, for visual alarm on the terminal, if possible;
* otherwise it sounds the alert.
*
* see also Curses.beep
*/
static VALUE
curses_flash(VALUE obj)
{
......
#define curses_ungetch rb_f_notimplement
#endif
/*
* Document-method: Curses.setpos
* call-seq: setpos(y, x)
*
* A setter for the position of the cursor,
* using coordinates +x+ and +y+
*
*/
static VALUE
curses_setpos(VALUE obj, VALUE y, VALUE x)
{
......
return Qnil;
}
/*
* Document-method: Curses.standout
*
* Enables the best highlighting mode of the terminal.
*
* This is equivalent to Curses:Window.attron(A_STANDOUT)
*
* see also Curses::Window.attrset additional information
*/
static VALUE
curses_standout(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.standend
*
* Enables the Normal display (no highlight)
*
* This is equivalent to Curses.attron(A_NORMAL)
*
* see also Curses::Window.attrset for additional information.
*/
static VALUE
curses_standend(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.inch
*
* Returns the character at the current position.
*/
static VALUE
curses_inch(VALUE obj)
{
......
return CH2FIX(inch());
}
/*
* Document-method: Curses.addch
* call-seq: addch(ch)
*
* Add a character +ch+, with attributes, then advance the cursor.
*
* see also the system manual for curs_addch(3)
*/
static VALUE
curses_addch(VALUE obj, VALUE ch)
{
......
return Qnil;
}
/*
* Document-method: Curses.insch
* call-seq: insch(ch)
*
* Insert a character +ch+, before the cursor.
*
*/
static VALUE
curses_insch(VALUE obj, VALUE ch)
{
......
return Qnil;
}
/*
* Document-method: Curses.getstr
*
* This is equivalent to a series f Curses::Window.getch calls
*
*/
static VALUE
curses_getstr(VALUE obj)
{
......
return rb_locale_str_new_cstr(rtn);
}
/*
* Document-method: Curses.delch
*
* Delete the character under the cursor
*
*/
static VALUE
curses_delch(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.deleteln
*
* Delete the line under the cursor.
*
*/
static VALUE
curses_deleteln(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.insertln
*
* Inserts a line above the cursor, and the bottom line is lost
*
*/
static VALUE
curses_insertln(VALUE obj)
{
......
return Qnil;
}
/*
* Document-method: Curses.keyname
* call-seq: keyname(c)
*
* Returns the character string corresponding to key +c+
*/
static VALUE
curses_keyname(VALUE obj, VALUE c)
{
......
#endif
}
/*
* Document-method: Curses.lines
*
* Returns the number of lines on the screen
*/
static VALUE
curses_lines(void)
{
return INT2FIX(LINES);
}
/*
* Document-method: Curses.cols
*
* Returns the number of columns on the screen
*/
static VALUE
curses_cols(void)
{
return INT2FIX(COLS);
}
/**
/*
* Document-method: Curses.curs_set
* call-seq: curs_set(visibility)
*
* Sets Cursor Visibility.
* 0: invisible
* 1: visible
......
#endif
}
/*
* Document-method: Curses.scrl
* call-seq: scrl(num)
*
* 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.
*
*/
static VALUE
curses_scrl(VALUE obj, VALUE n)
{
......
#endif
}
/*
* Document-method: Curses.setscrreg
* 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.
*
*/
static VALUE
curses_setscrreg(VALUE obj, VALUE top, VALUE bottom)
{
......
#endif
}
/*
* Document-method: Curses.attroff
* call-seq: attroff(attrs)
*
* Turns on the named attributes +attrs+ without affecting any others.
*
* See also Curses::Window.attrset for additional information.
*/
static VALUE
curses_attroff(VALUE obj, VALUE attrs)
{
......
/* return INT2FIX(attroff(NUM2INT(attrs))); */
}
/*
* Document-method: Curses.attron
* call-seq: attron(attrs)
*
* Turns off the named attributes +attrs+
* without turning any other attributes on or off.
*
* See also Curses::Window.attrset for additional information.
*/
static VALUE
curses_attron(VALUE obj, VALUE attrs)
{
......
}
/*
* Document-method: Curses.attrset
* call-seq: attrset(attrs)
*
* Sets the current attributes of the given window to +attrs+.
*
* see also Curses::Window.attrset
*
*/
......
}
#ifdef USE_COLOR
/*
* Document-method: Curses.start_color
*
* 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
*/
static VALUE
curses_start_color(VALUE obj)
{
......
return (start_color() == OK) ? Qtrue : Qfalse;
}
/*
* Document-method: Curses.init_pair
* call-seq: init_pair(pair, f, b)
*
* 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.
*
*/
static VALUE
curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b)
{
......
return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
}
/*
* Document-method: Curses.init_color
* call-seq: init_color(color, r, g, b)
*
* 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.
*/
static VALUE
curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b)
{
......
NUM2INT(g),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
}
/*
* Document-method: Curses.has_colors?
*
* Returns +true+ or +false+ depending on whether the terminal has color capbilities.
*/
static VALUE
curses_has_colors(VALUE obj)
{
......
return has_colors() ? Qtrue : Qfalse;
}
/*
* Document-method: Curses.can_change_color?
*
* Returns +true+ or +false+ depending on whether the terminal can change color attributes
*/
static VALUE
curses_can_change_color(VALUE obj)
{
......
}
#if defined(HAVE_COLORS)
/*
* Document-method: Curses.color
*
* returns COLORS
*/
static VALUE
curses_colors(VALUE obj)
{
......
#define curses_colors rb_f_notimplement
#endif
/*
* Document-method: Curses.color_content
* call-seq: color_content(color)
*
* Returns an 3 item Array of the RGB values in +color+
*/
static VALUE
curses_color_content(VALUE obj, VALUE color)
{
......
#if defined(HAVE_COLOR_PAIRS)
/*
* Document-method: Curses.color_pairs
*
* Returns the COLOR_PAIRS available, if the curses library supports it.
*/
static VALUE
curses_color_pairs(VALUE obj)
{
......
#define curses_color_pairs rb_f_notimplement
#endif
/*
* Document-method: Curses.pair_content
* call-seq: pair_content(pair)
*
* Returns a 2 item Array, with the foreground and
* background color, in +pair+
*/
static VALUE
curses_pair_content(VALUE obj, VALUE pair)
{
......
return rb_ary_new3(2,INT2FIX(f),INT2FIX(b));
}
/*
* Document-method: Curses.color_pair
* call-seq: color_pair(attrs)
*
* Sets the color pair attributes to +attrs+.
*
* This should be equivalent to Curses.attrset(COLOR_PAIR(+attrs+))
*
* TODO: validate that equivalency
*/
static VALUE
curses_color_pair(VALUE obj, VALUE attrs)
{
return INT2FIX(COLOR_PAIR(NUM2INT(attrs)));
}
/*
* Document-method: Curses.pair_number
* call-seq: pair_number(attrs)
*
* Returns the Fixnum color pair number of attributes +attrs+.
*/
static VALUE
curses_pair_number(VALUE obj, VALUE attrs)
{
......
/*
* Document-method: Curses.getmouse
*
* Returns the current mouse or nil
* Returns coordinates of the mouse.
*
* This will read and pop the mouse event data off the queue
*
* TODO: all the BUTTON* constants are needed here, to examine the mask of the event
*/
static VALUE
curses_getmouse(VALUE obj)
......
return (getmouse(mdata->mevent) == OK) ? val : Qnil;
}
/*
* Document-method: Curses.ungetmouse
*
* 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.
*/
static VALUE
curses_ungetmouse(VALUE obj, VALUE mevent)
{
......
return (ungetmouse(mdata->mevent) == OK) ? Qtrue : Qfalse;
}
/*
* Document-method: Curses.mouseinterval
* call-seq: mouseinterval(interval)
*
* 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.
*/
static VALUE
curses_mouseinterval(VALUE obj, VALUE interval)
{
......
return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse;
}
/*
* Document-method: Curses.mousemask
* call-seq: mousemask(mask)
*
* Returns the +mask+ of the reportable events
*/
static VALUE
curses_mousemask(VALUE obj, VALUE mask)
{
......
#endif
#ifdef HAVE_DEF_PROG_MODE
/*
* Document-method: Curses.def_prog_mode
*
* 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
*/
static VALUE
curses_def_prog_mode(VALUE obj)
{
......
#endif
#ifdef HAVE_RESET_PROG_MODE
/*
* Document-method: Curses.reset_prog_mode
*
* Reset the current terminal modes to the saved state
* by the Curses.def_prog_mode
*
* This is done automatically by Curses.close_screen
*/
static VALUE
curses_reset_prog_mode(VALUE obj)
{
......
* Document-method: Curses::Window.setpos
* call-seq: setpos(y, x)
*
* A setter for the position of the window,
* A setter for the position of the cursor
* in the current window,
* using coordinates +x+ and +y+
*
*/
......
* == Description
* An implementation of the CRT screen handling and optimization library.
*
* == Structures
* == Structures and such
*
* === Classes
*
......
* * Curses - basis for the curses implementation
* * Curses::Key - the collection of constants
*
* === Constants
*
* For whatever reason, these are not picked up in the RDoc
* These are Integer of the colors.
*
* * COLOR_BLACK = 0
* * COLOR_RED = 1
* * COLOR_GREEN = 2
* * COLOR_YELLOW = 3
* * COLOR_BLUE = 4
* * COLOR_MAGENTA = 5
* * COLOR_CYAN = 6
* * COLOR_WHITE = 7
*
*
* == Examples
*
* * hello.rb
......
* * rain.rb
* :include: rain.rb
*
*
* == TODO
*
* * document all the A_* constants
* * document all the BUTTON*_* constants
* * document all the ALL_MOUSE_EVENTS and REPORT_MOUSE_POSITION constants
*/
void
Init_curses(void)
......
rb_curses_define_const(A_COLOR);
#ifdef COLORS
/*
* Document-const: Curses::COLORS
*
* Integer of the colors available
*/
rb_curses_define_const(COLORS);
#endif
/*
* Document-const: Curses::COLOR_BLACK
*
* Integer of the color black
*/
rb_curses_define_const(COLOR_BLACK);
/*
* Document-const: COLOR_RED
*
* Integer of the color red
*/
rb_curses_define_const(COLOR_RED);
/*
* Document-const: COLOR_GREEN
*
* Integer of the color green
*/
rb_curses_define_const(COLOR_GREEN);
/*
* Document-const: COLOR_YELLOW
*
* Integer of the color yellow
*/
rb_curses_define_const(COLOR_YELLOW);
/*
* Document-const: COLOR_BLUE
*
* Integer of the color blue
*/
rb_curses_define_const(COLOR_BLUE);
/*
* Document-const: COLOR_MAGENTA
*
* Integer of the color magenta
*/
rb_curses_define_const(COLOR_MAGENTA);
/*
* Document-const: COLOR_CYAN
*
* Integer of the color cyan
*/
rb_curses_define_const(COLOR_CYAN);
/*
* Document-const: COLOR_WHITE
*
* Integer of the color white
*/
rb_curses_define_const(COLOR_WHITE);
#endif /* USE_COLOR */
#ifdef USE_MOUSE
(1-1/2)