class Rfd::MainWindow
Attributes
begy[R]
current_index[R]
number_of_panes[W]
Public Class Methods
new()
click to toggle source
Calls superclass method
Rfd::Window::new
# File lib/rfd/windows.rb, line 84 def initialize @begy, @current_index, @number_of_panes = 5, 0, 2 super window: Curses::Pad.new(Curses.lines - 7, Curses.cols - 2) end
Public Instance Methods
activate_pane(num)
click to toggle source
# File lib/rfd/windows.rb, line 102 def activate_pane(num) @current_index = num end
display(page)
click to toggle source
# File lib/rfd/windows.rb, line 98 def display(page) noutrefresh 0, (Curses.cols - 2) * page, begy, 1, begy + maxy - 1, Curses.cols - 2 end
draw_item(item, current: false)
click to toggle source
# File lib/rfd/windows.rb, line 118 def draw_item(item, current: false) setpos item.index % maxy, width * @current_index attron(Curses.color_pair(item.color) | (current ? Curses::A_UNDERLINE : Curses::A_NORMAL)) do self << item.to_s end end
draw_items_to_each_pane(items)
click to toggle source
# File lib/rfd/windows.rb, line 125 def draw_items_to_each_pane(items) items.each_slice(maxy).each.with_index do |arr, col_index| arr.each.with_index do |item, i| setpos i, width * col_index attron(Curses.color_pair(item.color) | Curses::A_NORMAL) { self << item.to_s } end end end
max_items()
click to toggle source
# File lib/rfd/windows.rb, line 114 def max_items maxy * @number_of_panes end
newpad(items)
click to toggle source
# File lib/rfd/windows.rb, line 89 def newpad(items) clear columns = items.size / maxy + 1 newx = width * (((columns - 1) / @number_of_panes + 1) * @number_of_panes) resize maxy, newx if newx != maxx draw_items_to_each_pane items end
pane_index_at(y: nil, x: nil)
click to toggle source
# File lib/rfd/windows.rb, line 106 def pane_index_at(y: nil, x: nil) (y >= begy) && (begy + maxy > y) && (x / width) end
toggle_mark(item)
click to toggle source
# File lib/rfd/windows.rb, line 134 def toggle_mark(item) item.toggle_mark end
width()
click to toggle source
# File lib/rfd/windows.rb, line 110 def width (Curses.cols - 2) / @number_of_panes end