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.
149
150
151
152
153
154
155
|
# File 'lib/rfd/windows.rb', line 149
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
165
166
167
|
# File 'lib/rfd/windows.rb', line 165
def activate_pane(num)
@panes.activate num
end
|
#draw_item(item, current: false) ⇒ Object
181
182
183
184
185
186
|
# File 'lib/rfd/windows.rb', line 181
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/rfd/windows.rb', line 188
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
177
178
179
|
# File 'lib/rfd/windows.rb', line 177
def max_items
maxy * @panes.size
end
|
#pane_index_at(y: nil, x: nil) ⇒ Object
169
170
171
|
# File 'lib/rfd/windows.rb', line 169
def pane_index_at(y: nil, x: nil)
@panes.get_index_by_point y: y, x: x
end
|
#spawn_panes(num) ⇒ Object
157
158
159
160
161
162
163
|
# File 'lib/rfd/windows.rb', line 157
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
205
206
207
|
# File 'lib/rfd/windows.rb', line 205
def toggle_mark(item)
mvwaddstr item.index % maxy, 0, item.current_mark if item.toggle_mark
end
|
#window ⇒ Object
173
174
175
|
# File 'lib/rfd/windows.rb', line 173
def window
@panes.active
end
|