Class: Potty::Surface
- Inherits:
-
Object
- Object
- Potty::Surface
- Defined in:
- lib/potty/surface.rb
Overview
Abstract render target. Widgets draw against a Surface (setpos / addstr / attron) and the concrete subclass decides how that reaches the terminal: CursesSurface paints a curses screen; InlineSurface writes ANSI to stdout. The component tree describes what; the surface decides how.
Direct Known Subclasses
Potty::Surfaces::CursesSurface, Potty::Surfaces::InlineSurface
Instance Method Summary collapse
- #addstr(_str) ⇒ Object
-
#attron(_style_or_attr) ⇒ Object
Apply a style around the block’s draws.
-
#erase ⇒ Object
Frame lifecycle: erase the buffer, widgets draw, then present flushes.
- #finalize ⇒ Object
- #present ⇒ Object
-
#read_key ⇒ Object
One integer key code, or nil if there was no input this cycle.
- #setpos(_row, _col) ⇒ Object
-
#size ⇒ Object
- rows, cols
-
of the drawable area.
-
#start ⇒ Object
Acquire / release the terminal.
Instance Method Details
#addstr(_str) ⇒ Object
27 28 29 |
# File 'lib/potty/surface.rb', line 27 def addstr(_str) raise NotImplementedError end |
#attron(_style_or_attr) ⇒ Object
Apply a style around the block’s draws. Accepts a Potty::Style or a raw integer (a legacy curses attribute) — see CursesSurface.
33 34 35 |
# File 'lib/potty/surface.rb', line 33 def attron(_style_or_attr) yield if block_given? end |
#erase ⇒ Object
Frame lifecycle: erase the buffer, widgets draw, then present flushes.
19 20 21 |
# File 'lib/potty/surface.rb', line 19 def erase raise NotImplementedError end |
#finalize ⇒ Object
16 |
# File 'lib/potty/surface.rb', line 16 def finalize; end |
#present ⇒ Object
37 38 39 |
# File 'lib/potty/surface.rb', line 37 def present raise NotImplementedError end |
#read_key ⇒ Object
One integer key code, or nil if there was no input this cycle.
42 43 44 |
# File 'lib/potty/surface.rb', line 42 def read_key nil end |
#setpos(_row, _col) ⇒ Object
23 24 25 |
# File 'lib/potty/surface.rb', line 23 def setpos(_row, _col) raise NotImplementedError end |
#size ⇒ Object
- rows, cols
-
of the drawable area.
10 11 12 |
# File 'lib/potty/surface.rb', line 10 def size raise NotImplementedError end |
#start ⇒ Object
Acquire / release the terminal.
15 |
# File 'lib/potty/surface.rb', line 15 def start; end |