Class: Fatty::Screen

Inherits:
Object
  • Object
show all
Defined in:
lib/fatty/screen.rb

Overview

Screen is a backend-neutral layout model.

It describes terminal geometry (rows/cols) and the logical regions that Fatty draws into (output/input/alert). Screen does not perform any IO and does not depend on curses.

Curses uses Screen to allocate resources (windows) and to understand where drawing should occur.

Defined Under Namespace

Classes: Rect

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rows:, cols:, status_rows: 0) ⇒ Screen

Returns a new instance of Screen.



29
30
31
# File 'lib/fatty/screen.rb', line 29

def initialize(rows:, cols:, status_rows: 0)
  resize(rows: rows, cols: cols, status_rows: status_rows)
end

Instance Attribute Details

#alert_rectObject (readonly)

Returns the value of attribute alert_rect.



26
27
28
# File 'lib/fatty/screen.rb', line 26

def alert_rect
  @alert_rect
end

#colsObject (readonly)

Returns the value of attribute cols.



23
24
25
# File 'lib/fatty/screen.rb', line 23

def cols
  @cols
end

#input_rectObject (readonly)

Returns the value of attribute input_rect.



25
26
27
# File 'lib/fatty/screen.rb', line 25

def input_rect
  @input_rect
end

#output_rectObject (readonly)

Returns the value of attribute output_rect.



24
25
26
# File 'lib/fatty/screen.rb', line 24

def output_rect
  @output_rect
end

#rowsObject (readonly)

Returns the value of attribute rows.



23
24
25
# File 'lib/fatty/screen.rb', line 23

def rows
  @rows
end

#status_rectObject (readonly)

Returns the value of attribute status_rect.



27
28
29
# File 'lib/fatty/screen.rb', line 27

def status_rect
  @status_rect
end

Instance Method Details

#resize(rows:, cols:, status_rows: 0) ⇒ Object

Update the terminal geometry and recompute the layout.



34
35
36
37
38
39
# File 'lib/fatty/screen.rb', line 34

def resize(rows:, cols:, status_rows: 0)
  @rows = rows
  @cols = cols
  layout!(status_rows: status_rows)
  self
end