ruby-changes:67533
From: aycabta <ko1@a...>
Date: Wed, 1 Sep 2021 18:05:36 +0900 (JST)
Subject: [ruby-changes:67533] 3bd3adde7c (master): [ruby/reline] Calc width including escape sequences and clear dialog correctly
https://git.ruby-lang.org/ruby.git/commit/?id=3bd3adde7c From 3bd3adde7cd952046539ca5ecd21d1bcfa2fe568 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Wed, 1 Sep 2021 17:52:28 +0900 Subject: [ruby/reline] Calc width including escape sequences and clear dialog correctly https://github.com/ruby/reline/commit/9b812d5151 --- lib/reline/line_editor.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 838494e..9ea0f07 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -787,12 +787,13 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L787 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) -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/