diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-08-12 23:08:29 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-08-12 23:08:29 +0200 |
commit | 246af172cc61ceb5e81cd7f5c058e3a1fd0645bc (patch) | |
tree | 73cee56198f75660a29f17e23641b83a984c13a1 | |
parent | 5c0239a48c8d4dafcdf5797f703e8b8ac3991b5f (diff) |
Handle out of bounds selection in inter.py better
-rw-r--r-- | inter.py | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -51,10 +51,15 @@ def mainloop(): global sel, menu while True: update() - if len([inps, sinks][sel[0]]) == 0 and len([sinks, inps][sel[0]]) != 0: + selected_things = [inps, sinks][sel[0]] + other_things = [sinks, inps][sel[0]] + if len(selected_things) == 0 and len(other_things) != 0: sel = (1 - sel[0], sel[1]) redraw() + if sel[1] < 0 or sel[1] >= len(selected_things): + sel = (sel[0], 0) + key = T.tgetkey() if menu != MENU_MAIN and (key == T.KEY_ESC or key == ord('q')): |