[ruby/reline] Calc width including escape sequences and clear dialog correctly

https://github.com/ruby/reline/commit/9b812d5151
This commit is contained in:
aycabta 2021-09-01 17:52:28 +09:00 коммит произвёл git
Родитель 67eaa222cf
Коммит 3bd3adde7c
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -787,12 +787,13 @@ class Reline::LineEditor
dialog_vertical_size.times do |i|
if i < visual_lines_under_dialog.size
Reline::IOGate.move_cursor_column(0)
@output.write "\e[39m\e[49m%-#{dialog.width}s\e[39m\e[49m" % visual_lines_under_dialog[i]
width = calculate_width(visual_lines_under_dialog[i], true)
str = visual_lines_under_dialog[i] + (' ' * (dialog.width - width))
@output.write "\e[39m\e[49m#{str}\e[39m\e[49m"
else
Reline::IOGate.move_cursor_column(dialog.column)
@output.write "\e[39m\e[49m#{' ' * dialog.width}\e[39m\e[49m"
end
Reline::IOGate.erase_after_cursor
move_cursor_down(1) if i < (dialog_vertical_size - 1)
end
move_cursor_up(dialog_vertical_size - 1 + dialog.vertical_offset)