Class: Rfd::MainWindow::Panes

Inherits:
Object
  • Object
show all
Defined in:
lib/rfd/windows.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_indexObject (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

#activeObject



121
122
123
# File 'lib/rfd/windows.rb', line 121

def active
  @panes[@current_index]
end

#close_allObject



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

Returns:

  • (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

#sizeObject



136
137
138
# File 'lib/rfd/windows.rb', line 136

def size
  @panes.size
end