mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add --autocomplete / --noautocomplete options
This commit is contained in:
parent
b6b2b767ed
commit
ece4ed0da7
9 changed files with 34 additions and 2 deletions
|
@ -59,7 +59,10 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本
|
|||
用しようとする.
|
||||
--colorize 色付けを利用する.
|
||||
--nocolorize 色付けを利用しない.
|
||||
--prompt prompt-mode/--prompt-mode prompt-mode
|
||||
--autocomplete オートコンプリートを利用する.
|
||||
--noautocomplete オートコンプリートを利用しない.
|
||||
--prompt prompt-mode
|
||||
--prompt-mode prompt-mode
|
||||
プロンプトモードを切替えます. 現在定義されているプ
|
||||
ロンプトモードは, default, simple, xmp, inf-rubyが
|
||||
用意されています.
|
||||
|
|
|
@ -72,6 +72,8 @@ require_relative "irb/easter-egg"
|
|||
# --nosingleline Don't use singleline editor module
|
||||
# --colorize Use colorization
|
||||
# --nocolorize Don't use colorization
|
||||
# --autocomplete Use autocompletion
|
||||
# --noautocomplete Don't use autocompletion
|
||||
# --prompt prompt-mode/--prompt-mode prompt-mode
|
||||
# Switch prompt mode. Pre-defined prompt modes are
|
||||
# `default', `simple', `xmp' and `inf-ruby'
|
||||
|
@ -114,6 +116,7 @@ require_relative "irb/easter-egg"
|
|||
# IRB.conf[:USE_SINGLELINE] = nil
|
||||
# IRB.conf[:USE_COLORIZE] = true
|
||||
# IRB.conf[:USE_TRACER] = false
|
||||
# IRB.conf[:USE_AUTOCOMPLETE] = true
|
||||
# IRB.conf[:IGNORE_SIGINT] = true
|
||||
# IRB.conf[:IGNORE_EOF] = false
|
||||
# IRB.conf[:PROMPT_MODE] = :DEFAULT
|
||||
|
|
|
@ -54,6 +54,7 @@ module IRB
|
|||
@use_multiline = nil
|
||||
end
|
||||
@use_colorize = IRB.conf[:USE_COLORIZE]
|
||||
@use_autocomplete = IRB.conf[:USE_AUTOCOMPLETE]
|
||||
@verbose = IRB.conf[:VERBOSE]
|
||||
@io = nil
|
||||
|
||||
|
@ -185,6 +186,8 @@ module IRB
|
|||
#
|
||||
# A copy of the default <code>IRB.conf[:USE_COLORIZE]</code>
|
||||
attr_reader :use_colorize
|
||||
# A copy of the default <code>IRB.conf[:USE_AUTOCOMPLETE]</code>
|
||||
attr_reader :use_autocomplete
|
||||
# A copy of the default <code>IRB.conf[:INSPECT_MODE]</code>
|
||||
attr_reader :inspect_mode
|
||||
|
||||
|
@ -311,6 +314,8 @@ module IRB
|
|||
alias use_readline? use_singleline
|
||||
# Alias for #use_colorize
|
||||
alias use_colorize? use_colorize
|
||||
# Alias for #use_autocomplete
|
||||
alias use_autocomplete? use_autocomplete
|
||||
# Alias for #rc
|
||||
alias rc? rc
|
||||
alias ignore_sigint? ignore_sigint
|
||||
|
|
|
@ -45,6 +45,7 @@ module IRB # :nodoc:
|
|||
|
||||
@CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
|
||||
@CONF[:USE_COLORIZE] = !ENV['NO_COLOR']
|
||||
@CONF[:USE_AUTOCOMPLETE] = true
|
||||
@CONF[:INSPECT_MODE] = true
|
||||
@CONF[:USE_TRACER] = false
|
||||
@CONF[:USE_LOADER] = false
|
||||
|
@ -274,6 +275,10 @@ module IRB # :nodoc:
|
|||
@CONF[:USE_COLORIZE] = true
|
||||
when "--nocolorize"
|
||||
@CONF[:USE_COLORIZE] = false
|
||||
when "--autocomplete"
|
||||
@CONF[:USE_AUTOCOMPLETE] = true
|
||||
when "--noautocomplete"
|
||||
@CONF[:USE_AUTOCOMPLETE] = false
|
||||
when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
|
||||
opt = $1 || argv.shift
|
||||
prompt_mode = opt.upcase.tr("-", "_").intern
|
||||
|
|
|
@ -295,6 +295,10 @@ module IRB
|
|||
end
|
||||
end
|
||||
Reline.dig_perfect_match_proc = IRB::InputCompletor::PerfectMatchedProc
|
||||
Reline.autocompletion = IRB.conf[:USE_AUTOCOMPLETE]
|
||||
if IRB.conf[:USE_AUTOCOMPLETE]
|
||||
Reline.add_dialog_proc(:show_doc, SHOW_DOC_DIALOG, Reline::DEFAULT_DIALOG_CONTEXT)
|
||||
end
|
||||
end
|
||||
|
||||
def check_termination(&block)
|
||||
|
@ -361,7 +365,6 @@ module IRB
|
|||
Reline.output = @stdout
|
||||
Reline.prompt_proc = @prompt_proc
|
||||
Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
|
||||
Reline.add_dialog_proc(:show_doc, SHOW_DOC_DIALOG, Reline::DEFAULT_DIALOG_CONTEXT)
|
||||
if l = readmultiline(@prompt, false, &@check_termination_proc)
|
||||
HISTORY.push(l) if !l.empty?
|
||||
@line[@line_no += 1] = l + "\n"
|
||||
|
|
|
@ -30,6 +30,8 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|||
--nosingleline Don't use singleline editor module
|
||||
--colorize Use colorization
|
||||
--nocolorize Don't use colorization
|
||||
--autocomplete Use autocompletion
|
||||
--noautocomplete Don't use autocompletion
|
||||
--prompt prompt-mode/--prompt-mode prompt-mode
|
||||
Switch prompt mode. Pre-defined prompt modes are
|
||||
`default', `simple', `xmp' and `inf-ruby'
|
||||
|
|
|
@ -29,6 +29,8 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|||
--nosingleline シングルラインエディタを利用しない.
|
||||
--colorize 色付けを利用する.
|
||||
--nocolorize 色付けを利用しない.
|
||||
--autocomplete オートコンプリートを利用する.
|
||||
--noautocomplete オートコンプリートを利用しない.
|
||||
--prompt prompt-mode/--prompt-mode prompt-mode
|
||||
プロンプトモードを切替えます. 現在定義されているプ
|
||||
ロンプトモードは, default, simple, xmp, inf-rubyが
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
.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 autocomplete
|
||||
.Op Fl - Ns Oo no Oc Ns verbose
|
||||
.Op Fl -prompt Ar mode
|
||||
.Op Fl -prompt-mode Ar mode
|
||||
|
@ -118,6 +119,13 @@ Use colorization.
|
|||
Don't use colorization.
|
||||
.Pp
|
||||
.Pp
|
||||
.It Fl -autocomplete
|
||||
Use autocompletion.
|
||||
.Pp
|
||||
.It Fl -noautocomplete
|
||||
Don't use autocompletion.
|
||||
.Pp
|
||||
.Pp
|
||||
.It Fl -verbose
|
||||
Show details.
|
||||
.Pp
|
||||
|
|
|
@ -159,6 +159,7 @@ module TestIRB
|
|||
|
||||
def test_default_config
|
||||
assert_equal(true, @context.use_colorize?)
|
||||
assert_equal(true, @context.use_autocomplete?)
|
||||
end
|
||||
|
||||
def test_assignment_expression
|
||||
|
|
Loading…
Reference in a new issue