summaryrefslogtreecommitdiff
path: root/ext/readline
diff options
context:
space:
mode:
authorkouji <kouji@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-06 12:52:22 +0000
committerkouji <kouji@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-06 12:52:22 +0000
commita78713ce45fa006cdbf4c72d0fa1a4f1fd8c38fa (patch)
treed858ad7ee09defc04dade3f2b95da7f62640e40d /ext/readline
parentb4e9b0d19c220965b5e3799771f31660b1262548 (diff)
* ext/readline/readline.c (readline_s_set_point, Init_readline):
add Readline.point=(pos). Patched by naruse. [ruby-dev:47535] [Feature #8675] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/readline')
-rw-r--r--ext/readline/readline.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 35facdd..f51d643 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -896,8 +896,25 @@ readline_s_get_point(VALUE self)
{
return INT2NUM(rl_point);
}
+
+/*
+ * call-seq:
+ * Readline.point = int
+ *
+ * Set the index of the current cursor position in
+ * +Readline.line_buffer+.
+ *
+ * See +Readline.point+.
+ */
+static VALUE
+readline_s_set_point(VALUE self, VALUE pos)
+{
+ rl_point = NUM2INT(pos);
+ return pos;
+}
#else
#define readline_s_get_point rb_f_notimplement
+#define readline_s_set_point rb_f_notimplement
#endif
static char **
@@ -1849,6 +1866,8 @@ Init_readline()
readline_s_get_line_buffer, 0);
rb_define_singleton_method(mReadline, "point",
readline_s_get_point, 0);
+ rb_define_singleton_method(mReadline, "point=",
+ readline_s_set_point, 1);
rb_define_singleton_method(mReadline, "set_screen_size",
readline_s_set_screen_size, 2);
rb_define_singleton_method(mReadline, "get_screen_size",