summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorkouji <kouji@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-03 12:21:08 +0000
committerkouji <kouji@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-03 12:21:08 +0000
commitd60cd5b3793bb362c09391623e365f405b750ec8 (patch)
treea0bf6693a8c28d6fe8173612f3f561fa71c9f86a /ext
parent4a2b6b2067e74a5226e9f68e4aef566d48fdbcad (diff)
* ext/readline/extconf.rb: checked rl_set_screen_size and
rl_get_screen_size. * ext/readline/readline.c (readline_s_set_screen_size): added Readline.set_screen_size. * ext/readline/readline.c (readline_s_get_screen_size): added Readline.get_screen_size. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/readline/extconf.rb2
-rw-r--r--ext/readline/readline.c60
2 files changed, 62 insertions, 0 deletions
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
index 1d74e29..6eb145f 100644
--- a/ext/readline/extconf.rb
+++ b/ext/readline/extconf.rb
@@ -63,6 +63,8 @@ have_readline_var("rl_editing_mode")
/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_event_hook")
have_readline_func("rl_cleanup_after_signal")
have_readline_func("rl_clear_signals")
+have_readline_func("rl_set_screen_size")
+have_readline_func("rl_get_screen_size")
have_readline_func("rl_vi_editing_mode")
have_readline_func("rl_emacs_editing_mode")
have_readline_func("replace_history_entry")
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 9d1a9fa..a5dbe46 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -438,6 +438,62 @@ readline_attempted_completion_function(const char *text, int start, int end)
/*
* call-seq:
+ * Readline.set_screen_size(rows, columns) -> self
+ *
+ * Set terminal size to +rows+ and +columns+.
+ *
+ * See GNU Readline's rl_set_screen_size function.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ *
+ * Raises SecurityError exception if $SAFE is 4.
+ */
+static VALUE
+readline_s_set_screen_size(VALUE self, VALUE rows, VALUE columns)
+{
+#ifdef HAVE_RL_SET_SCREEN_SIZE
+ rb_secure(4);
+ rl_set_screen_size(NUM2INT(rows), NUM2INT(columns));
+ return self;
+#else
+ rb_notimplement();
+ return Qnil; /* not reached */
+#endif /* HAVE_RL_SET_SCREEN_SIZE */
+}
+
+/*
+ * call-seq:
+ * Readline.get_screen_size -> [rows, columns]
+ *
+ * Returns the terminal's rows and columns.
+ *
+ * See GNU Readline's rl_get_screen_size function.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ *
+ * Raises SecurityError exception if $SAFE is 4.
+ */
+static VALUE
+readline_s_get_screen_size(VALUE self)
+{
+#ifdef HAVE_RL_GET_SCREEN_SIZE
+ int rows, columns;
+ VALUE res;
+
+ rb_secure(4);
+ rl_get_screen_size(&rows, &columns);
+ res = rb_ary_new();
+ rb_ary_push(res, INT2NUM(rows));
+ rb_ary_push(res, INT2NUM(columns));
+ return res;
+#else
+ rb_notimplement();
+ return Qnil; /* not reached */
+#endif /* HAVE_RL_GET_SCREEN_SIZE */
+}
+
+/*
+ * call-seq:
* Readline.vi_editing_mode -> nil
*
* Specifies VI editing mode. See the manual of GNU Readline for
@@ -1200,6 +1256,10 @@ Init_readline()
readline_s_set_completion_case_fold, 1);
rb_define_singleton_method(mReadline, "completion_case_fold",
readline_s_get_completion_case_fold, 0);
+ rb_define_singleton_method(mReadline, "set_screen_size",
+ readline_s_set_screen_size, 2);
+ rb_define_singleton_method(mReadline, "get_screen_size",
+ readline_s_get_screen_size, 0);
rb_define_singleton_method(mReadline, "vi_editing_mode",
readline_s_vi_editing_mode, 0);
rb_define_singleton_method(mReadline, "vi_editing_mode?",