class Reline::LineEditor
def render_each_dialog(dialog, cursor_column)
def render_each_dialog(dialog, cursor_column) _pasting r_each_dialog(dialog) og.contents = nil og.trap_key = nil rn .set_cursor_pos(cursor_column, @first_line_started_from + @started_from) _render_info = dialog.call(@last_key) log_render_info.nil? or dialog_render_info.contents.nil? or dialog_render_info.contents.empty? s = whole_lines og.lines_backup = { modified_lines: lines, nes: modify_lines(lines), ne_index: @line_index, rst_line_started_from: @first_line_started_from, arted_from: @started_from, te_pointer: @byte_pointer r_each_dialog(dialog) og.contents = nil og.trap_key = nil rn alog = dialog.clone .contents = dialog_render_info.contents r = dialog.pointer log_render_info.width og.width = dialog_render_info.width og.width = dialog.contents.map { |l| calculate_width(l, true) }.max = dialog_render_info.height || DIALOG_DEFAULT_HEIGHT = dialog.contents.size if dialog.contents.size < height log.contents.size > height ialog.pointer dialog.pointer < 0 dialog.scroll_top = 0 sif (dialog.pointer - dialog.scroll_top) >= (height - 1) dialog.scroll_top = dialog.pointer - (height - 1) sif (dialog.pointer - dialog.scroll_top) < 0 dialog.scroll_top = dialog.pointer d inter = dialog.pointer - dialog.scroll_top alog.scroll_top = 0 og.contents = dialog.contents[dialog.scroll_top, height] log_render_info.scrollbar and dialog_render_info.contents.size > height max_height = height * 2 ng_distance = (dialog_render_info.contents.size - height) * 2 tion_ratio = dialog.scroll_top.zero? ? 0.0 : ((dialog.scroll_top * 2).to_f / moving_distance) height = (bar_max_height * ((dialog.contents.size * 2).to_f / (dialog_render_info.contents.size * 2))).floor.to_i height = MINIMUM_SCROLLBAR_HEIGHT if bar_height < MINIMUM_SCROLLBAR_HEIGHT og.scrollbar_pos = ((bar_max_height - bar_height) * position_ratio).floor.to_i og.scrollbar_pos = nil space = @first_line_started_from - @started_from .column = dialog_render_info.pos.x .width += @block_elem_width if dialog.scrollbar_pos (dialog.column + dialog.width) - (@screen_size.last) f > 0 og.column -= diff est_height - dialog_render_info.pos.y) >= height og.vertical_offset = dialog_render_info.pos.y + 1 upper_space >= height og.vertical_offset = dialog_render_info.pos.y - height @rest_height - dialog_render_info.pos.y) < height roll_down(height + dialog_render_info.pos.y) ve_cursor_up(height + dialog_render_info.pos.y) og.vertical_offset = dialog_render_info.pos.y + 1 ::IOGate.hide_cursor log.column < 0 og.column = 0 og.width = @screen_size.last dialog(dialog, old_dialog) ursor_down(dialog.vertical_offset) ::IOGate.move_cursor_column(dialog.column) .contents.each_with_index do |item, i| == pointer _color = dialog_render_info.pointer_fg_color _color = dialog_render_info.pointer_bg_color _color = dialog_render_info.fg_color _color = dialog_render_info.bg_color width = dialog.width - (dialog.scrollbar_pos.nil? ? 0 : @block_elem_width) = padding_space_with_escape_sequences(Reline::Unicode.take_range(item, 0, str_width), str_width) put.write "\e[#{bg_color}m\e[#{fg_color}m#{str}" ialog.scrollbar_pos utput.write "\e[37m" dialog.scrollbar_pos <= (i * 2) and (i * 2 + 1) < (dialog.scrollbar_pos + bar_height) @output.write @full_block sif dialog.scrollbar_pos <= (i * 2) and (i * 2) < (dialog.scrollbar_pos + bar_height) @output.write @upper_half_block sif dialog.scrollbar_pos <= (i * 2 + 1) and (i * 2) < (dialog.scrollbar_pos + bar_height) @output.write @lower_half_block se @output.write ' ' * @block_elem_width d put.write "\e[0m" ne::IOGate.move_cursor_column(dialog.column) _cursor_down(1) if i < (dialog.contents.size - 1) ::IOGate.move_cursor_column(cursor_column) ursor_up(dialog.vertical_offset + dialog.contents.size - 1) ::IOGate.show_cursor = whole_lines .lines_backup = { dified_lines: lines, s: modify_lines(lines), _index: @line_index, t_line_started_from: @first_line_started_from, ted_from: @started_from, _pointer: @byte_pointer