Skip to content

Commit 651c5f6

Browse files
committed
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.
1 parent f570525 commit 651c5f6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/reline/line_editor.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ def add_dialog_proc(name, p, context = nil)
624624

625625
DIALOG_HEIGHT = 20
626626
private def render_dialog(cursor_column)
627-
return unless Encoding.default_external == Encoding::UTF_8
628627
@dialogs.each do |dialog|
629628
render_each_dialog(dialog, cursor_column)
630629
end
@@ -713,6 +712,13 @@ def add_dialog_proc(name, p, context = nil)
713712
reset_dialog(dialog, old_dialog)
714713
move_cursor_down(dialog.vertical_offset)
715714
Reline::IOGate.move_cursor_column(dialog.column)
715+
if Encoding.default_external == Encoding::UTF_8
716+
full_block = '█'
717+
upper_half_block = '▀'
718+
lower_half_block = '▄'
719+
else
720+
full_block = upper_half_block = lower_half_block = ''
721+
end
716722
dialog.contents.each_with_index do |item, i|
717723
if i == pointer
718724
bg_color = '45'
@@ -729,12 +735,12 @@ def add_dialog_proc(name, p, context = nil)
729735
if dialog.scrollbar_pos and (dialog.scrollbar_pos != old_dialog.scrollbar_pos or dialog.column != old_dialog.column)
730736
@output.write "\e[37m"
731737
if dialog.scrollbar_pos <= (i * 2) and (i * 2 + 1) < (dialog.scrollbar_pos + bar_height)
732-
@output.write '█'
738+
@output.write full_block
733739
elsif dialog.scrollbar_pos <= (i * 2) and (i * 2) < (dialog.scrollbar_pos + bar_height)
734-
@output.write '▀'
740+
@output.write upper_half_block
735741
str += ''
736742
elsif dialog.scrollbar_pos <= (i * 2 + 1) and (i * 2) < (dialog.scrollbar_pos + bar_height)
737-
@output.write '▄'
743+
@output.write lower_half_block
738744
else
739745
@output.write ' ' * @block_elem_width
740746
end

0 commit comments

Comments
 (0)