Class: Rfd::MainWindow::Panes
- Inherits:
-
Object
- Object
- Rfd::MainWindow::Panes
- Defined in:
- lib/rfd/windows.rb
Instance Attribute Summary collapse
-
#current_index ⇒ Object
readonly
Returns the value of attribute current_index.
Instance Method Summary collapse
- #activate(index) ⇒ Object
- #active ⇒ Object
- #close_all ⇒ Object
- #get_index_by_point(y: nil, x: nil) ⇒ Object
- #include_point?(pane: pane, y: nil, x: nil) ⇒ Boolean
-
#initialize(panes) ⇒ Panes
constructor
A new instance of Panes.
- #size ⇒ Object
Constructor Details
#initialize(panes) ⇒ Panes
Returns a new instance of Panes.
117 118 119 |
# File 'lib/rfd/windows.rb', line 117 def initialize(panes) @panes, @current_index = panes, 0 end |
Instance Attribute Details
#current_index ⇒ Object (readonly)
Returns the value of attribute current_index.
115 116 117 |
# File 'lib/rfd/windows.rb', line 115 def current_index @current_index end |
Instance Method Details
#activate(index) ⇒ Object
125 126 127 |
# File 'lib/rfd/windows.rb', line 125 def activate(index) @current_index = index if index < @panes.size end |
#active ⇒ Object
121 122 123 |
# File 'lib/rfd/windows.rb', line 121 def active @panes[@current_index] end |
#close_all ⇒ Object
140 141 142 |
# File 'lib/rfd/windows.rb', line 140 def close_all @panes.each {|p| Curses.delwin p} end |
#get_index_by_point(y: nil, x: nil) ⇒ Object
129 130 131 132 133 134 |
# File 'lib/rfd/windows.rb', line 129 def get_index_by_point(y: nil, x: nil) @panes.each.with_index do |p, i| return i if include_point? pane: p, y: y, x: x end if y && x nil end |
#include_point?(pane: pane, y: nil, x: nil) ⇒ Boolean
144 145 146 |
# File 'lib/rfd/windows.rb', line 144 def include_point?(pane: pane, y: nil, x: nil) (y >= Curses.getbegy(pane)) && (Curses.getbegy(pane) + Curses.getmaxy(pane) > y) && (x >= Curses.getbegx(pane)) && (Curses.getbegx(pane) + Curses.getmaxx(pane) > x) end |
#size ⇒ Object
136 137 138 |
# File 'lib/rfd/windows.rb', line 136 def size @panes.size end |