Class: TuiTui::CanvasCompositor

Inherits:
Object
  • Object
show all
Defined in:
lib/tui_tui/canvas_compositor.rb

Overview

Builds the terminal update string. Same-size frames repaint only changed column spans of changed rows.

Instance Method Summary collapse

Constructor Details

#initialize(depth: :ansi256) ⇒ CanvasCompositor

Returns a new instance of CanvasCompositor.



9
10
11
# File 'lib/tui_tui/canvas_compositor.rb', line 9

def initialize(depth: :ansi256)
  @depth = depth
end

Instance Method Details

#render(previous, canvas) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tui_tui/canvas_compositor.rb', line 13

def render(previous, canvas)
  out = +""
  if full_repaint?(previous, canvas)
    out << Ansi::CLEAR
    (1..canvas.rows).each { |row| out << row_paint(canvas, row) }
  else
    (1..canvas.rows).each { |row| out << row_diff(canvas, previous, row) }
  end

  out
end