commit 25df46911d2ac5d09cc9d24feece38828a2ca48c Author: Sambuddha Basu <sambuddhaba...@gmail.com> Date: Sat May 7 01:43:03 2016 +0400
Added checkboxes for selected events --- nyx/popups.py | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/nyx/popups.py b/nyx/popups.py index f0d4050..a146d47 100644 --- a/nyx/popups.py +++ b/nyx/popups.py @@ -418,17 +418,49 @@ def select_event_types(): def new_select_event_types(): + + selection = 0 + selected_events = [] + def _render(subwindow): subwindow.box() subwindow.addstr(0, 0, 'Event Types:', HIGHLIGHT) events = nyx.tor_controller().get_info('events/names', None) - for i, line in enumerate(events.split()): - subwindow.addstr(1, i + 1, line) + + if events: + events = events.split() + events = [events[i:i + 3] for i in xrange(0, len(events), 3)] + + for i, line in enumerate(events): + for j, in_line in enumerate(line): + x = subwindow.addstr(j * 30 + 1, i + 1, '[X]' if (i * 3 + j) in selected_events else '[]') + x = subwindow.addstr(x, i + 1, in_line, HIGHLIGHT if selection == (i * 3 + j) else NORMAL) with nyx.curses.CURSES_LOCK: - nyx.curses.draw(_render, top = _top(), width = 80, height = 16) - return None + events = nyx.tor_controller().get_info('events/names', None) + if events: + events = events.split() + while True: + nyx.curses.draw(_render, top = _top(), width = 80, height = 16) + key = nyx.curses.key_input() + + if key.match('up'): + selection = max(0, selection - 3) + elif key.match('down'): + selection = min(len(events) - 1, selection + 3) + elif key.match('left'): + selection = max(0, selection - 1) + elif key.match('right'): + selection = min(len(events) - 1, selection + 1) + elif key.is_selection(): + if selection in selected_events: + selected_events.remove(selection) + else: + selected_events.append(selection) + elif key.match('esc'): + return None + def confirm_save_torrc(torrc): """ _______________________________________________ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits