[tor-commits] [nyx/master] Added Ok and Cancel for selecting events

atagar at torproject.org atagar at torproject.org
Sun May 15 05:37:21 UTC 2016


commit aa0dfe24e0a60832940a02f0084f7eb340fd8ede
Author: Sambuddha Basu <sambuddhabasu1 at gmail.com>
Date:   Sun May 8 01:32:54 2016 +0400

    Added Ok and Cancel for selecting events
---
 nyx/popups.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/nyx/popups.py b/nyx/popups.py
index a146d47..f4be35d 100644
--- a/nyx/popups.py
+++ b/nyx/popups.py
@@ -430,13 +430,19 @@ def new_select_event_types():
 
     if events:
       events = events.split()
-      events = [events[i:i + 3] for i in xrange(0, len(events), 3)]
+      tor_events = [events[i:i + 3] for i in xrange(0, len(events), 3)]
 
-      for i, line in enumerate(events):
+      for i, line in enumerate(tor_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)
 
+      x = 30
+      for i, line in enumerate(['Ok', 'Cancel']):
+        x = subwindow.addstr(x, len(tor_events) + 2, '[')
+        x = subwindow.addstr(x, len(tor_events) + 2, line, HIGHLIGHT if selection == (len(events) + i) else NORMAL)
+        x = subwindow.addstr(x, len(tor_events) + 2, ']')
+
   with nyx.curses.CURSES_LOCK:
     events = nyx.tor_controller().get_info('events/names', None)
     if events:
@@ -448,14 +454,18 @@ def new_select_event_types():
         if key.match('up'):
           selection = max(0, selection - 3)
         elif key.match('down'):
-          selection = min(len(events) - 1, selection + 3)
+          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)
+          selection = min(len(events) + 1, selection + 1)
         elif key.is_selection():
           if selection in selected_events:
             selected_events.remove(selection)
+          elif selection == len(events):
+            return set([events[i] for i in selected_events])
+          elif selection == (len(events) + 1):
+            return None
           else:
             selected_events.append(selection)
         elif key.match('esc'):





More information about the tor-commits mailing list