Class: Potty::WindowManager
- Inherits:
-
Object
- Object
- Potty::WindowManager
- Defined in:
- lib/potty/window_manager.rb
Overview
Holds the curses stdscr and screen dimensions, and batches the refresh (noutrefresh + doupdate). Backs CursesSurface.
Instance Attribute Summary collapse
-
#max_x ⇒ Object
readonly
Returns the value of attribute max_x.
-
#max_y ⇒ Object
readonly
Returns the value of attribute max_y.
-
#stdscr ⇒ Object
readonly
Returns the value of attribute stdscr.
Instance Method Summary collapse
-
#initialize ⇒ WindowManager
constructor
A new instance of WindowManager.
-
#refresh_all ⇒ Object
Flush buffered drawing to the screen.
-
#setup(stdscr) ⇒ Object
Called during application setup.
- #update_dimensions ⇒ Object
Constructor Details
#initialize ⇒ WindowManager
Returns a new instance of WindowManager.
11 12 13 |
# File 'lib/potty/window_manager.rb', line 11 def initialize @stdscr = nil end |
Instance Attribute Details
#max_x ⇒ Object (readonly)
Returns the value of attribute max_x.
9 10 11 |
# File 'lib/potty/window_manager.rb', line 9 def max_x @max_x end |
#max_y ⇒ Object (readonly)
Returns the value of attribute max_y.
9 10 11 |
# File 'lib/potty/window_manager.rb', line 9 def max_y @max_y end |
#stdscr ⇒ Object (readonly)
Returns the value of attribute stdscr.
9 10 11 |
# File 'lib/potty/window_manager.rb', line 9 def stdscr @stdscr end |
Instance Method Details
#refresh_all ⇒ Object
Flush buffered drawing to the screen.
27 28 29 30 |
# File 'lib/potty/window_manager.rb', line 27 def refresh_all @stdscr.noutrefresh ::Curses.doupdate end |
#setup(stdscr) ⇒ Object
Called during application setup.
16 17 18 19 |
# File 'lib/potty/window_manager.rb', line 16 def setup(stdscr) @stdscr = stdscr update_dimensions end |
#update_dimensions ⇒ Object
21 22 23 24 |
# File 'lib/potty/window_manager.rb', line 21 def update_dimensions @max_y = @stdscr.maxy @max_x = @stdscr.maxx end |