Skip to content

Commit

Permalink
Re-architecture LineEditor's internal state and rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Jan 21, 2024
1 parent 5b59e48 commit 317f17e
Show file tree
Hide file tree
Showing 2 changed files with 614 additions and 1,292 deletions.
17 changes: 10 additions & 7 deletions lib/reline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,12 @@ def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
Reline::HISTORY << whole_buffer
end

line_editor.reset_line if line_editor.whole_buffer.nil?
whole_buffer
if line_editor.eof?
line_editor.reset_line
nil
else
whole_buffer
end
end
end

Expand Down Expand Up @@ -326,7 +330,7 @@ def readline(prompt = '', add_hist = false)
line_editor.prompt_proc = prompt_proc
line_editor.auto_indent_proc = auto_indent_proc
line_editor.dig_perfect_match_proc = dig_perfect_match_proc
line_editor.pre_input_hook = pre_input_hook
pre_input_hook&.call
@dialog_proc_list.each_pair do |name_sym, d|
line_editor.add_dialog_proc(name_sym, d.dialog_proc, d.context)
end
Expand All @@ -337,6 +341,7 @@ def readline(prompt = '', add_hist = false)
io_gate.set_default_key_bindings(config)
end

line_editor.print_nomultiline_prompt(prompt)
line_editor.rerender

begin
Expand All @@ -346,10 +351,8 @@ def readline(prompt = '', add_hist = false)
prev_pasting_state = io_gate.in_pasting?
read_io(config.keyseq_timeout) { |inputs|
line_editor.set_pasting_state(io_gate.in_pasting?)
inputs.each { |c|
line_editor.input_key(c)
line_editor.rerender
}
inputs.each { |c| line_editor.update(c) }
line_editor.rerender
if @bracketed_paste_finished
line_editor.rerender_all
@bracketed_paste_finished = false
Expand Down
Loading

0 comments on commit 317f17e

Please sign in to comment.