diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-07-05 15:54:00 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-07-05 15:54:00 +0000 |
commit | f985b689ca330d73afbd5efa214aae28606b3635 (patch) | |
tree | 46a75ae7aac03b894a6f64c8e14e69c58ef39e47 /ext | |
parent | 003e46239361caade57885e36311ee4d24c4cf78 (diff) |
* ext/readline/readline.c (readline_event): merge from 1.7: a
non-void function should return a value.
* ext/readline/readline.c: merge from 1.7: add new methods:
Readline::completion_append_character and
Readline::completion_append_character=.
* ext/readline/README, ext/readline/README.jp: merge from 1.7: add
an English version of the document.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/readline/README | 57 | ||||
-rw-r--r-- | ext/readline/readline.c | 35 |
2 files changed, 67 insertions, 25 deletions
diff --git a/ext/readline/README b/ext/readline/README index 8a5fe9120f..9bbf325c99 100644 --- a/ext/readline/README +++ b/ext/readline/README @@ -1,55 +1,62 @@ -GNU Readline Libraryを利用するための拡張モジュールです。 +Extension for GNU Readline Library -require "readline" -include Readline +Example: -line = readline("Prompt> ", TRUE) + require "readline" + include Readline -のように使用してください。 + line = readline("Prompt> ", true) [Readline] -<モジュール関数> +<module function> -readline(prompt, add=nil) +readline(prompt, add_history=nil) - 一行入力を読み込みます。 - addがTRUEの場合、ヒストリに読み込んだ文字列を追加します。 + Reads one line with line editing. The inputted line is added to the + history if add_history is true. -<クラスメソッド> +<class methods> completion_proc = proc - 補完時の動作を決定するProcオブジェクトを指定します。 - procは引数に入力文字列を取り、候補文字列の配列を返すように - してください。 + Specifies a Proc object to determine completion behavior. It + should take input-string, and return an array of completion + candidates. completion_proc - 補完時の動作を決定するProcオブジェクトを返します。 + Returns the completion Proc object. -completion_case_fold = case_fold +completion_case_fold = bool - 補完時に大文字小文字を区別しない場合、TRUEを指定します。 + Sets whether or not to ignore case on completion. completion_case_fold - 補完時に大文字小文字を区別しない場合、TRUEを返します。 + Returns true if completion ignores case. + +completion_append_character = char + + Specifies a character to be appended on completion. + Nothing will be appended if an empty string ("") or nil is + specified. + +completion_append_character + + Returns a string containing a character to be appended on + completion. The default is a space (" "). vi_editing_mode - VIモードになります。 + Specifies VI editing mode. emacs_editing_mode - Emacsモードになります。 + Specifies Emacs editing mode. -<クラス定数> +<class constants> HISTORY -ヒストリに対する操作はこの定数を通して行ってください。 -配列と同じように扱えるようになっています。 - - -
\ No newline at end of file +The history buffer. It behaves just like an array. diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 876207c224..49e3c04fed 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -26,6 +26,7 @@ readline_event() { CHECK_INTS; rb_thread_schedule(); + return 0; } static VALUE @@ -167,6 +168,36 @@ readline_s_emacs_editing_mode(self) } static VALUE +readline_s_set_completion_append_character(self, str) + VALUE self, str; +{ + if (NIL_P(str)) { + rl_completion_append_character = '\0'; + } else { + Check_Type(str, T_STRING); + + rl_completion_append_character = RSTRING(str)->ptr[0]; + } + + return self; +} + +static VALUE +readline_s_get_completion_append_character(self) + VALUE self; +{ + VALUE str; + + if (rl_completion_append_character == '\0') + return Qnil; + + str = rb_str_new("", 1); + RSTRING(str)->ptr[0] = rl_completion_append_character; + + return str; +} + +static VALUE hist_to_s(self) VALUE self; { @@ -394,6 +425,10 @@ Init_readline() readline_s_vi_editing_mode, 0); rb_define_singleton_method(mReadline, "emacs_editing_mode", readline_s_emacs_editing_mode, 0); + rb_define_singleton_method(mReadline, "completion_append_character=", + readline_s_set_completion_append_character, 1); + rb_define_singleton_method(mReadline, "completion_append_character", + readline_s_get_completion_append_character, 0); histary = rb_obj_alloc(rb_cObject); rb_extend_object(histary, rb_mEnumerable); |