Class: Charming::Components::Viewport::LineWindow

Inherits:
Object
  • Object
show all
Defined in:
lib/charming/presentation/components/viewport/line_window.rb

Overview

LineWindow renders one content line inside the viewport’s horizontal window.

Constant Summary collapse

ANSI_PATTERN =
/\e\[[0-9;]*m/

Instance Method Summary collapse

Constructor Details

#initialize(width:, column:, wrap:) ⇒ LineWindow

Returns a new instance of LineWindow.



12
13
14
15
16
# File 'lib/charming/presentation/components/viewport/line_window.rb', line 12

def initialize(width:, column:, wrap:)
  @width = width
  @column = column
  @wrap = wrap
end

Instance Method Details

#render(line) ⇒ Object



18
19
20
21
22
23
# File 'lib/charming/presentation/components/viewport/line_window.rb', line 18

def render(line)
  return line unless width
  return pad_line(line, width) if wrap

  pad_line(clip_line(line), width)
end