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
|
end
|
||||||
@dialog_proc = ->() {
|
@dialog_proc = ->() {
|
||||||
# autocomplete
|
# autocomplete
|
||||||
if just_cursor_moving
|
if just_cursor_moving and completion_journey_data.nil?
|
||||||
# Auto complete starts only when edited
|
# Auto complete starts only when edited
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
@ -191,7 +191,14 @@ module Reline
|
||||||
if target.nil? or target.empty?
|
if target.nil? or target.empty?
|
||||||
return nil
|
return nil
|
||||||
end
|
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
|
if result and result.size == 1 and result[0] == target
|
||||||
result = nil
|
result = nil
|
||||||
end
|
end
|
||||||
|
@ -203,7 +210,7 @@ module Reline
|
||||||
else
|
else
|
||||||
y = 0
|
y = 0
|
||||||
end
|
end
|
||||||
[Reline::CursorPos.new(x, y), result]
|
[Reline::CursorPos.new(x, y), result, pointer]
|
||||||
}
|
}
|
||||||
inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
|
inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
|
||||||
|
|
||||||
|
|
|
@ -514,6 +514,10 @@ class Reline::LineEditor
|
||||||
@line_editor.instance_variable_get(:@screen_size).last
|
@line_editor.instance_variable_get(:@screen_size).last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def completion_journey_data
|
||||||
|
@line_editor.instance_variable_get(:@completion_journey_data)
|
||||||
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
instance_exec(&@proc_to_exec)
|
instance_exec(&@proc_to_exec)
|
||||||
end
|
end
|
||||||
|
@ -533,7 +537,7 @@ class Reline::LineEditor
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@dialog_proc_scope.set_cursor_pos(cursor_column, @first_line_started_from + @started_from)
|
@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 = @dialog_contents
|
||||||
old_dialog_contents_width = @dialog_contents_width
|
old_dialog_contents_width = @dialog_contents_width
|
||||||
old_dialog_column = @dialog_column
|
old_dialog_column = @dialog_column
|
||||||
|
@ -582,7 +586,12 @@ class Reline::LineEditor
|
||||||
move_cursor_down(@dialog_vertical_offset)
|
move_cursor_down(@dialog_vertical_offset)
|
||||||
Reline::IOGate.move_cursor_column(@dialog_column)
|
Reline::IOGate.move_cursor_column(@dialog_column)
|
||||||
@dialog_contents.each_with_index do |item, i|
|
@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)
|
Reline::IOGate.move_cursor_column(@dialog_column)
|
||||||
move_cursor_down(1) if i < (@dialog_contents.size - 1)
|
move_cursor_down(1) if i < (@dialog_contents.size - 1)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue