class Reline::LineEditor
def render_dialog_changes(changes, cursor_column)
Experimental RBS support (using type sampling data from the type_fusion
project).
def render_dialog_changes: (Array[Array, Reline::LineEditor::Dialog, Reline::LineEditor::Dialog] changes, Integer cursor_column) -> nil
This signature was generated using 1 sample from 1 application.
def render_dialog_changes(changes, cursor_column) ect x-coordinate range and content of previous and current dialogs for each line alog_ranges = {} alog_ranges = {} alog_contents = {} s.each do |old_dialog, new_dialog| ld_dialog.contents range, y_range = dialog_range(old_dialog, @previous_rendered_dialog_y) range.each do |y| (old_dialog_ranges[y] ||= []) << x_range d ew_dialog.contents range, y_range = dialog_range(new_dialog, @first_line_started_from + @started_from) range.each do |y| (new_dialog_ranges[y] ||= []) << x_range (new_dialog_contents[y] ||= []) << [x_range, new_dialog.contents[y - y_range.begin]] d if old_dialog_ranges.empty? && new_dialog_ranges.empty? ulate x-coordinate ranges to restore text that was hidden behind dialogs for each line _to_restore = {} ct_cache = {} alog_ranges.each do |y, old_x_ranges| x_ranges = new_dialog_ranges[y] || [] es = subtract_cache[[old_x_ranges, new_x_ranges]] ||= range_subtract(old_x_ranges, new_x_ranges) es_to_restore[y] = ranges if ranges.any? te visual_lines for restoring text hidden behind dialogs ges_to_restore.any? s = whole_lines pt, _prompt_width, prompt_list = check_multiline_prompt(lines, force_recalc: true) fied_lines = modify_lines(lines, force_recalc: true) al_lines = [] fied_lines.each_with_index { |l, i| = prompt_list ? prompt_list[i] : prompt , = split_by_width(pr + l, @screen_size.last) .compact! sual_lines.concat(vl) r and rerender all dialogs line by line ::IOGate.hide_cursor ymax = (ranges_to_restore.keys + new_dialog_ranges.keys).minmax _partial_screen = @scroll_partial_screen || 0 _y_range = scroll_partial_screen..(scroll_partial_screen + @screen_height - 1) ymin.clamp(screen_y_range.begin, screen_y_range.end) ymax.clamp(screen_y_range.begin, screen_y_range.end) _y = @first_line_started_from + @started_from _y = dialog_y ghest_in_all <= ymax ll_down(ymax - cursor_y) _cursor_up(ymax - cursor_y) .ymax).each do |y| _cursor_down(y - cursor_y) or_y = y x_ranges = new_dialog_ranges[y] ore_ranges = ranges_to_restore[y] store text that was hidden behind dialogs estore_ranges ne = visual_lines[y] || '' store_ranges.each do |range| col = range.begin width = range.end - range.begin s = padding_space_with_escape_sequences(Reline::Unicode.take_range(line, col, width), width) Reline::IOGate.move_cursor_column(col) @output.write "\e[0m#{s}\e[0m" d x_column = [calculate_width(line, true), new_x_ranges&.map(&:end)&.max || 0].max max_column < restore_ranges.map(&:end).max Reline::IOGate.move_cursor_column(max_column) Reline::IOGate.erase_after_cursor d nder dialog contents dialog_contents[y]&.each do |x_range, content| line::IOGate.move_cursor_column(x_range.begin) utput.write "\e[0m#{content}\e[0m" ursor_up(cursor_y - dialog_y) ::IOGate.move_cursor_column(cursor_column) ::IOGate.show_cursor ous_rendered_dialog_y = dialog_y