From 257c314fbb34230aea4528fbc1276304f6c7575c Mon Sep 17 00:00:00 2001 From: kouji Date: Fri, 10 Jul 2009 13:03:40 +0000 Subject: [PATCH] * ext/readline/extconf.rb: checked rl_refresh_line in readline. * ext/readline/readline.c (readline_s_refresh_line): add new method, a patch from Koichiro Ohba. see [ruby-list:45922]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/readline/extconf.rb | 1 + ext/readline/readline.c | 22 ++++++++++++++++++++++ test/readline/test_readline.rb | 1 + 4 files changed, 31 insertions(+) diff --git a/ChangeLog b/ChangeLog index a16e08a748..45df64670c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Jul 10 21:45:30 2009 TAKAO Kouji + + * ext/readline/extconf.rb: checked rl_refresh_line in readline. + + * ext/readline/readline.c (readline_s_refresh_line): add new + method, a patch from Koichiro Ohba. see [ruby-list:45922]. + Fri Jul 10 21:00:05 2009 TAKAO Kouji * ext/readline/extconf.rb: checked rl_line_buffer and rl_point in diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb index d3ccca697a..512e28f627 100644 --- a/ext/readline/extconf.rb +++ b/ext/readline/extconf.rb @@ -50,6 +50,7 @@ have_readline_func("rl_getc_function") have_readline_func("rl_filename_completion_function") have_readline_func("rl_username_completion_function") have_readline_func("rl_completion_matches") +have_readline_func("rl_refresh_line") have_readline_var("rl_deprep_term_function") have_readline_var("rl_completion_append_character") have_readline_var("rl_basic_word_break_characters") diff --git a/ext/readline/readline.c b/ext/readline/readline.c index d54a280fcd..7a7fb30dc7 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -1043,6 +1043,26 @@ readline_s_get_filename_quote_characters(VALUE self, VALUE str) #define readline_s_get_filename_quote_characters rb_f_notimplement #endif +#ifdef HAVE_RL_REFRESH_LINE +/* + * call-seq: + * Readline.refresh_line -> nil + * + * Clear the current input line. + * + * Raises SecurityError exception if $SAFE is 4. + */ +static VALUE +readline_s_refresh_line(self) +{ + rb_secure(4); + rl_refresh_line(0, 0); + return Qnil; +} +#else +#define readline_s_refresh_line rb_f_notimplement +#endif + static VALUE hist_to_s(VALUE self) { @@ -1350,6 +1370,8 @@ Init_readline() readline_s_set_filename_quote_characters, 1); rb_define_singleton_method(mReadline, "filename_quote_characters", readline_s_get_filename_quote_characters, 0); + rb_define_singleton_method(mReadline, "refresh_line", + readline_s_refresh_line, 0); history = rb_obj_alloc(rb_cObject); rb_extend_object(history, rb_mEnumerable); diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb index 259f7ddd6d..5871f4c2bb 100644 --- a/test/readline/test_readline.rb +++ b/test/readline/test_readline.rb @@ -21,6 +21,7 @@ begin "completer_quote_characters", "filename_quote_characters=", "filename_quote_characters", + "refresh_line", ].each do |method_name| define_method(method_name.to_sym) do |*args| raise NotImplementedError