mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
8e463e3e73
commit
4b2b10707a
2 changed files with 21 additions and 5 deletions
|
@ -183,7 +183,7 @@ module Reline
|
|||
end
|
||||
@dialog_proc = ->() {
|
||||
# autocomplete
|
||||
if just_cursor_moving
|
||||
if just_cursor_moving and completion_journey_data.nil?
|
||||
# Auto complete starts only when edited
|
||||
return nil
|
||||
end
|
||||
|
@ -191,7 +191,14 @@ module Reline
|
|||
if target.nil? or target.empty?
|
||||
return nil
|
||||
end
|
||||
result = call_completion_proc_with_checking_args(pre, target, post)
|
||||
if completion_journey_data and completion_journey_data.list
|
||||
result = completion_journey_data.list.dup
|
||||
result.shift
|
||||
pointer = completion_journey_data.pointer - 1
|
||||
else
|
||||
result = call_completion_proc_with_checking_args(pre, target, post)
|
||||
pointer = nil
|
||||
end
|
||||
if result and result.size == 1 and result[0] == target
|
||||
result = nil
|
||||
end
|
||||
|
@ -203,7 +210,7 @@ module Reline
|
|||
else
|
||||
y = 0
|
||||
end
|
||||
[Reline::CursorPos.new(x, y), result]
|
||||
[Reline::CursorPos.new(x, y), result, pointer]
|
||||
}
|
||||
inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
|
||||
|
||||
|
|
|
@ -514,6 +514,10 @@ class Reline::LineEditor
|
|||
@line_editor.instance_variable_get(:@screen_size).last
|
||||
end
|
||||
|
||||
def completion_journey_data
|
||||
@line_editor.instance_variable_get(:@completion_journey_data)
|
||||
end
|
||||
|
||||
def call
|
||||
instance_exec(&@proc_to_exec)
|
||||
end
|
||||
|
@ -533,7 +537,7 @@ class Reline::LineEditor
|
|||
return
|
||||
end
|
||||
@dialog_proc_scope.set_cursor_pos(cursor_column, @first_line_started_from + @started_from)
|
||||
pos, result = @dialog_proc_scope.call
|
||||
pos, result, pointer = @dialog_proc_scope.call
|
||||
old_dialog_contents = @dialog_contents
|
||||
old_dialog_contents_width = @dialog_contents_width
|
||||
old_dialog_column = @dialog_column
|
||||
|
@ -582,7 +586,12 @@ class Reline::LineEditor
|
|||
move_cursor_down(@dialog_vertical_offset)
|
||||
Reline::IOGate.move_cursor_column(@dialog_column)
|
||||
@dialog_contents.each_with_index do |item, i|
|
||||
@output.write "\e[46m%-#{DIALOG_WIDTH}s\e[49m" % item.slice(0, DIALOG_WIDTH)
|
||||
if i == pointer
|
||||
bg_color = '45'
|
||||
else
|
||||
bg_color = '46'
|
||||
end
|
||||
@output.write "\e[#{bg_color}m%-#{DIALOG_WIDTH}s\e[49m" % item.slice(0, DIALOG_WIDTH)
|
||||
Reline::IOGate.move_cursor_column(@dialog_column)
|
||||
move_cursor_down(1) if i < (@dialog_contents.size - 1)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue