From e857679ee6affccb25f9689ced4db2c7fc5cf521 Mon Sep 17 00:00:00 2001 From: Ben Connors Date: Mon, 9 Mar 2020 20:09:41 -0400 Subject: Improvements to interface - Somewhat ghetto solution to crashing when too small - Can now advance by just hitting enter --- interface/input/tabcomp.py | 15 +++++++++++++-- interface/interface.py | 11 +++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/interface/input/tabcomp.py b/interface/input/tabcomp.py index 7479f97..c454ad2 100755 --- a/interface/input/tabcomp.py +++ b/interface/input/tabcomp.py @@ -61,6 +61,13 @@ class Input: start = {} for i, f in ctx: + if not i: + if None in parent.children: + raise ValueError("Duplicate base command") + parent.children.append(None) + parent.f = f + continue + if isinstance(i, str): i = i.split(' ') if i[0] not in start: @@ -180,16 +187,20 @@ class Input: ## In the format: ## (input, parsed, display, is variable?) path = [["", True, "", False]] + size_ok = True while True: with self._ctx_lock: self._l1 = "".join((i[2] for i in path if i[2])) with CURSES_LOCK: - self._redraw() + if size_ok: + self._redraw() l = self.win.getch() with self._ctx_lock: if l == curses.KEY_RESIZE: if resize is not None: - resize() + size_ok = resize() + continue + if not size_ok: continue if self._context is None: continue diff --git a/interface/interface.py b/interface/interface.py index 3572bbe..0586f16 100644 --- a/interface/interface.py +++ b/interface/interface.py @@ -60,8 +60,14 @@ class Interface: def _resize(self): ## FIXME - self._actual_resize() - self._actual_resize() + try: + self._actual_resize() + self._actual_resize() + except: + self.stdscr.addstr(0, 0, "Too small") + self.stdscr.refresh() + return False + return True def _actual_resize(self): for (a1, a2), (f1, f2) in zip(self._compute_sizes(*self.stdscr.getmaxyx()), ((self.channel_bank.set_dim, self.channel_bank.set_pos), (self.input.set_dim, self.input.set_pos), (self.pager.set_dim, self.pager.set_pos), *((c.set_dim, c.set_pos) for c in self.chaser_views))): @@ -938,6 +944,7 @@ class Interface: ("advance $num", lambda n: self.run_jump(n, None, False)), ("advance", lambda: self.run_jump(0, None, True)), ("badvance", lambda: self.run_jump(1, None, True)), + ("", lambda: self.run_jump(0, None, True)), ("everythingadvance", self.run_advance_all), -- cgit v1.2.3