19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/ruvim/screen.rb', line 19
def render(editor)
@rich_render_info = nil
rows, cols = @terminal.winsize
text_rows, text_cols = editor.text_viewport_size(rows:, cols:)
text_rows = [text_rows, 1].max
text_cols = [text_cols, 1].max
rects = window_rects(editor, text_rows:, text_cols:)
if (current_rect = rects[editor.current_window_id])
editor.current_window_view_height_hint = [current_rect[:height], 1].max
end
editor.window_order.each do |win_id|
win = editor.windows.fetch(win_id)
buf = editor.buffers.fetch(win.buffer_id)
rect = rects[win_id]
next unless rect
content_width = [rect[:width] - number_column_width(editor, win, buf), 1].max
if RuVim::RichView.active?(editor)
win.ensure_visible(
buf,
height: [rect[:height], 1].max,
width: content_width,
tabstop: tabstop_for(editor, win, buf),
scrolloff: editor.effective_option("scrolloff", window: win, buffer: buf),
sidescrolloff: editor.effective_option("sidescrolloff", window: win, buffer: buf)
)
ensure_visible_rich(editor, win, buf, rect, content_width)
else
win.col_offset = 0 if wrap_enabled?(editor, win, buf)
win.ensure_visible(
buf,
height: [rect[:height], 1].max,
width: content_width,
tabstop: tabstop_for(editor, win, buf),
scrolloff: editor.effective_option("scrolloff", window: win, buffer: buf),
sidescrolloff: editor.effective_option("sidescrolloff", window: win, buffer: buf)
)
if wrap_enabled?(editor, win, buf)
ensure_visible_under_wrap(editor, win, buf, height: [rect[:height], 1].max, content_w: content_width)
end
end
end
frame = build_frame(editor, rows:, cols:, text_rows:, text_cols:, rects:)
out = if can_diff_render?(frame)
render_diff(frame)
else
render_full(frame)
end
cursor_row, cursor_col = cursor_screen_position(editor, text_rows, rects)
out << "\e[#{cursor_row};#{cursor_col}H"
if cursor_use_terminal?(editor)
out << "\e[6 q"
out << "\e[?25h"
else
out << "\e[?25l"
end
@last_frame = frame.merge(cursor_row:, cursor_col:)
@terminal.write(out)
end
|