Class: Potty::WindowManager

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeWindowManager

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_xObject (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_yObject (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

#stdscrObject (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_allObject

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_dimensionsObject



21
22
23
24
# File 'lib/potty/window_manager.rb', line 21

def update_dimensions
  @max_y = @stdscr.maxy
  @max_x = @stdscr.maxx
end