irb 1.0.0 → 1.1.0.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 423daf218fc081796e0be9093dea7df2340782475a57d97cc279f55482d5ba09
4
- data.tar.gz: c2990b036ee5b6f1cab514e11be623d67eed699729e361bea46b2722bd0eea8b
3
+ metadata.gz: f66136bc4e18da53d6d29f7b04244c16f4e195012723da1a35de758683092667
4
+ data.tar.gz: be8a4c66b1823e4ac852c08a6299523edc6921b5a4ae9313a025d98105ee99e3
5
5
  SHA512:
6
- metadata.gz: 190785277de97de1faef3c9aa599ad15c456c20da76eed4559a8e32f4c49aaf957884b083677ce5fc31c9974353f3f3dbc4a4a3aef29f36a703b16929656600d
7
- data.tar.gz: b79eb0f94a33aa34afc6ebf7124e9e72ae4cad283063d369ab7ca7e3b86adb88248d1fc3e0dd3df7f6584c6222e93baf09a0d776a686772ab99508b5d5706b05
6
+ metadata.gz: 643216ead68eb3cf7e0b01164067c6f9ab41ad2f849a490e8f4eafbdbf97b4df4e2795cd87c30ae294cf6a9c6aa137fcce71e41700c8f4a0aa40fb47d9f5a779
7
+ data.tar.gz: a069be08937a2fc54a31ea7c0ae4447027850b05b03a0f3a47e3ec2689099229666c33a83b593c1c8b0fe7b190dd90598fa22d9f367d5444dbae0cee57ac8365
data/irb.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.homepage = "https://github.com/ruby/irb"
17
17
  spec.license = "BSD-2-Clause"
18
18
 
19
- spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "exe/irb", "irb.gemspec", "lib/irb.rb", "lib/irb/cmd/chws.rb", "lib/irb/cmd/fork.rb", "lib/irb/cmd/help.rb", "lib/irb/cmd/load.rb", "lib/irb/cmd/nop.rb", "lib/irb/cmd/pushws.rb", "lib/irb/cmd/subirb.rb", "lib/irb/completion.rb", "lib/irb/context.rb", "lib/irb/ext/change-ws.rb", "lib/irb/ext/history.rb", "lib/irb/ext/loader.rb", "lib/irb/ext/multi-irb.rb", "lib/irb/ext/save-history.rb", "lib/irb/ext/tracer.rb", "lib/irb/ext/use-loader.rb", "lib/irb/ext/workspaces.rb", "lib/irb/extend-command.rb", "lib/irb/frame.rb", "lib/irb/help.rb", "lib/irb/init.rb", "lib/irb/input-method.rb", "lib/irb/inspector.rb", "lib/irb/lc/.document", "lib/irb/lc/error.rb", "lib/irb/lc/help-message", "lib/irb/lc/ja/encoding_aliases.rb", "lib/irb/lc/ja/error.rb", "lib/irb/lc/ja/help-message", "lib/irb/locale.rb", "lib/irb/magic-file.rb", "lib/irb/notifier.rb", "lib/irb/output-method.rb", "lib/irb/ruby-lex.rb", "lib/irb/ruby-token.rb", "lib/irb/slex.rb", "lib/irb/src_encoding.rb", "lib/irb/version.rb", "lib/irb/workspace.rb", "lib/irb/ws-for-case-2.rb", "lib/irb/xmp.rb"]
19
+ spec.files = ["LICENSE.txt", "README.md", "exe/irb", "irb.gemspec", "lib/irb.rb", "lib/irb/cmd/chws.rb", "lib/irb/cmd/fork.rb", "lib/irb/cmd/help.rb", "lib/irb/cmd/load.rb", "lib/irb/cmd/nop.rb", "lib/irb/cmd/pushws.rb", "lib/irb/cmd/subirb.rb", "lib/irb/completion.rb", "lib/irb/context.rb", "lib/irb/ext/change-ws.rb", "lib/irb/ext/history.rb", "lib/irb/ext/loader.rb", "lib/irb/ext/multi-irb.rb", "lib/irb/ext/save-history.rb", "lib/irb/ext/tracer.rb", "lib/irb/ext/use-loader.rb", "lib/irb/ext/workspaces.rb", "lib/irb/extend-command.rb", "lib/irb/frame.rb", "lib/irb/help.rb", "lib/irb/init.rb", "lib/irb/input-method.rb", "lib/irb/inspector.rb", "lib/irb/lc/.document", "lib/irb/lc/error.rb", "lib/irb/lc/help-message", "lib/irb/lc/ja/encoding_aliases.rb", "lib/irb/lc/ja/error.rb", "lib/irb/lc/ja/help-message", "lib/irb/locale.rb", "lib/irb/magic-file.rb", "lib/irb/notifier.rb", "lib/irb/output-method.rb", "lib/irb/ruby-lex.rb", "lib/irb/ruby-token.rb", "lib/irb/slex.rb", "lib/irb/src_encoding.rb", "lib/irb/version.rb", "lib/irb/workspace.rb", "lib/irb/ws-for-case-2.rb", "lib/irb/xmp.rb"]
20
20
  spec.bindir = "exe"
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
data/lib/irb.rb CHANGED
@@ -18,6 +18,7 @@ require "irb/extend-command"
18
18
  require "irb/ruby-lex"
19
19
  require "irb/input-method"
20
20
  require "irb/locale"
21
+ require "irb/color"
21
22
 
22
23
  require "irb/version"
23
24
 
@@ -59,21 +60,24 @@ require "irb/version"
59
60
  # -W[level=2] Same as `ruby -W`
60
61
  # --inspect Use `inspect' for output (default except for bc mode)
61
62
  # --noinspect Don't use inspect for output
63
+ # --reidline Use Reidline extension module
64
+ # --noreidline Don't use Reidline extension module
62
65
  # --readline Use Readline extension module
63
66
  # --noreadline Don't use Readline extension module
67
+ # --colorize Use colorization
68
+ # --nocolorize Don't use colorization
64
69
  # --prompt prompt-mode
65
70
  # --prompt-mode prompt-mode
66
71
  # Switch prompt mode. Pre-defined prompt modes are
67
72
  # `default', `simple', `xmp' and `inf-ruby'
68
73
  # --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
69
- # Suppresses --readline.
74
+ # Suppresses --reidline and --readline.
70
75
  # --simple-prompt Simple prompt mode
71
76
  # --noprompt No prompt mode
72
77
  # --tracer Display trace for each execution of commands.
73
78
  # --back-trace-limit n
74
79
  # Display backtrace top n and tail n. The default
75
80
  # value is 16.
76
- # --irb_debug n Set internal debug level to n (not for popular use)
77
81
  # -v, --version Print the version of irb
78
82
  #
79
83
  # == Configuration
@@ -95,13 +99,14 @@ require "irb/version"
95
99
  # IRB.conf[:IRB_RC] = nil
96
100
  # IRB.conf[:BACK_TRACE_LIMIT]=16
97
101
  # IRB.conf[:USE_LOADER] = false
102
+ # IRB.conf[:USE_REIDLINE] = nil
98
103
  # IRB.conf[:USE_READLINE] = nil
104
+ # IRB.conf[:USE_COLORIZE] = true
99
105
  # IRB.conf[:USE_TRACER] = false
100
106
  # IRB.conf[:IGNORE_SIGINT] = true
101
107
  # IRB.conf[:IGNORE_EOF] = false
102
108
  # IRB.conf[:PROMPT_MODE] = :DEFAULT
103
109
  # IRB.conf[:PROMPT] = {...}
104
- # IRB.conf[:DEBUG_LEVEL]=0
105
110
  #
106
111
  # === Auto indentation
107
112
  #
@@ -410,9 +415,7 @@ module IRB
410
415
  @context = Context.new(self, workspace, input_method, output_method)
411
416
  @context.main.extend ExtendCommandBundle
412
417
  @signal_status = :IN_IRB
413
-
414
418
  @scanner = RubyLex.new
415
- @scanner.exception_on_syntax_error = false
416
419
  end
417
420
 
418
421
  def run(conf = IRB.conf)
@@ -749,8 +752,8 @@ class Binding
749
752
  #
750
753
  # Potato.new
751
754
  #
752
- # Running +ruby potato.rb+ will open an IRB session where +binding.irb+ is
753
- # called, and you will see the following:
755
+ # Running <code>ruby potato.rb</code> will open an IRB session where
756
+ # +binding.irb+ is called, and you will see the following:
754
757
  #
755
758
  # $ ruby potato.rb
756
759
  #
@@ -780,7 +783,7 @@ class Binding
780
783
  # irb(#<Potato:0x00007feea1916670>):004:0> @cooked = true
781
784
  # => true
782
785
  #
783
- # You can exit the IRB session with the `exit` command. Note that exiting will
786
+ # You can exit the IRB session with the +exit+ command. Note that exiting will
784
787
  # resume execution where +binding.irb+ had paused it, as you can see from the
785
788
  # output printed to standard output in this example:
786
789
  #
data/lib/irb/cmd/fork.rb CHANGED
@@ -21,7 +21,7 @@ module IRB
21
21
  class << self
22
22
  alias_method :exit, ExtendCommand.irb_original_method_name('exit')
23
23
  end
24
- if iterator?
24
+ if block_given?
25
25
  begin
26
26
  yield
27
27
  ensure
@@ -8,6 +8,7 @@
8
8
  #
9
9
 
10
10
  require "readline"
11
+ require "rdoc"
11
12
 
12
13
  module IRB
13
14
  module InputCompletor # :nodoc:
@@ -35,7 +36,13 @@ module IRB
35
36
  yield
36
37
  ]
37
38
 
39
+ BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
40
+
38
41
  CompletionProc = proc { |input|
42
+ retrieve_completion_data(input).compact.map{ |i| i.encode(Encoding.default_external) }
43
+ }
44
+
45
+ def self.retrieve_completion_data(input, doc_namespace = false)
39
46
  bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
40
47
 
41
48
  case input
@@ -45,7 +52,11 @@ module IRB
45
52
  message = Regexp.quote($3)
46
53
 
47
54
  candidates = String.instance_methods.collect{|m| m.to_s}
48
- select_message(receiver, message, candidates)
55
+ if doc_namespace
56
+ "String.#{message}"
57
+ else
58
+ select_message(receiver, message, candidates)
59
+ end
49
60
 
50
61
  when /^(\/[^\/]*\/)\.([^.]*)$/
51
62
  # Regexp
@@ -53,7 +64,11 @@ module IRB
53
64
  message = Regexp.quote($2)
54
65
 
55
66
  candidates = Regexp.instance_methods.collect{|m| m.to_s}
56
- select_message(receiver, message, candidates)
67
+ if doc_namespace
68
+ "Regexp.#{message}"
69
+ else
70
+ select_message(receiver, message, candidates)
71
+ end
57
72
 
58
73
  when /^([^\]]*\])\.([^.]*)$/
59
74
  # Array
@@ -61,19 +76,28 @@ module IRB
61
76
  message = Regexp.quote($2)
62
77
 
63
78
  candidates = Array.instance_methods.collect{|m| m.to_s}
64
- select_message(receiver, message, candidates)
79
+ if doc_namespace
80
+ "Array.#{message}"
81
+ else
82
+ select_message(receiver, message, candidates)
83
+ end
65
84
 
66
85
  when /^([^\}]*\})\.([^.]*)$/
67
86
  # Proc or Hash
68
87
  receiver = $1
69
88
  message = Regexp.quote($2)
70
89
 
71
- candidates = Proc.instance_methods.collect{|m| m.to_s}
72
- candidates |= Hash.instance_methods.collect{|m| m.to_s}
73
- select_message(receiver, message, candidates)
90
+ proc_candidates = Proc.instance_methods.collect{|m| m.to_s}
91
+ hash_candidates = Hash.instance_methods.collect{|m| m.to_s}
92
+ if doc_namespace
93
+ ["Proc.#{message}", "Hash.#{message}"]
94
+ else
95
+ select_message(receiver, message, proc_candidates | hash_candidates)
96
+ end
74
97
 
75
98
  when /^(:[^:.]*)$/
76
99
  # Symbol
100
+ return nil if doc_namespace
77
101
  if Symbol.respond_to?(:all_symbols)
78
102
  sym = $1
79
103
  candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
@@ -86,7 +110,11 @@ module IRB
86
110
  # Absolute Constant or class methods
87
111
  receiver = $1
88
112
  candidates = Object.constants.collect{|m| m.to_s}
89
- candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
113
+ if doc_namespace
114
+ candidates.find { |i| i == receiver }
115
+ else
116
+ candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
117
+ end
90
118
 
91
119
  when /^([A-Z].*)::([^:.]*)$/
92
120
  # Constant or class methods
@@ -98,7 +126,11 @@ module IRB
98
126
  rescue Exception
99
127
  candidates = []
100
128
  end
101
- select_message(receiver, message, candidates, "::")
129
+ if doc_namespace
130
+ "#{receiver}::#{message}"
131
+ else
132
+ select_message(receiver, message, candidates, "::")
133
+ end
102
134
 
103
135
  when /^(:[^:.]+)(\.|::)([^.]*)$/
104
136
  # Symbol
@@ -107,20 +139,33 @@ module IRB
107
139
  message = Regexp.quote($3)
108
140
 
109
141
  candidates = Symbol.instance_methods.collect{|m| m.to_s}
110
- select_message(receiver, message, candidates, sep)
142
+ if doc_namespace
143
+ "Symbol.#{message}"
144
+ else
145
+ select_message(receiver, message, candidates, sep)
146
+ end
111
147
 
112
- when /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)(\.|::)([^.]*)$/
148
+ when /^(?<num>-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE][+-]?[0-9]+i?|r)?)(?<sep>\.|::)(?<mes>[^.]*)$/
113
149
  # Numeric
114
- receiver = $1
115
- sep = $5
116
- message = Regexp.quote($6)
150
+ receiver = $~[:num]
151
+ sep = $~[:sep]
152
+ message = Regexp.quote($~[:mes])
117
153
 
118
154
  begin
119
- candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
155
+ instance = eval(receiver, bind)
156
+ if doc_namespace
157
+ "#{instance.class.name}.#{message}"
158
+ else
159
+ candidates = instance.methods.collect{|m| m.to_s}
160
+ select_message(receiver, message, candidates, sep)
161
+ end
120
162
  rescue Exception
121
- candidates = []
163
+ if doc_namespace
164
+ nil
165
+ else
166
+ candidates = []
167
+ end
122
168
  end
123
- select_message(receiver, message, candidates, sep)
124
169
 
125
170
  when /^(-?0x[0-9a-fA-F_]+)(\.|::)([^.]*)$/
126
171
  # Numeric(0xFFFF)
@@ -129,16 +174,30 @@ module IRB
129
174
  message = Regexp.quote($3)
130
175
 
131
176
  begin
132
- candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
177
+ instance = eval(receiver, bind)
178
+ if doc_namespace
179
+ "#{instance.class.name}.#{message}"
180
+ else
181
+ candidates = instance.methods.collect{|m| m.to_s}
182
+ select_message(receiver, message, candidates, sep)
183
+ end
133
184
  rescue Exception
134
- candidates = []
185
+ if doc_namespace
186
+ nil
187
+ else
188
+ candidates = []
189
+ end
135
190
  end
136
- select_message(receiver, message, candidates, sep)
137
191
 
138
192
  when /^(\$[^.]*)$/
139
193
  # global var
140
- regmessage = Regexp.new(Regexp.quote($1))
141
- candidates = global_variables.collect{|m| m.to_s}.grep(regmessage)
194
+ gvar = $1
195
+ all_gvars = global_variables.collect{|m| m.to_s}
196
+ if doc_namespace
197
+ all_gvars.find{ |i| i == gvar }
198
+ else
199
+ all_gvars.grep(Regexp.new(Regexp.quote(gvar)))
200
+ end
142
201
 
143
202
  when /^([^."].*)(\.|::)([^.]*)$/
144
203
  # variable.func or func.func
@@ -177,7 +236,11 @@ module IRB
177
236
  candidates.sort!
178
237
  candidates.uniq!
179
238
  end
180
- select_message(receiver, message, candidates, sep)
239
+ if doc_namespace
240
+ "#{rec.class.name}#{sep}#{candidates.find{ |i| i == message }}"
241
+ else
242
+ select_message(receiver, message, candidates, sep)
243
+ end
181
244
 
182
245
  when /^\.([^.]*)$/
183
246
  # unknown(maybe String)
@@ -186,12 +249,50 @@ module IRB
186
249
  message = Regexp.quote($1)
187
250
 
188
251
  candidates = String.instance_methods(true).collect{|m| m.to_s}
189
- select_message(receiver, message, candidates)
252
+ if doc_namespace
253
+ "String.#{candidates.find{ |i| i == message }}"
254
+ else
255
+ select_message(receiver, message, candidates)
256
+ end
190
257
 
191
258
  else
192
259
  candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
260
+ conditions |= ReservedWords
261
+
262
+ if doc_namespace
263
+ candidates.find{ |i| i == input }
264
+ else
265
+ candidates.grep(/^#{Regexp.quote(input)}/)
266
+ end
267
+ end
268
+ end
193
269
 
194
- (candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/)
270
+ RDocRIDriver = RDoc::RI::Driver.new
271
+ PerfectMatchedProc = ->(matched) {
272
+ if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
273
+ File.open(File.join(__dir__, 'ruby_logo.aa')) do |f|
274
+ RDocRIDriver.page do |io|
275
+ IO.copy_stream(f, io)
276
+ end
277
+ end
278
+ return
279
+ end
280
+ namespace = retrieve_completion_data(matched, true)
281
+ return unless matched
282
+ if namespace.is_a?(Array)
283
+ out = RDoc::Markup::Document.new
284
+ namespace.each do |m|
285
+ begin
286
+ RDocRIDriver.add_method(out, m)
287
+ rescue RDoc::RI::Driver::NotFoundError
288
+ end
289
+ end
290
+ RDocRIDriver.display(out)
291
+ else
292
+ begin
293
+ RDocRIDriver.display_names([namespace])
294
+ rescue RDoc::RI::Driver::NotFoundError
295
+ end
195
296
  end
196
297
  }
197
298
 
@@ -236,9 +337,3 @@ module IRB
236
337
  end
237
338
  end
238
339
  end
239
-
240
- if Readline.respond_to?("basic_word_break_characters=")
241
- Readline.basic_word_break_characters= " \t\n`><=;|&{("
242
- end
243
- Readline.completion_append_character = nil
244
- Readline.completion_proc = IRB::InputCompletor::CompletionProc
data/lib/irb/context.rb CHANGED
@@ -22,7 +22,7 @@ module IRB
22
22
  #
23
23
  # The optional +input_method+ argument:
24
24
  #
25
- # +nil+:: uses stdin or Readline
25
+ # +nil+:: uses stdin or Reidline or Readline
26
26
  # +String+:: uses a File
27
27
  # +other+:: uses this as InputMethod
28
28
  def initialize(irb, workspace = nil, input_method = nil, output_method = nil)
@@ -40,6 +40,8 @@ module IRB
40
40
  @load_modules = IRB.conf[:LOAD_MODULES]
41
41
 
42
42
  @use_readline = IRB.conf[:USE_READLINE]
43
+ @use_reidline = IRB.conf[:USE_REIDLINE]
44
+ @use_colorize = IRB.conf[:USE_COLORIZE]
43
45
  @verbose = IRB.conf[:VERBOSE]
44
46
  @io = nil
45
47
 
@@ -64,23 +66,41 @@ module IRB
64
66
 
65
67
  case input_method
66
68
  when nil
67
- case use_readline?
69
+ @io = nil
70
+ case use_reidline?
68
71
  when nil
69
- if (defined?(ReadlineInputMethod) && STDIN.tty? &&
70
- IRB.conf[:PROMPT_MODE] != :INF_RUBY)
71
- @io = ReadlineInputMethod.new
72
+ if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_readline?
73
+ @io = ReidlineInputMethod.new
72
74
  else
73
- @io = StdioInputMethod.new
75
+ @io = nil
74
76
  end
75
77
  when false
76
- @io = StdioInputMethod.new
78
+ @io = nil
77
79
  when true
78
- if defined?(ReadlineInputMethod)
79
- @io = ReadlineInputMethod.new
80
+ @io = ReidlineInputMethod.new
81
+ end
82
+ unless @io
83
+ case use_readline?
84
+ when nil
85
+ if (defined?(ReadlineInputMethod) && STDIN.tty? &&
86
+ IRB.conf[:PROMPT_MODE] != :INF_RUBY)
87
+ @io = ReadlineInputMethod.new
88
+ else
89
+ @io = nil
90
+ end
91
+ when false
92
+ @io = nil
93
+ when true
94
+ if defined?(ReadlineInputMethod)
95
+ @io = ReadlineInputMethod.new
96
+ else
97
+ @io = nil
98
+ end
80
99
  else
81
- @io = StdioInputMethod.new
100
+ @io = nil
82
101
  end
83
102
  end
103
+ @io = StdioInputMethod.new unless @io
84
104
 
85
105
  when String
86
106
  @io = FileInputMethod.new(input_method)
@@ -101,7 +121,6 @@ module IRB
101
121
  if @echo.nil?
102
122
  @echo = true
103
123
  end
104
- self.debug_level = IRB.conf[:DEBUG_LEVEL]
105
124
  end
106
125
 
107
126
  # The top-level workspace, see WorkSpace#main
@@ -117,9 +136,9 @@ module IRB
117
136
  attr_reader :thread
118
137
  # The current input method
119
138
  #
120
- # Can be either StdioInputMethod, ReadlineInputMethod, FileInputMethod or
121
- # other specified when the context is created. See ::new for more
122
- # information on +input_method+.
139
+ # Can be either StdioInputMethod, ReadlineInputMethod,
140
+ # ReidlineInputMethod, FileInputMethod or other specified when the
141
+ # context is created. See ::new for more # information on +input_method+.
123
142
  attr_accessor :io
124
143
 
125
144
  # Current irb session
@@ -137,12 +156,22 @@ module IRB
137
156
  # +input_method+ passed to Context.new
138
157
  attr_accessor :irb_path
139
158
 
159
+ # Whether +Reidline+ is enabled or not.
160
+ #
161
+ # A copy of the default <code>IRB.conf[:USE_REIDLINE]</code>
162
+ #
163
+ # See #use_reidline= for more information.
164
+ attr_reader :use_reidline
140
165
  # Whether +Readline+ is enabled or not.
141
166
  #
142
167
  # A copy of the default <code>IRB.conf[:USE_READLINE]</code>
143
168
  #
144
169
  # See #use_readline= for more information.
145
170
  attr_reader :use_readline
171
+ # Whether colorization is enabled or not.
172
+ #
173
+ # A copy of the default <code>IRB.conf[:USE_COLORIZE]</code>
174
+ attr_reader :use_colorize
146
175
  # A copy of the default <code>IRB.conf[:INSPECT_MODE]</code>
147
176
  attr_reader :inspect_mode
148
177
 
@@ -211,10 +240,6 @@ module IRB
211
240
  #
212
241
  # A copy of the default <code>IRB.conf[:VERBOSE]</code>
213
242
  attr_accessor :verbose
214
- # The debug level of irb
215
- #
216
- # See #debug_level= for more information.
217
- attr_reader :debug_level
218
243
 
219
244
  # The limit of backtrace lines displayed as top +n+ and tail +n+.
220
245
  #
@@ -225,8 +250,12 @@ module IRB
225
250
  # See IRB@Command+line+options for more command line options.
226
251
  attr_accessor :back_trace_limit
227
252
 
253
+ # Alias for #use_reidline
254
+ alias use_reidline? use_reidline
228
255
  # Alias for #use_readline
229
256
  alias use_readline? use_readline
257
+ # Alias for #use_colorize
258
+ alias use_colorize? use_colorize
230
259
  # Alias for #rc
231
260
  alias rc? rc
232
261
  alias ignore_sigint? ignore_sigint
@@ -236,7 +265,9 @@ module IRB
236
265
  # Returns whether messages are displayed or not.
237
266
  def verbose?
238
267
  if @verbose.nil?
239
- if defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
268
+ if @io.kind_of?(ReidlineInputMethod)
269
+ false
270
+ elsif defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
240
271
  false
241
272
  elsif !STDIN.tty? or @io.kind_of?(FileInputMethod)
242
273
  true
@@ -249,9 +280,11 @@ module IRB
249
280
  end
250
281
 
251
282
  # Whether #verbose? is +true+, and +input_method+ is either
252
- # StdioInputMethod or ReadlineInputMethod, see #io for more information.
283
+ # StdioInputMethod or ReidlineInputMethod or ReadlineInputMethod, see #io
284
+ # for more information.
253
285
  def prompting?
254
286
  verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
287
+ @io.kind_of?(ReidlineInputMethod) ||
255
288
  (defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
256
289
  end
257
290
 
@@ -361,25 +394,11 @@ module IRB
361
394
  print "Do nothing."
362
395
  end
363
396
 
364
- # Sets the debug level of irb
365
- #
366
- # Can also be set using the +--irb_debug+ command line option.
367
- #
368
- # See IRB@Command+line+options for more command line options.
369
- def debug_level=(value)
370
- @debug_level = value
371
- RubyLex.debug_level = value
372
- end
373
-
374
- # Whether or not debug mode is enabled, see #debug_level=.
375
- def debug?
376
- @debug_level > 0
377
- end
378
-
379
397
  def evaluate(line, line_no, exception: nil) # :nodoc:
380
398
  @line_no = line_no
381
399
  if exception
382
- line = "begin ::Kernel.raise _; rescue _.class; #{line}; end"
400
+ line_no -= 1
401
+ line = "begin ::Kernel.raise _; rescue _.class\n#{line}\n""end"
383
402
  @workspace.local_variable_set(:_, exception)
384
403
  end
385
404
  set_last_value(@workspace.evaluate(self, line, irb_path, line_no))