summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2015-11-13 14:36:12 -0800
committerAndy Grover <agrover@redhat.com>2015-11-13 14:36:12 -0800
commita9c50f07d6608b08e4a59fdad1be61d79b6454c9 (patch)
tree21b33992183a58b6f947ea7f112aa340cb26e2cb
parent1eb29bb40fe86f8882591e8c5387e0903c1343be (diff)
downloadconfigshell-fb-a9c50f07d6608b08e4a59fdad1be61d79b6454c9.tar.gz
Handle getting urwid focus position better
Experiencing weirdness when MainLoop is not broken out of with an ExitMainLoop exception. Change handler to do this, and then get the current focus position using the listbox.focus_position property. Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r--configshell/node.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/configshell/node.py b/configshell/node.py
index 591bbdc..848c667 100644
--- a/configshell/node.py
+++ b/configshell/node.py
@@ -1061,9 +1061,6 @@ class ConfigNode(object):
'''
import urwid
- class Selected(Exception):
- pass
-
palette = [('header', 'white', 'black'),
('reveal focus', 'black', 'yellow', 'standout')]
@@ -1086,14 +1083,12 @@ class ConfigNode(object):
except IndexError:
pass
elif key == 'enter':
- raise Selected(pos)
+ raise urwid.ExitMainLoop()
content.set_focus(start_pos)
loop = urwid.MainLoop(frame, palette, input_filter=handle_input)
- try:
- loop.run()
- except Selected as pos:
- return int(str(pos))
+ loop.run()
+ return listbox.focus_position
def ui_complete_cd(self, parameters, text, current_param):
'''