Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reline 0.5.0.pre #614

Merged
merged 15 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions lib/reline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def initialize
@dialog_proc_list = {}
yield self
@completion_quote_character = nil
@bracketed_paste_finished = false
end

def io_gate
Expand Down Expand Up @@ -278,8 +277,13 @@ 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
# Return nil if the input is aborted by C-d.
nil
tompng marked this conversation as resolved.
Show resolved Hide resolved
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,30 +341,24 @@ def readline(prompt = '', add_hist = false)
io_gate.set_default_key_bindings(config)
end

line_editor.print_nomultiline_prompt(prompt)
line_editor.update_dialogs
Comment on lines +344 to +345
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let me know for study purposes. Why do I need to update dialogs before read_io?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reline has an ability to always show dialog. Reline needs to setup and render dialog on initial render, before first read_io.

irb(main):001> Reline.add_dialog_proc(:FOO,->{Reline::DialogRenderInfo.new contents:['DIALOG'], pos: cursor_pos})
irb(main):002> 
               DIALOG

This is tested in test_dialog_narrower_than_screen and test_dialog_with_fullwidth_scrollbar

line_editor.rerender

begin
line_editor.set_signal_handlers
prev_pasting_state = false
loop do
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
}
if @bracketed_paste_finished
line_editor.rerender_all
@bracketed_paste_finished = false
end
inputs.each { |key| line_editor.update(key) }
}
if prev_pasting_state == true and not io_gate.in_pasting? and not line_editor.finished?
line_editor.set_pasting_state(false)
prev_pasting_state = false
line_editor.rerender_all
if line_editor.finished?
line_editor.render_finished
break
else
line_editor.set_pasting_state(io_gate.in_pasting?)
line_editor.rerender
end
break if line_editor.finished?
end
io_gate.move_cursor_column(0)
rescue Errno::EIO
Expand Down Expand Up @@ -395,7 +393,6 @@ def readline(prompt = '', add_hist = false)
c = io_gate.getc(Float::INFINITY)
if c == -1
result = :unmatched
@bracketed_paste_finished = true
else
buffer << c
result = key_stroke.match_status(buffer)
Expand Down
2 changes: 1 addition & 1 deletion lib/reline/general_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def self.ungetc(c)
end

def self.get_screen_size
[1, 1]
[24, 80]
end

def self.cursor_pos
Expand Down
Loading
Loading