@@ -661,6 +661,13 @@ def add_dialog_proc(name, p, context = nil)
661
661
reset_dialog ( dialog , old_dialog )
662
662
move_cursor_down ( dialog . vertical_offset )
663
663
Reline ::IOGate . move_cursor_column ( dialog . column )
664
+ if dialog_render_info . scrollbar and dialog_render_info . contents . size > height
665
+ bar_max_height = height * 2
666
+ moving_distance = ( dialog_render_info . contents . size - height ) * 2
667
+ position_ratio = dialog . scroll_top . zero? ? 0.0 : ( ( dialog . scroll_top * 2 ) . to_f / moving_distance )
668
+ bar_height = ( bar_max_height * ( ( dialog . contents . size * 2 ) . to_f / ( dialog_render_info . contents . size * 2 ) ) ) . floor . to_i
669
+ position = ( ( bar_max_height - bar_height ) * position_ratio ) . floor . to_i
670
+ end
664
671
dialog . contents . each_with_index do |item , i |
665
672
if i == pointer
666
673
bg_color = '45'
@@ -672,10 +679,22 @@ def add_dialog_proc(name, p, context = nil)
672
679
end
673
680
end
674
681
str = padding_space_with_escape_sequences ( Reline ::Unicode . take_range ( item , 0 , dialog . width ) , dialog . width )
682
+ if dialog_render_info . scrollbar and dialog_render_info . contents . size > height
683
+ if position <= ( i * 2 ) and ( i * 2 ) <= ( position + bar_height )
684
+ str += '█'
685
+ elsif position <= ( i * 2 ) and ( i * 2 - 1 ) <= ( position + bar_height )
686
+ str += '▀'
687
+ elsif position <= ( i * 2 + 1 ) and ( i * 2 ) <= ( position + bar_height )
688
+ str += '▄'
689
+ else
690
+ str += ' '
691
+ end
692
+ end
675
693
@output . write "\e [#{ bg_color } m#{ str } \e [49m"
676
694
Reline ::IOGate . move_cursor_column ( dialog . column )
677
695
move_cursor_down ( 1 ) if i < ( dialog . contents . size - 1 )
678
696
end
697
+ dialog . width += 1 if dialog_render_info . scrollbar and dialog_render_info . contents . size > height
679
698
Reline ::IOGate . move_cursor_column ( cursor_column )
680
699
move_cursor_up ( dialog . vertical_offset + dialog . contents . size - 1 )
681
700
Reline ::IOGate . show_cursor
0 commit comments