зеркало из https://github.com/github/ruby.git
[ruby/reline] Support custom bg color
https://github.com/ruby/reline/commit/cd0cbf53d5
This commit is contained in:
Родитель
7ea46c1ef2
Коммит
acd15a39d2
|
@ -211,7 +211,7 @@ module Reline
|
|||
cursor_pos_to_render = Reline::CursorPos.new(x, y)
|
||||
context.clear
|
||||
context.push(cursor_pos_to_render, result, pointer)
|
||||
[cursor_pos_to_render, result, pointer]
|
||||
[cursor_pos_to_render, result, pointer, nil]
|
||||
}
|
||||
|
||||
require 'rdoc'
|
||||
|
@ -247,7 +247,7 @@ module Reline
|
|||
formatter.width = 40
|
||||
str = doc.accept(formatter)
|
||||
|
||||
[Reline::CursorPos.new(cursor_pos_to_render.x + 40, cursor_pos_to_render.y + pointer), str.split("\n"), nil]
|
||||
[Reline::CursorPos.new(cursor_pos_to_render.x + 40, cursor_pos_to_render.y + pointer), str.split("\n"), nil, '40']
|
||||
}
|
||||
|
||||
def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
|
||||
|
|
|
@ -560,7 +560,7 @@ class Reline::LineEditor
|
|||
return
|
||||
end
|
||||
dialog.set_cursor_pos(cursor_column, @first_line_started_from + @started_from)
|
||||
pos, result, pointer = dialog.call
|
||||
pos, result, pointer, bg = dialog.call
|
||||
old_dialog_contents = dialog.contents
|
||||
old_dialog_column = dialog.column
|
||||
old_dialog_vertical_offset = dialog.vertical_offset
|
||||
|
@ -605,7 +605,11 @@ class Reline::LineEditor
|
|||
if i == pointer
|
||||
bg_color = '45'
|
||||
else
|
||||
bg_color = '46'
|
||||
if bg
|
||||
bg_color = bg
|
||||
else
|
||||
bg_color = '46'
|
||||
end
|
||||
end
|
||||
@output.write "\e[#{bg_color}m%-#{DIALOG_WIDTH}s\e[49m" % item.slice(0, DIALOG_WIDTH)
|
||||
Reline::IOGate.move_cursor_column(dialog.column)
|
||||
|
|
Загрузка…
Ссылка в новой задаче