Class: Dcha::UI::Window
- Inherits:
-
Curses::Window
- Object
- Curses::Window
- Dcha::UI::Window
- Defined in:
- lib/dcha/ui/window.rb
Overview
:nodoc:
Instance Method Summary collapse
- #heading=(head) ⇒ Object
-
#initialize ⇒ Window
constructor
A new instance of Window.
-
#peers=(peers) ⇒ Object
TODO: Cut off string if overflow.
- #update(&_block) ⇒ Object
Constructor Details
#initialize ⇒ Window
Returns a new instance of Window.
5 6 7 8 9 10 |
# File 'lib/dcha/ui/window.rb', line 5 def initialize(*) super = subwin(maxy - 2, maxx * 0.3, 0, 0) @input = subwin(3, 0, maxy - 3, 0) end |
Instance Method Details
#heading=(head) ⇒ Object
21 22 23 24 |
# File 'lib/dcha/ui/window.rb', line 21 def heading=(head) @input.setpos(1, 1) @input.addstr(head) end |
#peers=(peers) ⇒ Object
TODO: Cut off string if overflow
27 28 29 30 31 32 33 34 |
# File 'lib/dcha/ui/window.rb', line 27 def peers=(peers) peers = peers.take(maxy - 5) peers.push('And more ...') if peers.size == maxy - 5 peers.each.with_index do |peer, index| .setpos(index + 1, 2) .addstr(peer) end end |
#update(&_block) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/dcha/ui/window.rb', line 12 def update(&_block) clear box('|', '-') update_input yield if block_given? refresh end |