From 91bf3b7a77e187794cc84549f330e5675fb5d367 Mon Sep 17 00:00:00 2001 From: aycabta Date: Wed, 30 Oct 2019 09:32:16 +0900 Subject: Use singleline/multiline instead of readline/reidline --- doc/irb/irb.rd.ja | 34 +++++++++++++++--------- lib/irb.rb | 18 ++++++------- lib/irb/context.rb | 65 +++++++++++++++++++++++++--------------------- lib/irb/init.rb | 18 ++++++------- lib/irb/lc/help-message | 12 +++++---- lib/irb/lc/ja/help-message | 9 ++++--- man/irb.1 | 19 +++++++++----- test/irb/test_context.rb | 2 +- 8 files changed, 102 insertions(+), 75 deletions(-) diff --git a/doc/irb/irb.rd.ja b/doc/irb/irb.rd.ja index 31b7cdf3e3..81247ce4b0 100644 --- a/doc/irb/irb.rd.ja +++ b/doc/irb/irb.rd.ja @@ -53,8 +53,10 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本 --noecho 実行結果を表示しない. --inspect 結果出力にinspectを用いる. --noinspect 結果出力にinspectを用いない. - --readline readlineライブラリを利用する. - --noreadline readlineライブラリを利用しない. + --singleline シングルラインエディタを利用する. + --nosingleline シングルラインエディタを利用しない. デフォルトの動 + 作は, inf-ruby-mode以外でシングルラインエディタを利 + 用しようとする. --colorize 色付けを利用する. --nocolorize 色付けを利用しない. --prompt prompt-mode/--prompt-mode prompt-mode @@ -62,8 +64,8 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本 ロンプトモードは, default, simple, xmp, inf-rubyが 用意されています. --inf-ruby-mode emacsのinf-ruby-mode用のプロンプト表示を行なう. 特 - に指定がない限り, readlineライブラリは使わなくなる. - --sample-book-mode/--simple-prompt + に指定がない限り, ラインエディタは使わなくなる. + --simple-prompt 非常にシンプルなプロンプトを用いるモードです. --noprompt プロンプト表示を行なわない. --single-irb irb 中で self を実行して得られるオブジェクトをサ @@ -96,7 +98,7 @@ irb起動時に``~/.irbrc''を読み込みます. もし存在しない場合は IRB.conf[:IRB_RC] = nil IRB.conf[:BACK_TRACE_LIMIT]=16 IRB.conf[:USE_LOADER] = false - IRB.conf[:USE_READLINE] = nil + IRB.conf[:USE_SINGLELINE] = nil IRB.conf[:USE_TRACER] = false IRB.conf[:IGNORE_SIGINT] = true IRB.conf[:IGNORE_EOF] = false @@ -198,7 +200,8 @@ irb拡張コマンドは, 簡単な名前と頭に`irb_'をつけた名前と両 実行中: 実行を中止する. --- conf.inf_ruby_mode = true/false - inf-ruby-mode用のプロンプト表示を行なう. デフォルトはfalse. + inf-ruby-mode用のプロンプト表示を行なう. デフォルトはfalse. 特に指定 + がない限り, ラインエディタは使わなくなる. --- conf.inspect_mode = true/false/nil インスペクトモードを設定する. @@ -226,12 +229,19 @@ irb拡張コマンドは, 簡単な名前と頭に`irb_'をつけた名前と両 --- conf.use_prompt = true/false プロンプト表示するかどうか? デフォルトではプロンプトを表示する. ---- conf.use_readline = true/false/nil - readlineを使うかどうか? - true: readlineを使う. - false: readlineを使わない. - nil: (デフォルト)inf-ruby-mode以外でreadlineライブラリを利用しよ - うとする. +--- conf.use_multiline = true/false/nil + マルチラインエディタを使うかどうか? + true: マルチラインエディタを使う. + false: マルチラインエディタを使わない. + nil: (デフォルト)inf-ruby-mode以外でマルチラインエディタを利用しよう + とする. + +--- conf.use_singleline = true/false/nil + シングルラインエディタを使うかどうか? + true: シングルラインエディタを使う. + false: シングルラインエディタを使わない. + nil: (デフォルト)inf-ruby-modeとマルチラインエディタ以外でシングルラ + インエディタを利用しようとする. # #--- conf.verbose=T/F # irbからいろいろなメッセージを出力するか? diff --git a/lib/irb.rb b/lib/irb.rb index 2bf46aa227..ed91d29b91 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -45,8 +45,8 @@ require "irb/version" # irb(main):006:1> end # #=> nil # -# The Readline extension module can be used with irb. Use of Readline is -# default if it's installed. +# The singleline editor module or multiline editor module can be used with irb. +# Use of multiline editor is default if it's installed. # # == Command line options # @@ -61,10 +61,10 @@ require "irb/version" # -W[level=2] Same as `ruby -W` # --inspect Use `inspect' for output (default except for bc mode) # --noinspect Don't use inspect for output -# --reidline Use Reidline extension module -# --noreidline Don't use Reidline extension module -# --readline Use Readline extension module -# --noreadline Don't use Readline extension module +# --multiline Use multiline editor module +# --nomultiline Don't use multiline editor module +# --singleline Use singleline editor module +# --nosingleline Don't use singleline editor module # --colorize Use colorization # --nocolorize Don't use colorization # --prompt prompt-mode @@ -72,7 +72,7 @@ require "irb/version" # Switch prompt mode. Pre-defined prompt modes are # `default', `simple', `xmp' and `inf-ruby' # --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs. -# Suppresses --reidline and --readline. +# Suppresses --multiline and --singleline. # --simple-prompt Simple prompt mode # --noprompt No prompt mode # --tracer Display trace for each execution of commands. @@ -100,8 +100,8 @@ require "irb/version" # IRB.conf[:IRB_RC] = nil # IRB.conf[:BACK_TRACE_LIMIT]=16 # IRB.conf[:USE_LOADER] = false -# IRB.conf[:USE_REIDLINE] = nil -# IRB.conf[:USE_READLINE] = nil +# IRB.conf[:USE_MULTILINE] = nil +# IRB.conf[:USE_SINGLELINE] = nil # IRB.conf[:USE_COLORIZE] = true # IRB.conf[:USE_TRACER] = false # IRB.conf[:IGNORE_SIGINT] = true diff --git a/lib/irb/context.rb b/lib/irb/context.rb index a8344f08fb..f529787bae 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -39,8 +39,20 @@ module IRB @rc = IRB.conf[:RC] @load_modules = IRB.conf[:LOAD_MODULES] - @use_readline = IRB.conf[:USE_READLINE] - @use_reidline = IRB.conf[:USE_REIDLINE] + if IRB.conf.has_key?(:USE_SINGLELINE) + @use_singleline = IRB.conf[:USE_SINGLELINE] + elsif IRB.conf.has_key?(:USE_READLINE) # backward compatibility + @use_singleline = IRB.conf[:USE_READLINE] + else + @use_singleline = nil + end + if IRB.conf.has_key?(:USE_MULTILINE) + @use_multiline = IRB.conf[:USE_MULTILINE] + elsif IRB.conf.has_key?(:USE_REIDLINE) # backward compatibility + @use_multiline = IRB.conf[:USE_REIDLINE] + else + @use_multiline = nil + end @use_colorize = IRB.conf[:USE_COLORIZE] @verbose = IRB.conf[:VERBOSE] @io = nil @@ -67,9 +79,9 @@ module IRB case input_method when nil @io = nil - case use_reidline? + case use_multiline? when nil - if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_readline? + if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline? @io = ReidlineInputMethod.new else @io = nil @@ -80,7 +92,7 @@ module IRB @io = ReidlineInputMethod.new end unless @io - case use_readline? + case use_singleline? when nil if (defined?(ReadlineInputMethod) && STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY) @@ -155,18 +167,14 @@ module IRB # +input_method+ passed to Context.new attr_accessor :irb_path - # Whether +Reidline+ is enabled or not. - # - # A copy of the default IRB.conf[:USE_REIDLINE] - # - # See #use_reidline= for more information. - attr_reader :use_reidline - # Whether +Readline+ is enabled or not. + # Whether multiline editor mode is enabled or not. # - # A copy of the default IRB.conf[:USE_READLINE] + # A copy of the default IRB.conf[:USE_MULTILINE] + attr_reader :use_multiline + # Whether singleline editor mode is enabled or not. # - # See #use_readline= for more information. - attr_reader :use_readline + # A copy of the default IRB.conf[:USE_SINGLELINE] + attr_reader :use_singleline # Whether colorization is enabled or not. # # A copy of the default IRB.conf[:USE_COLORIZE] @@ -258,10 +266,18 @@ module IRB # See IRB@Command+line+options for more command line options. attr_accessor :back_trace_limit - # Alias for #use_reidline - alias use_reidline? use_reidline - # Alias for #use_readline - alias use_readline? use_readline + # Alias for #use_multiline + alias use_multiline? use_multiline + # Alias for #use_singleline + alias use_singleline? use_singleline + # backward compatibility + alias use_reidline use_multiline + # backward compatibility + alias use_reidline? use_multiline + # backward compatibility + alias use_readline use_singleline + # backward compatibility + alias use_readline? use_singleline # Alias for #use_colorize alias use_colorize? use_colorize # Alias for #rc @@ -392,17 +408,6 @@ module IRB @inspect_mode end - # Obsolete method. - # - # Can be set using the +--noreadline+ and +--readline+ command line - # options. - # - # See IRB@Command+line+options for more command line options. - def use_readline=(opt) - print "This method is obsolete." - print "Do nothing." - end - def evaluate(line, line_no, exception: nil) # :nodoc: @line_no = line_no if exception diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 00357468c9..11f3932be2 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -43,7 +43,7 @@ module IRB # :nodoc: @CONF[:LOAD_MODULES] = [] @CONF[:IRB_RC] = nil - @CONF[:USE_READLINE] = false unless defined?(ReadlineInputMethod) + @CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod) @CONF[:USE_COLORIZE] = true @CONF[:INSPECT_MODE] = true @CONF[:USE_TRACER] = false @@ -161,14 +161,14 @@ module IRB # :nodoc: end when "--noinspect" @CONF[:INSPECT_MODE] = false - when "--readline" - @CONF[:USE_READLINE] = true - when "--noreadline" - @CONF[:USE_READLINE] = false - when "--reidline" - @CONF[:USE_REIDLINE] = true - when "--noreidline" - @CONF[:USE_REIDLINE] = false + when "--singleline", "--readline" + @CONF[:USE_SINGLELINE] = true + when "--nosingleline", "--noreadline" + @CONF[:USE_SINGLELINE] = false + when "--multiline", "--reidline" + @CONF[:USE_MULTILINE] = true + when "--nomultiline", "--noreidline" + @CONF[:USE_MULTILINE] = false when "--echo" @CONF[:ECHO] = true when "--noecho" diff --git a/lib/irb/lc/help-message b/lib/irb/lc/help-message index 57f099e005..a80facc9c5 100644 --- a/lib/irb/lc/help-message +++ b/lib/irb/lc/help-message @@ -22,17 +22,19 @@ Usage: irb.rb [options] [programfile] [arguments] when new workspace was created --echo Show result(default) --noecho Don't show result - --inspect Use `inspect' for output - --noinspect Don't use inspect for output - --readline Use Readline extension module - --noreadline Don't use Readline extension module + --inspect Use `inspect' for output + --noinspect Don't use inspect for output + --multiline Use multiline editor module + --nomultiline Don't use multiline editor module + --singleline Use singleline editor module + --nosingleline Don't use singleline editor module --colorize Use colorization --nocolorize Don't use colorization --prompt prompt-mode/--prompt-mode prompt-mode Switch prompt mode. Pre-defined prompt modes are `default', `simple', `xmp' and `inf-ruby' --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs. - Suppresses --readline. + Suppresses --multiline and --singleline. --sample-book-mode/--simple-prompt Simple prompt mode --noprompt No prompt mode diff --git a/lib/irb/lc/ja/help-message b/lib/irb/lc/ja/help-message index 2bb7c2adee..9794a8e24e 100644 --- a/lib/irb/lc/ja/help-message +++ b/lib/irb/lc/ja/help-message @@ -23,8 +23,10 @@ Usage: irb.rb [options] [programfile] [arguments] --noecho 実行結果を表示しない. --inspect 結果出力にinspectを用いる. --noinspect 結果出力にinspectを用いない. - --readline readlineライブラリを利用する. - --noreadline readlineライブラリを利用しない. + --multiline マルチラインエディタを利用する. + --nomultiline マルチラインエディタを利用しない. + --singleline シングルラインエディタを利用する. + --nosingleline シングルラインエディタを利用しない. --colorize 色付けを利用する. --nocolorize 色付けを利用しない. --prompt prompt-mode/--prompt-mode prompt-mode @@ -32,7 +34,8 @@ Usage: irb.rb [options] [programfile] [arguments] ロンプトモードは, default, simple, xmp, inf-rubyが 用意されています. --inf-ruby-mode emacsのinf-ruby-mode用のプロンプト表示を行なう. 特 - に指定がない限り, readlineライブラリは使わなくなる. + に指定がない限り, シングルラインエディタとマルチラ + インエディタは使わなくなる. --sample-book-mode/--simple-prompt 非常にシンプルなプロンプトを用いるモードです. --noprompt プロンプト表示を行なわない. diff --git a/man/irb.1 b/man/irb.1 index 60992afc25..f0a720fbd3 100644 --- a/man/irb.1 +++ b/man/irb.1 @@ -14,7 +14,8 @@ .Op Fl E Ar external Ns Op : Ns Ar internal .Op Fl W Ns Op Ar level .Op Fl - Ns Oo no Oc Ns inspect -.Op Fl - Ns Oo no Oc Ns readline +.Op Fl - Ns Oo no Oc Ns multiline +.Op Fl - Ns Oo no Oc Ns singleline .Op Fl - Ns Oo no Oc Ns echo .Op Fl - Ns Oo no Oc Ns colorize .Op Fl - Ns Oo no Oc Ns verbose @@ -90,11 +91,17 @@ Uses `inspect' for output (default except for bc mode) .It Fl -noinspect Doesn't use inspect for output .Pp -.It Fl -readline -Uses Readline extension module. +.It Fl -multiline +Uses multiline editor module. .Pp -.It Fl -noreadline -Doesn't use Readline extension module. +.It Fl -nomultiline +Doesn't use multiline editor module. +.Pp +.It Fl -singleline +Uses singleline editor module. +.Pp +.It Fl -nosingleline +Doesn't use singleline editor module. .Pp .Pp .It Fl -echo @@ -124,7 +131,7 @@ Switch prompt mode. Pre-defined prompt modes are .Pp .It Fl -inf-ruby-mode Uses prompt appropriate for inf-ruby-mode on emacs. -Suppresses --readline. +Suppresses --multiline and --singleline. .Pp .It Fl -simple-prompt Makes prompts simple. diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 075db35d2b..693ebbeaea 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -34,7 +34,7 @@ module TestIRB def setup IRB.init_config(nil) - IRB.conf[:USE_READLINE] = false + IRB.conf[:USE_SINGLELINE] = false IRB.conf[:VERBOSE] = false workspace = IRB::WorkSpace.new(Object.new) @context = IRB::Context.new(nil, workspace, TestInputMethod.new) -- cgit v1.2.1