|
1 | 1 | require 'rdoc/ri' |
2 | 2 |
|
3 | | -# readline support might not be present, so be careful |
4 | | -# when requiring it. |
5 | | -begin |
6 | | - require('readline') |
7 | | - require('abbrev') |
8 | | - CAN_USE_READLINE = true # HACK use an RDoc namespace constant |
9 | | -rescue LoadError |
10 | | - CAN_USE_READLINE = false |
11 | | -end |
12 | | - |
13 | 3 | ## |
14 | 4 | # This is a kind of 'flag' module. If you want to write your own 'ri' display |
15 | 5 | # module (perhaps because you're writing an IDE), you write a class which |
@@ -42,6 +32,8 @@ class RDoc::RI::DefaultDisplay |
42 | 32 |
|
43 | 33 | include RDoc::RI::Display |
44 | 34 |
|
| 35 | + attr_reader :formatter |
| 36 | + |
45 | 37 | def initialize(formatter, width, use_stdout, output = $stdout) |
46 | 38 | @use_stdout = use_stdout |
47 | 39 | @formatter = formatter.new output, width, " " |
@@ -126,51 +118,6 @@ def display_class_info(klass) |
126 | 118 | # the methods. |
127 | 119 |
|
128 | 120 | def get_class_method_choice(method_map) |
129 | | - if CAN_USE_READLINE then |
130 | | - # prepare abbreviations for tab completion |
131 | | - abbreviations = method_map.keys.abbrev |
132 | | - Readline.completion_proc = proc do |string| |
133 | | - abbreviations.values.uniq.grep(/^#{string}/) |
134 | | - end |
135 | | - end |
136 | | - |
137 | | - @formatter.raw_print_line "\nEnter the method name you want.\n" |
138 | | - @formatter.raw_print_line "Class methods can be preceeded by '::' and instance methods by '#'.\n" |
139 | | - |
140 | | - if CAN_USE_READLINE |
141 | | - @formatter.raw_print_line "You can use tab to autocomplete.\n" |
142 | | - @formatter.raw_print_line "Enter a blank line to exit.\n" |
143 | | - |
144 | | - choice_string = Readline.readline(">> ").strip |
145 | | - else |
146 | | - @formatter.raw_print_line "Enter a blank line to exit.\n" |
147 | | - @formatter.raw_print_line ">> " |
148 | | - choice_string = $stdin.gets.strip |
149 | | - end |
150 | | - |
151 | | - if choice_string == '' |
152 | | - return nil |
153 | | - else |
154 | | - class_or_instance = method_map[choice_string] |
155 | | - |
156 | | - if class_or_instance |
157 | | - # If the user's choice is not preceeded by a '::' or a '#', figure |
158 | | - # out whether they want a class or an instance method and decorate |
159 | | - # the choice appropriately. |
160 | | - if(choice_string =~ /^[a-zA-Z]/) |
161 | | - if(class_or_instance == :class) |
162 | | - choice_string = "::#{choice_string}" |
163 | | - else |
164 | | - choice_string = "##{choice_string}" |
165 | | - end |
166 | | - end |
167 | | - |
168 | | - return choice_string |
169 | | - else |
170 | | - @formatter.raw_print_line "No method matched '#{choice_string}'.\n" |
171 | | - return nil |
172 | | - end |
173 | | - end |
174 | 121 | end |
175 | 122 |
|
176 | 123 | ## |
@@ -326,7 +273,7 @@ def display_params(method) |
326 | 273 | # List the classes in +classes+. |
327 | 274 |
|
328 | 275 | def list_known_classes(classes) |
329 | | - if classes.empty? |
| 276 | + if classes.empty? then |
330 | 277 | warn_no_database |
331 | 278 | else |
332 | 279 | page do |
|
0 commit comments