Class: Reline::LineEditor
- Inherits:
-
Object
- Object
- Reline::LineEditor
- Defined in:
- lib/reline/line_editor.rb
Defined Under Namespace
Modules: CompletionState Classes: CompletionJourneyData, MenuInfo
Constant Summary collapse
- VI_MOTIONS =
%i{ ed_prev_char ed_next_char vi_zero ed_move_to_beg ed_move_to_end vi_to_column vi_next_char vi_prev_char vi_next_word vi_prev_word vi_to_next_char vi_to_prev_char vi_end_word vi_next_big_word vi_prev_big_word vi_end_big_word vi_repeat_next_char vi_repeat_prev_char }
- PROMPT_LIST_CACHE_TIMEOUT =
0.5
Instance Attribute Summary collapse
-
#auto_indent_proc ⇒ Object
Returns the value of attribute auto_indent_proc.
-
#byte_pointer ⇒ Object
Returns the value of attribute byte_pointer.
-
#completion_append_character ⇒ Object
Returns the value of attribute completion_append_character.
-
#completion_proc ⇒ Object
Returns the value of attribute completion_proc.
-
#confirm_multiline_termination_proc ⇒ Object
Returns the value of attribute confirm_multiline_termination_proc.
-
#dig_perfect_match_proc ⇒ Object
Returns the value of attribute dig_perfect_match_proc.
-
#line ⇒ Object
readonly
TODO: undo.
-
#output ⇒ Object
writeonly
Sets the attribute output.
-
#output_modifier_proc ⇒ Object
Returns the value of attribute output_modifier_proc.
-
#pre_input_hook ⇒ Object
Returns the value of attribute pre_input_hook.
-
#prompt_proc ⇒ Object
Returns the value of attribute prompt_proc.
Instance Method Summary collapse
- #call_completion_proc ⇒ Object
- #confirm_multiline_termination ⇒ Object
- #delete_text(start = nil, length = nil) ⇒ Object
- #editing_mode ⇒ Object
- #eof? ⇒ Boolean
- #finalize ⇒ Object
- #finish ⇒ Object
- #finished? ⇒ Boolean
-
#initialize(config, encoding) ⇒ LineEditor
constructor
A new instance of LineEditor.
- #input_key(key) ⇒ Object
- #insert_text(text) ⇒ Object
- #just_move_cursor ⇒ Object
- #multiline_off ⇒ Object
- #multiline_on ⇒ Object
- #rerender ⇒ Object
- #rerender_all ⇒ Object
- #reset(prompt = '', encoding:) ⇒ Object
- #reset_line ⇒ Object
- #reset_variables(prompt = '', encoding:) ⇒ Object
- #retrieve_completion_block(set_completion_quote_character = false) ⇒ Object
- #set_pasting_state(in_pasting) ⇒ Object
- #simplified_rendering? ⇒ Boolean
- #whole_buffer ⇒ Object
- #whole_lines(index: @line_index, line: @line) ⇒ Object
- #wrap_method_call(method_symbol, method_obj, key, with_operator = false) ⇒ Object
Constructor Details
#initialize(config, encoding) ⇒ LineEditor
Returns a new instance of LineEditor.
55 56 57 58 59 |
# File 'lib/reline/line_editor.rb', line 55 def initialize(config, encoding) @config = config @completion_append_character = '' reset_variables(encoding: encoding) end |
Instance Attribute Details
#auto_indent_proc ⇒ Object
Returns the value of attribute auto_indent_proc.
15 16 17 |
# File 'lib/reline/line_editor.rb', line 15 def auto_indent_proc @auto_indent_proc end |
#byte_pointer ⇒ Object
Returns the value of attribute byte_pointer.
9 10 11 |
# File 'lib/reline/line_editor.rb', line 9 def byte_pointer @byte_pointer end |
#completion_append_character ⇒ Object
Returns the value of attribute completion_append_character.
12 13 14 |
# File 'lib/reline/line_editor.rb', line 12 def completion_append_character @completion_append_character end |
#completion_proc ⇒ Object
Returns the value of attribute completion_proc.
11 12 13 |
# File 'lib/reline/line_editor.rb', line 11 def completion_proc @completion_proc end |
#confirm_multiline_termination_proc ⇒ Object
Returns the value of attribute confirm_multiline_termination_proc.
10 11 12 |
# File 'lib/reline/line_editor.rb', line 10 def confirm_multiline_termination_proc @confirm_multiline_termination_proc end |
#dig_perfect_match_proc ⇒ Object
Returns the value of attribute dig_perfect_match_proc.
17 18 19 |
# File 'lib/reline/line_editor.rb', line 17 def dig_perfect_match_proc @dig_perfect_match_proc end |
#line ⇒ Object (readonly)
TODO: undo
8 9 10 |
# File 'lib/reline/line_editor.rb', line 8 def line @line end |
#output=(value) ⇒ Object (writeonly)
Sets the attribute output
18 19 20 |
# File 'lib/reline/line_editor.rb', line 18 def output=(value) @output = value end |
#output_modifier_proc ⇒ Object
Returns the value of attribute output_modifier_proc.
13 14 15 |
# File 'lib/reline/line_editor.rb', line 13 def output_modifier_proc @output_modifier_proc end |
#pre_input_hook ⇒ Object
Returns the value of attribute pre_input_hook.
16 17 18 |
# File 'lib/reline/line_editor.rb', line 16 def pre_input_hook @pre_input_hook end |
#prompt_proc ⇒ Object
Returns the value of attribute prompt_proc.
14 15 16 |
# File 'lib/reline/line_editor.rb', line 14 def prompt_proc @prompt_proc end |
Instance Method Details
#call_completion_proc ⇒ Object
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 |
# File 'lib/reline/line_editor.rb', line 1160 def call_completion_proc result = retrieve_completion_block(true) preposing, target, postposing = result if @completion_proc and target argnum = @completion_proc.parameters.inject(0) { |result, item| case item.first when :req, :opt result + 1 when :rest break 3 end } case argnum when 1 result = @completion_proc.(target) when 2 result = @completion_proc.(target, preposing) when 3..Float::INFINITY result = @completion_proc.(target, preposing, postposing) end end Reline.core.instance_variable_set(:@completion_quote_character, nil) result end |
#confirm_multiline_termination ⇒ Object
1309 1310 1311 1312 1313 1314 1315 1316 1317 |
# File 'lib/reline/line_editor.rb', line 1309 def confirm_multiline_termination temp_buffer = @buffer_of_lines.dup if @previous_line_index and @line_index == (@buffer_of_lines.size - 1) temp_buffer[@previous_line_index] = @line else temp_buffer[@line_index] = @line end @confirm_multiline_termination_proc.(temp_buffer.join("\n") + "\n") end |
#delete_text(start = nil, length = nil) ⇒ Object
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 |
# File 'lib/reline/line_editor.rb', line 1331 def delete_text(start = nil, length = nil) if start.nil? and length.nil? if @is_multiline if @buffer_of_lines.size == 1 @line&.clear @byte_pointer = 0 @cursor = 0 @cursor_max = 0 elsif @line_index == (@buffer_of_lines.size - 1) and @line_index > 0 @buffer_of_lines.pop @line_index -= 1 @line = @buffer_of_lines[@line_index] @byte_pointer = 0 @cursor = 0 @cursor_max = calculate_width(@line) elsif @line_index < (@buffer_of_lines.size - 1) @buffer_of_lines.delete_at(@line_index) @line = @buffer_of_lines[@line_index] @byte_pointer = 0 @cursor = 0 @cursor_max = calculate_width(@line) end else @line&.clear @byte_pointer = 0 @cursor = 0 @cursor_max = 0 end elsif not start.nil? and not length.nil? if @line before = @line.byteslice(0, start) after = @line.byteslice(start + length, @line.bytesize) @line = before + after @byte_pointer = @line.bytesize if @byte_pointer > @line.bytesize str = @line.byteslice(0, @byte_pointer) @cursor = calculate_width(str) @cursor_max = calculate_width(@line) end elsif start.is_a?(Range) range = start first = range.first last = range.last last = @line.bytesize - 1 if last > @line.bytesize last += @line.bytesize if last < 0 first += @line.bytesize if first < 0 range = range.exclude_end? ? first...last : first..last @line = @line.bytes.reject.with_index{ |c, i| range.include?(i) }.map{ |c| c.chr(Encoding::ASCII_8BIT) }.join.force_encoding(@encoding) @byte_pointer = @line.bytesize if @byte_pointer > @line.bytesize str = @line.byteslice(0, @byte_pointer) @cursor = calculate_width(str) @cursor_max = calculate_width(@line) else @line = @line.byteslice(0, start) @byte_pointer = @line.bytesize if @byte_pointer > @line.bytesize str = @line.byteslice(0, @byte_pointer) @cursor = calculate_width(str) @cursor_max = calculate_width(@line) end end |
#editing_mode ⇒ Object
820 821 822 |
# File 'lib/reline/line_editor.rb', line 820 def editing_mode @config.editing_mode end |
#eof? ⇒ Boolean
207 208 209 |
# File 'lib/reline/line_editor.rb', line 207 def eof? @eof end |
#finalize ⇒ Object
203 204 205 |
# File 'lib/reline/line_editor.rb', line 203 def finalize Signal.trap('SIGINT', @old_trap) end |
#finish ⇒ Object
1420 1421 1422 1423 1424 |
# File 'lib/reline/line_editor.rb', line 1420 def finish @finished = true @rerender_all = true @config.reset end |
#finished? ⇒ Boolean
1416 1417 1418 |
# File 'lib/reline/line_editor.rb', line 1416 def finished? @finished end |
#input_key(key) ⇒ Object
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
# File 'lib/reline/line_editor.rb', line 1106 def input_key(key) @just_cursor_moving = nil if key.char.nil? if @first_char @line = nil end finish return end old_line = @line.dup @first_char = false completion_occurs = false if @config.editing_mode_is?(:emacs, :vi_insert) and key.char == "\C-i".ord unless @config.disable_completion result = call_completion_proc if result.is_a?(Array) completion_occurs = true process_insert complete(result) end end elsif not @config.disable_completion and @config.editing_mode_is?(:vi_insert) and ["\C-p".ord, "\C-n".ord].include?(key.char) unless @config.disable_completion result = call_completion_proc if result.is_a?(Array) completion_occurs = true process_insert move_completed_list(result, "\C-p".ord == key.char ? :up : :down) end end elsif Symbol === key.char and respond_to?(key.char, true) process_key(key.char, key.char) else normal_char(key) end unless completion_occurs @completion_state = CompletionState::NORMAL end if not @in_pasting and @just_cursor_moving.nil? if @previous_line_index and @buffer_of_lines[@previous_line_index] == @line @just_cursor_moving = true elsif @previous_line_index.nil? and @buffer_of_lines[@line_index] == @line and old_line == @line @just_cursor_moving = true else @just_cursor_moving = false end else @just_cursor_moving = false end if @is_multiline and @auto_indent_proc and not simplified_rendering? process_auto_indent end end |
#insert_text(text) ⇒ Object
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 |
# File 'lib/reline/line_editor.rb', line 1319 def insert_text(text) width = calculate_width(text) if @cursor == @cursor_max @line += text else @line = byteinsert(@line, @byte_pointer, text) end @byte_pointer += text.bytesize @cursor += width @cursor_max += width end |
#just_move_cursor ⇒ Object
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/reline/line_editor.rb', line 517 def just_move_cursor prompt, prompt_width, prompt_list = check_multiline_prompt(@buffer_of_lines, prompt) move_cursor_up(@started_from) new_first_line_started_from = if @line_index.zero? 0 else calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt) end first_line_diff = new_first_line_started_from - @first_line_started_from new_cursor, new_cursor_max, new_started_from, new_byte_pointer = calculate_nearest_cursor(@buffer_of_lines[@line_index], @cursor, @started_from, @byte_pointer, false) new_started_from = calculate_height_by_width(prompt_width + new_cursor) - 1 calculate_scroll_partial_screen(@highest_in_all, new_first_line_started_from + new_started_from) @previous_line_index = nil if @rerender_all @line = @buffer_of_lines[@line_index] rerender_all_lines @rerender_all = false true else @line = @buffer_of_lines[@line_index] @first_line_started_from = new_first_line_started_from @started_from = new_started_from @cursor = new_cursor @cursor_max = new_cursor_max @byte_pointer = new_byte_pointer move_cursor_down(first_line_diff + @started_from) Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last) false end end |
#multiline_off ⇒ Object
269 270 271 |
# File 'lib/reline/line_editor.rb', line 269 def multiline_off @is_multiline = false end |
#multiline_on ⇒ Object
265 266 267 |
# File 'lib/reline/line_editor.rb', line 265 def multiline_on @is_multiline = true end |
#rerender ⇒ Object
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/reline/line_editor.rb', line 377 def rerender return if @line.nil? if @menu_info scroll_down(@highest_in_all - @first_line_started_from) @rerender_all = true end if @menu_info @menu_info = nil end prompt, prompt_width, prompt_list = check_multiline_prompt(whole_lines, prompt) if @cleared clear_screen_buffer(prompt, prompt_list, prompt_width) @cleared = false return end if @is_multiline and finished? and @scroll_partial_screen # Re-output all code higher than the screen when finished. Reline::IOGate.move_cursor_up(@first_line_started_from + @started_from - @scroll_partial_screen) Reline::IOGate.move_cursor_column(0) @scroll_partial_screen = nil prompt, prompt_width, prompt_list = check_multiline_prompt(whole_lines, prompt) if @previous_line_index new_lines = whole_lines(index: @previous_line_index, line: @line) else new_lines = whole_lines end modify_lines(new_lines).each_with_index do |line, index| @output.write "#{prompt_list ? prompt_list[index] : prompt}#{line}\n" Reline::IOGate.erase_after_cursor end @output.flush return end new_highest_in_this = calculate_height_by_width(prompt_width + calculate_width(@line.nil? ? '' : @line)) # FIXME: end of logical line sometimes breaks rendered = false if @add_newline_to_end_of_buffer rerender_added_newline(prompt, prompt_width) @add_newline_to_end_of_buffer = false else if @just_cursor_moving and not @rerender_all rendered = just_move_cursor @just_cursor_moving = false return elsif @previous_line_index or new_highest_in_this != @highest_in_this rerender_changed_current_line @previous_line_index = nil rendered = true elsif @rerender_all rerender_all_lines @rerender_all = false rendered = true else end end if @is_multiline if finished? # Always rerender on finish because output_modifier_proc may return a different output. if @previous_line_index new_lines = whole_lines(index: @previous_line_index, line: @line) else new_lines = whole_lines end line = modify_lines(new_lines)[@line_index] prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines, prompt) render_partial(prompt, prompt_width, line, @first_line_started_from) move_cursor_down(@highest_in_all - (@first_line_started_from + @highest_in_this - 1) - 1) scroll_down(1) Reline::IOGate.move_cursor_column(0) Reline::IOGate.erase_after_cursor elsif not rendered unless @in_pasting line = modify_lines(whole_lines)[@line_index] prompt, prompt_width, prompt_list = check_multiline_prompt(whole_lines, prompt) render_partial(prompt, prompt_width, line, @first_line_started_from) end end @buffer_of_lines[@line_index] = @line @rest_height = 0 if @scroll_partial_screen else line = modify_lines(whole_lines)[@line_index] render_partial(prompt, prompt_width, line, 0) if finished? scroll_down(1) Reline::IOGate.move_cursor_column(0) Reline::IOGate.erase_after_cursor end end end |
#rerender_all ⇒ Object
371 372 373 374 375 |
# File 'lib/reline/line_editor.rb', line 371 def rerender_all @rerender_all = true process_insert(force: true) rerender end |
#reset(prompt = '', encoding:) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/reline/line_editor.rb', line 148 def reset(prompt = '', encoding:) @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y @screen_size = Reline::IOGate.get_screen_size @screen_height = @screen_size.first reset_variables(prompt, encoding: encoding) @old_trap = Signal.trap('SIGINT') { if @scroll_partial_screen move_cursor_down(@screen_height - (@line_index - @scroll_partial_screen) - 1) else move_cursor_down(@highest_in_all - @line_index - 1) end Reline::IOGate.move_cursor_column(0) scroll_down(1) @old_trap.call if @old_trap.respond_to?(:call) # can also be string, ex: "DEFAULT" raise Interrupt } Reline::IOGate.set_winch_handler do @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y old_screen_size = @screen_size @screen_size = Reline::IOGate.get_screen_size @screen_height = @screen_size.first if old_screen_size.last < @screen_size.last # columns increase @rerender_all = true rerender else back = 0 new_buffer = whole_lines prompt, prompt_width, prompt_list = check_multiline_prompt(new_buffer, prompt) new_buffer.each_with_index do |line, index| prompt_width = calculate_width(prompt_list[index], true) if @prompt_proc width = prompt_width + calculate_width(line) height = calculate_height_by_width(width) back += height end @highest_in_all = back @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max) @first_line_started_from = if @line_index.zero? 0 else calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt) end if @prompt_proc prompt = prompt_list[@line_index] prompt_width = calculate_width(prompt, true) end calculate_nearest_cursor @started_from = calculate_height_by_width(prompt_width + @cursor) - 1 Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last) @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max) @rerender_all = true end end end |
#reset_line ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/reline/line_editor.rb', line 247 def reset_line @cursor = 0 @cursor_max = 0 @byte_pointer = 0 @buffer_of_lines = [String.new(encoding: @encoding)] @line_index = 0 @previous_line_index = nil @line = @buffer_of_lines[0] @first_line_started_from = 0 @move_up = 0 @started_from = 0 @highest_in_this = 1 @highest_in_all = 1 @line_backup_in_history = nil @multibyte_buffer = String.new(encoding: 'ASCII-8BIT') @check_new_auto_indent = false end |
#reset_variables(prompt = '', encoding:) ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/reline/line_editor.rb', line 211 def reset_variables(prompt = '', encoding:) @prompt = prompt @mark_pointer = nil @encoding = encoding @is_multiline = false @finished = false @cleared = false @rerender_all = false @history_pointer = nil @kill_ring ||= Reline::KillRing.new @vi_clipboard = '' @vi_arg = nil @waiting_proc = nil @waiting_operator_proc = nil @waiting_operator_vi_arg = nil @completion_journey_data = nil @completion_state = CompletionState::NORMAL @perfect_matched = nil @menu_info = nil @first_prompt = true @searching_prompt = nil @first_char = true @add_newline_to_end_of_buffer = false @just_cursor_moving = nil @cached_prompt_list = nil @prompt_cache_time = nil @eof = false @continuous_insertion_buffer = String.new(encoding: @encoding) @scroll_partial_screen = nil @prev_mode_string = nil @drop_terminate_spaces = false @in_pasting = false @auto_indent_proc = nil reset_line end |
#retrieve_completion_block(set_completion_quote_character = false) ⇒ Object
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
# File 'lib/reline/line_editor.rb', line 1227 def retrieve_completion_block(set_completion_quote_character = false) if Reline.completer_word_break_characters.empty? word_break_regexp = nil else word_break_regexp = /\A[#{Regexp.escape(Reline.completer_word_break_characters)}]/ end if Reline.completer_quote_characters.empty? quote_characters_regexp = nil else quote_characters_regexp = /\A[#{Regexp.escape(Reline.completer_quote_characters)}]/ end before = @line.byteslice(0, @byte_pointer) rest = nil break_pointer = nil quote = nil closing_quote = nil escaped_quote = nil i = 0 while i < @byte_pointer do slice = @line.byteslice(i, @byte_pointer - i) unless slice.valid_encoding? i += 1 next end if quote and slice.start_with?(closing_quote) quote = nil i += 1 rest = nil elsif quote and slice.start_with?(escaped_quote) # skip i += 2 elsif quote_characters_regexp and slice =~ quote_characters_regexp # find new " rest = $' quote = $& closing_quote = /(?!\\)#{Regexp.escape(quote)}/ escaped_quote = /\\#{Regexp.escape(quote)}/ i += 1 break_pointer = i - 1 elsif word_break_regexp and not quote and slice =~ word_break_regexp rest = $' i += 1 before = @line.byteslice(i, @byte_pointer - i) break_pointer = i else i += 1 end end postposing = @line.byteslice(@byte_pointer, @line.bytesize - @byte_pointer) if rest preposing = @line.byteslice(0, break_pointer) target = rest if set_completion_quote_character and quote Reline.core.instance_variable_set(:@completion_quote_character, quote) if postposing !~ /(?!\\)#{Regexp.escape(quote)}/ # closing quote insert_text(quote) end end else preposing = '' if break_pointer preposing = @line.byteslice(0, break_pointer) else preposing = '' end target = before end if @is_multiline if @previous_line_index lines = whole_lines(index: @previous_line_index, line: @line) else lines = whole_lines end if @line_index > 0 preposing = lines[0..(@line_index - 1)].join("\n") + "\n" + preposing end if (lines.size - 1) > @line_index postposing = postposing + "\n" + lines[(@line_index + 1)..-1].join("\n") end end [preposing.encode(@encoding), target.encode(@encoding), postposing.encode(@encoding)] end |
#set_pasting_state(in_pasting) ⇒ Object
61 62 63 |
# File 'lib/reline/line_editor.rb', line 61 def set_pasting_state(in_pasting) @in_pasting = in_pasting end |
#simplified_rendering? ⇒ Boolean
65 66 67 68 69 70 71 72 73 |
# File 'lib/reline/line_editor.rb', line 65 def simplified_rendering? if finished? false elsif @just_cursor_moving and not @rerender_all true else not @rerender_all and not finished? and @in_pasting end end |
#whole_buffer ⇒ Object
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 |
# File 'lib/reline/line_editor.rb', line 1404 def whole_buffer if @buffer_of_lines.size == 1 and @line.nil? nil else if @previous_line_index whole_lines(index: @previous_line_index, line: @line).join("\n") else whole_lines.join("\n") end end end |
#whole_lines(index: @line_index, line: @line) ⇒ Object
1398 1399 1400 1401 1402 |
# File 'lib/reline/line_editor.rb', line 1398 def whole_lines(index: @line_index, line: @line) temp_lines = @buffer_of_lines.dup temp_lines[index] = line temp_lines end |
#wrap_method_call(method_symbol, method_obj, key, with_operator = false) ⇒ Object
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
# File 'lib/reline/line_editor.rb', line 997 def wrap_method_call(method_symbol, method_obj, key, with_operator = false) if @config.editing_mode_is?(:emacs, :vi_insert) and @waiting_proc.nil? and @waiting_operator_proc.nil? not_insertion = method_symbol != :ed_insert process_insert(force: not_insertion) end if @vi_arg and argumentable?(method_obj) if with_operator and inclusive?(method_obj) method_obj.(key, arg: @vi_arg, inclusive: true) else method_obj.(key, arg: @vi_arg) end else if with_operator and inclusive?(method_obj) method_obj.(key, inclusive: true) else method_obj.(key) end end end |