Class: Rfd::MainWindow
Defined Under Namespace
Classes: Panes
Instance Method Summary
collapse
Methods inherited from Window
#begx, #begy, #draw_border, #maxx, #maxy, #mvwaddstr, #subwin, #waddstr, #wclear, #wclrtoeol, #wmove, #wrefresh
Constructor Details
#initialize(dir = '.') ⇒ MainWindow
Returns a new instance of MainWindow.
152
153
154
155
156
157
158
|
# File 'lib/rfd/windows.rb', line 152
def initialize(dir = '.')
border_window = subwin Curses.LINES - 5, Curses.COLS, 4, 0
Curses.wbkgd border_window, Curses::COLOR_PAIR(Curses::COLOR_CYAN)
Curses.box border_window, 0, 0
spawn_panes 2
end
|
Instance Method Details
#activate_pane(num) ⇒ Object
168
169
170
|
# File 'lib/rfd/windows.rb', line 168
def activate_pane(num)
@panes.activate num
end
|
#draw_item(item, current: false) ⇒ Object
184
185
186
187
188
189
|
# File 'lib/rfd/windows.rb', line 184
def draw_item(item, current: false)
Curses.wattr_set window, current ? Curses::A_UNDERLINE : Curses::A_NORMAL, item.color, nil
mvwaddstr item.index % maxy, 0, "#{item.to_s}\n"
Curses.wstandend window
wrefresh
end
|
#draw_items_to_each_pane(items) ⇒ Object
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
# File 'lib/rfd/windows.rb', line 191
def draw_items_to_each_pane(items)
original_active_pane_index = @panes.current_index
0.upto(@panes.size - 1) do |index|
activate_pane index
wclear
wmove 0
items[maxy * index, maxy * (index + 1)].each do |item|
Curses.wattr_set window, Curses::A_NORMAL, item.color, nil
waddstr "#{item.to_s}\n"
end if items[maxy * index, maxy * (index + 1)]
Curses.wstandend window
wrefresh
end
activate_pane original_active_pane_index
end
|
#max_items ⇒ Object
180
181
182
|
# File 'lib/rfd/windows.rb', line 180
def max_items
maxy * @panes.size
end
|
#pane_index_at(y: nil, x: nil) ⇒ Object
172
173
174
|
# File 'lib/rfd/windows.rb', line 172
def pane_index_at(y: nil, x: nil)
@panes.get_index_by_point y: y, x: x
end
|
#spawn_panes(num) ⇒ Object
160
161
162
163
164
165
166
|
# File 'lib/rfd/windows.rb', line 160
def spawn_panes(num)
@panes.close_all if defined? @panes
width = (Curses.COLS - 2) / num
windows = 0.upto(num - 1).inject([]) {|arr, i| arr << subwin(Curses.LINES - 7, width - 1, 5, width * i + 1)}
@panes = Panes.new windows
activate_pane 0
end
|
#toggle_mark(item) ⇒ Object
208
209
210
|
# File 'lib/rfd/windows.rb', line 208
def toggle_mark(item)
mvwaddstr item.index % maxy, 0, item.current_mark if item.toggle_mark
end
|
#window ⇒ Object
176
177
178
|
# File 'lib/rfd/windows.rb', line 176
def window
@panes.active
end
|