[前][次][番号順一覧][スレッド一覧]

ruby-changes:67534

From: aycabta <ko1@a...>
Date: Wed, 1 Sep 2021 18:05:36 +0900 (JST)
Subject: [ruby-changes:67534] a669b9661e (master): [ruby/reline] Calc width including escape sequences and padding with spaces correctly

https://git.ruby-lang.org/ruby.git/commit/?id=a669b9661e

From a669b9661eaf9623160e2f2010f24b0b9fd5f01a Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Wed, 1 Sep 2021 17:53:17 +0900
Subject: [ruby/reline] Calc width including escape sequences and padding with
 spaces correctly

https://github.com/ruby/reline/commit/21c795e97f
---
 lib/reline/line_editor.rb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 9ea0f07..9df04f1 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -651,7 +651,9 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L651
           bg_color = '46'
         end
       end
-      @output.write "\e[#{bg_color}m%-#{dialog.width}s\e[49m" % Reline::Unicode.take_range(item, 0, dialog.width)
+      str = Reline::Unicode.take_range(item, 0, dialog.width)
+      str += ' ' * (dialog.width - calculate_width(str, true))
+      @output.write "\e[#{bg_color}m#{str}\e[49m"
       Reline::IOGate.move_cursor_column(dialog.column)
       move_cursor_down(1) if i < (dialog.contents.size - 1)
     end
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]