diff options
author | Jeremy Evans <[email protected]> | 2021-10-06 12:56:31 -0700 |
---|---|---|
committer | git <[email protected]> | 2021-10-08 10:38:47 +0900 |
commit | 55d7f63bdeda993696c2700bd1a2a3b02b0b6d30 (patch) | |
tree | eff85715ad010e0c23fd45cb4ba38f9e91a00cdc /lib/reline/line_editor.rb | |
parent | eb4682b3c6dd703b073614fa10dec9f968e98df3 (diff) |
[ruby/reline] Better fix for non-UTF-8 default external encoding
Previous fix didn't show the cursor or dialogs. This allows the
dialogs to continue to work.
https://github.com/ruby/reline/commit/651c5f63cc
Diffstat (limited to 'lib/reline/line_editor.rb')
-rw-r--r-- | lib/reline/line_editor.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 5991ab2301..6128cc8ddf 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -624,7 +624,6 @@ class Reline::LineEditor DIALOG_DEFAULT_HEIGHT = 20 private def render_dialog(cursor_column) - return unless Encoding.default_external == Encoding::UTF_8 @dialogs.each do |dialog| render_each_dialog(dialog, cursor_column) end @@ -717,6 +716,13 @@ class Reline::LineEditor reset_dialog(dialog, old_dialog) move_cursor_down(dialog.vertical_offset) Reline::IOGate.move_cursor_column(dialog.column) + if Encoding.default_external == Encoding::UTF_8 + full_block = '█' + upper_half_block = '▀' + lower_half_block = '▄' + else + full_block = upper_half_block = lower_half_block = '' + end dialog.contents.each_with_index do |item, i| if i == pointer bg_color = '45' @@ -733,12 +739,12 @@ class Reline::LineEditor if dialog.scrollbar_pos and (dialog.scrollbar_pos != old_dialog.scrollbar_pos or dialog.column != old_dialog.column) @output.write "\e[37m" if dialog.scrollbar_pos <= (i * 2) and (i * 2 + 1) < (dialog.scrollbar_pos + bar_height) - @output.write '█' + @output.write full_block elsif dialog.scrollbar_pos <= (i * 2) and (i * 2) < (dialog.scrollbar_pos + bar_height) - @output.write '▀' + @output.write upper_half_block str += '' elsif dialog.scrollbar_pos <= (i * 2 + 1) and (i * 2) < (dialog.scrollbar_pos + bar_height) - @output.write '▄' + @output.write lower_half_block else @output.write ' ' * @block_elem_width end |