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.



141
142
143
# File 'lib/rfd/windows.rb', line 141

def initialize(panes)
  @panes, @current_index = panes, 0
end

Instance Attribute Details

#current_indexObject (readonly)

Returns the value of attribute current_index.



139
140
141
# File 'lib/rfd/windows.rb', line 139

def current_index
  @current_index
end

Instance Method Details

#activate(index) ⇒ Object



149
150
151
# File 'lib/rfd/windows.rb', line 149

def activate(index)
  @current_index = index if index < @panes.size
end

#activeObject



145
146
147
# File 'lib/rfd/windows.rb', line 145

def active
  @panes[@current_index]
end

#close_allObject



164
165
166
167
168
169
# File 'lib/rfd/windows.rb', line 164

def close_all
  @panes.each do |p|
    p.clear
    p.close
  end
end

#get_index_by_point(y: nil, x: nil) ⇒ Object



153
154
155
156
157
158
# File 'lib/rfd/windows.rb', line 153

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)


171
172
173
# File 'lib/rfd/windows.rb', line 171

def include_point?(pane: pane, y: nil, x: nil)
  (y >= pane.begy) && (pane.begy + pane.maxy > y) && (x >= pane.begx) && (pane.begx + pane.maxx > x)
end

#sizeObject



160
161
162
# File 'lib/rfd/windows.rb', line 160

def size
  @panes.size
end