* ext/readline/README.ja: added API document for

Readline.vi_editing_mode? and Readline.emacs_editing_mode?.

* ext/readline/extconf.rb: checked rl_editing_mode variable in
  Readline library.

* ext/readline/readline.c (readline_s_emacs_editing_mode_p): added
  Readline.emacs_editing_mode? method.
  (readline_s_vi_editing_mode_p): added Readline.vi_editing_mode?
  method.
  (Init_readline): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kouji 2008-08-11 08:31:45 +00:00
Родитель e956f28724
Коммит aa2a222f9c
5 изменённых файлов: 105 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,17 @@
Mon Aug 11 17:26:16 2008 TAKAO Kouji <kouji@takao7.net>
* ext/readline/README.ja: added API document for
Readline.vi_editing_mode? and Readline.emacs_editing_mode?.
* ext/readline/extconf.rb: checked rl_editing_mode variable in
Readline library.
* ext/readline/readline.c (readline_s_emacs_editing_mode_p): added
Readline.emacs_editing_mode? method.
(readline_s_vi_editing_mode_p): added Readline.vi_editing_mode?
method.
(Init_readline): ditto.
Mon Aug 11 16:56:40 2008 TAKAO Kouji <kouji@takao7.net>
* test/readline/test_readline.rb: added test for Readline's class

Просмотреть файл

@ -186,6 +186,15 @@ Readline.vi_editing_mode -> nil
$SAFE が 4 の場合、例外 SecurityError が発生します。
Readline.vi_editing_mode? -> bool
編集モードが vi モードの場合、true を返します。そうでなければ false
を返します。
サポートしていない環境では、例外 NotImplementedError が発生します。
$SAFE が 4 の場合、例外 SecurityError が発生します。
Readline.emacs_editing_mode -> nil
編集モードを Emacs モードにします。
@ -196,6 +205,15 @@ Readline.emacs_editing_mode -> nil
$SAFE が 4 の場合、例外 SecurityError が発生します。
Readline.emacs_editing_mode? -> bool
編集モードが Emacs モードの場合、true を返します。そうでなければ false
を返します。
サポートしていない環境では、例外 NotImplementedError が発生します。
$SAFE が 4 の場合、例外 SecurityError が発生します。
Readline.completion_append_character = char
ユーザの入力の補完が完了した場合に、最後に付加する文字 char を指定し

Просмотреть файл

@ -58,6 +58,7 @@ have_readline_var("rl_completer_quote_characters")
have_readline_var("rl_filename_quote_characters")
have_readline_var("rl_attempted_completion_over")
have_readline_var("rl_library_version")
have_readline_var("rl_editing_mode")
# workaround for native windows.
/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_event_hook")
have_readline_func("rl_cleanup_after_signal")

Просмотреть файл

@ -455,6 +455,28 @@ readline_s_vi_editing_mode(VALUE self)
#endif /* HAVE_RL_VI_EDITING_MODE */
}
/*
* call-seq:
* Readline.vi_editing_mode? -> bool
*
* Returns true if vi mode is active. Returns false if not.
*
* Raises NotImplementedError if the using readline library does not support.
*
* Raises SecurityError exception if $SAFE is 4.
*/
static VALUE
readline_s_vi_editing_mode_p(VALUE self)
{
#ifdef HAVE_RL_EDITING_MODE
rb_secure(4);
return rl_editing_mode == 0 ? Qtrue : Qfalse;
#else
rb_notimplement();
return Qnil; /* not reached */
#endif /* HAVE_RL_EDITING_MODE */
}
/*
* call-seq:
* Readline.emacs_editing_mode -> nil
@ -479,6 +501,28 @@ readline_s_emacs_editing_mode(VALUE self)
#endif /* HAVE_RL_EMACS_EDITING_MODE */
}
/*
* call-seq:
* Readline.emacs_editing_mode? -> bool
*
* Returns true if emacs mode is active. Returns false if not.
*
* Raises NotImplementedError if the using readline library does not support.
*
* Raises SecurityError exception if $SAFE is 4.
*/
static VALUE
readline_s_emacs_editing_mode_p(VALUE self)
{
#ifdef HAVE_RL_EDITING_MODE
rb_secure(4);
return rl_editing_mode == 1 ? Qtrue : Qfalse;
#else
rb_notimplement();
return Qnil; /* not reached */
#endif /* HAVE_RL_EDITING_MODE */
}
/*
* call-seq:
* Readline.completion_append_character = char
@ -1154,8 +1198,12 @@ Init_readline()
readline_s_get_completion_case_fold, 0);
rb_define_singleton_method(mReadline, "vi_editing_mode",
readline_s_vi_editing_mode, 0);
rb_define_singleton_method(mReadline, "vi_editing_mode?",
readline_s_vi_editing_mode_p, 0);
rb_define_singleton_method(mReadline, "emacs_editing_mode",
readline_s_emacs_editing_mode, 0);
rb_define_singleton_method(mReadline, "emacs_editing_mode?",
readline_s_emacs_editing_mode_p, 0);
rb_define_singleton_method(mReadline, "completion_append_character=",
readline_s_set_completion_append_character, 1);
rb_define_singleton_method(mReadline, "completion_append_character",

Просмотреть файл

@ -138,6 +138,30 @@ class TestReadline < Test::Unit::TestCase
end
end
# vi_editing_mode
# emacs_editing_mode
def test_editing_mode
begin
assert_equal(false, Readline.vi_editing_mode?)
assert_equal(true, Readline.emacs_editing_mode?)
assert_equal(nil, Readline.vi_editing_mode)
assert_equal(true, Readline.vi_editing_mode?)
assert_equal(false, Readline.emacs_editing_mode?)
assert_equal(nil, Readline.vi_editing_mode)
assert_equal(true, Readline.vi_editing_mode?)
assert_equal(false, Readline.emacs_editing_mode?)
assert_equal(nil, Readline.emacs_editing_mode)
assert_equal(false, Readline.vi_editing_mode?)
assert_equal(true, Readline.emacs_editing_mode?)
assert_equal(nil, Readline.emacs_editing_mode)
assert_equal(false, Readline.vi_editing_mode?)
assert_equal(true, Readline.emacs_editing_mode?)
rescue NotImplementedError
end
end
def test_completion_append_character
begin
Readline.completion_append_character = "x"