diff options
author | aycabta <aycabta@gmail.com> | 2021-09-07 05:14:43 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-09-08 00:04:40 +0900 |
commit | 30486d91504e33c3f49776b1df135a6182de9b42 (patch) | |
tree | 38ad95a6c2e6c04053e0646c6aec477cee8e32a0 /lib/reline | |
parent | 26153667f91f0c883f6af6b61fac2c0df5312b45 (diff) |
[ruby/reline] The width of Block Elements in Unicode is East Asian Ambiguous
https://github.com/ruby/reline/commit/05e8ab8cbb
Diffstat (limited to 'lib/reline')
-rw-r--r-- | lib/reline/line_editor.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index fc48cd011f..3b81c99675 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -692,6 +692,7 @@ class Reline::LineEditor bar_height = (bar_max_height * ((dialog.contents.size * 2).to_f / (dialog_render_info.contents.size * 2))).floor.to_i position = ((bar_max_height - bar_height) * position_ratio).floor.to_i end + block_elem_size = calculate_width('█') dialog.contents.each_with_index do |item, i| if i == pointer bg_color = '45' @@ -706,15 +707,15 @@ class Reline::LineEditor @output.write "\e[#{bg_color}m#{str}" if dialog_render_info.scrollbar and dialog_render_info.contents.size > height @output.write "\e[37m" - if position <= (i * 2) and (i * 2 + 1) < (position + bar_height) + if position <= (i * 2) and (i * 2 + block_elem_size) < (position + bar_height) @output.write '█' elsif position <= (i * 2) and (i * 2) < (position + bar_height) @output.write '▀' str += '' - elsif position <= (i * 2 + 1) and (i * 2) < (position + bar_height) + elsif position <= (i * 2 + block_elem_size) and (i * 2) < (position + bar_height) @output.write '▄' else - @output.write ' ' + @output.write ' ' * block_elem_size end @output.write "\e[39m" end @@ -722,7 +723,7 @@ class Reline::LineEditor Reline::IOGate.move_cursor_column(dialog.column) move_cursor_down(1) if i < (dialog.contents.size - 1) end - dialog.width += 1 if dialog_render_info.scrollbar and dialog_render_info.contents.size > height + dialog.width += block_elem_size if dialog_render_info.scrollbar and dialog_render_info.contents.size > height Reline::IOGate.move_cursor_column(cursor_column) move_cursor_up(dialog.vertical_offset + dialog.contents.size - 1) Reline::IOGate.show_cursor |