[ruby/io-console] [DOC] Add missing documents

https://github.com/ruby/io-console/commit/44dce34569
This commit is contained in:
Nobuyoshi Nakada 2023-12-16 15:55:45 +09:00 committed by Hiroshi SHIBATA
parent 4173c4bcfb
commit e7f91fd74c

View File

@ -898,6 +898,16 @@ console_set_winsize(VALUE io, VALUE size)
#endif
#ifdef _WIN32
/*
* call-seq:
* io.check_winsize_changed { ... } -> io
*
* Yields while console input events are queued.
*
* This method is Windows only.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_check_winsize_changed(VALUE io)
{
@ -984,6 +994,14 @@ console_ioflush(VALUE io)
return io;
}
/*
* call-seq:
* io.beep
*
* Beeps on the output console.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_beep(VALUE io)
{
@ -1051,6 +1069,17 @@ console_scroll(VALUE io, int line)
#include "win32_vk.inc"
/*
* call-seq:
* io.pressed?(key) -> bool
*
* Returns +true+ if +key+ is pressed. +key+ may be a virtual key
* code or its name (String or Symbol) with out "VK_" prefix.
*
* This method is Windows only.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_key_pressed_p(VALUE io, VALUE k)
{
@ -1194,6 +1223,14 @@ console_cursor_pos(VALUE io)
#endif
}
/*
* call-seq:
* io.goto(line, column) -> io
*
* Set the cursor position at +line+ and +column+.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_goto(VALUE io, VALUE y, VALUE x)
{
@ -1240,6 +1277,15 @@ console_move(VALUE io, int y, int x)
return io;
}
/*
* call-seq:
* io.goto_column(column) -> io
*
* Set the cursor position at +column+ in the same line of the current
* position.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_goto_column(VALUE io, VALUE val)
{
@ -1262,6 +1308,18 @@ console_goto_column(VALUE io, VALUE val)
return io;
}
/*
* call-seq:
* io.erase_line(mode) -> io
*
* Erases the line at the cursor corresponding to +mode+.
* +mode+ may be either:
* 0: after cursor
* 1: before and cursor
* 2: entire line
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_erase_line(VALUE io, VALUE val)
{
@ -1297,6 +1355,18 @@ console_erase_line(VALUE io, VALUE val)
return io;
}
/*
* call-seq:
* io.erase_screen(mode) -> io
*
* Erases the screen at the cursor corresponding to +mode+.
* +mode+ may be either:
* 0: after cursor
* 1: before and cursor
* 2: entire screen
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_erase_screen(VALUE io, VALUE val)
{
@ -1339,6 +1409,16 @@ console_erase_screen(VALUE io, VALUE val)
return io;
}
/*
* call-seq:
* io.cursor = [line, column] -> io
*
* Same as <tt>io.goto(line, column)</tt>
*
* See IO#goto.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_cursor_set(VALUE io, VALUE cpos)
{
@ -1347,42 +1427,98 @@ console_cursor_set(VALUE io, VALUE cpos)
return console_goto(io, RARRAY_AREF(cpos, 0), RARRAY_AREF(cpos, 1));
}
/*
* call-seq:
* io.cursor_up(n) -> io
*
* Moves the cursor up +n+ lines.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_cursor_up(VALUE io, VALUE val)
{
return console_move(io, -NUM2INT(val), 0);
}
/*
* call-seq:
* io.cursor_down(n) -> io
*
* Moves the cursor down +n+ lines.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_cursor_down(VALUE io, VALUE val)
{
return console_move(io, +NUM2INT(val), 0);
}
/*
* call-seq:
* io.cursor_left(n) -> io
*
* Moves the cursor left +n+ columns.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_cursor_left(VALUE io, VALUE val)
{
return console_move(io, 0, -NUM2INT(val));
}
/*
* call-seq:
* io.cursor_right(n) -> io
*
* Moves the cursor right +n+ columns.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_cursor_right(VALUE io, VALUE val)
{
return console_move(io, 0, +NUM2INT(val));
}
/*
* call-seq:
* io.scroll_forward(n) -> io
*
* Scrolls the entire scrolls forward +n+ lines.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_scroll_forward(VALUE io, VALUE val)
{
return console_scroll(io, +NUM2INT(val));
}
/*
* call-seq:
* io.scroll_backward(n) -> io
*
* Scrolls the entire scrolls backward +n+ lines.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_scroll_backward(VALUE io, VALUE val)
{
return console_scroll(io, -NUM2INT(val));
}
/*
* call-seq:
* io.clear_screen -> io
*
* Clears the entire screen and moves the cursor top-left corner.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_clear_screen(VALUE io)
{
@ -1677,7 +1813,9 @@ InitVM_console(void)
rb_define_method(rb_cIO, "getpass", console_getpass, -1);
rb_define_singleton_method(rb_cIO, "console", console_dev, -1);
{
/* :stopdoc: */
VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
/* :startdoc: */
rb_define_method(mReadable, "getch", io_getch, -1);
rb_define_method(mReadable, "getpass", io_getpass, -1);
}