From 4da3081ef6346ac792dff0226fa9e749464f3558 Mon Sep 17 00:00:00 2001 From: dece Date: Mon, 31 May 2021 17:43:37 +0200 Subject: [PATCH] browser: avoid crash if mouse support is off --- bebop/browser/browser.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bebop/browser/browser.py b/bebop/browser/browser.py index 413c7ba..724a1fa 100644 --- a/bebop/browser/browser.py +++ b/bebop/browser/browser.py @@ -130,7 +130,9 @@ class Browser: self.screen.clear() self.screen.refresh() - curses.mousemask(curses.ALL_MOUSE_EVENTS) + mousemask = curses.mousemask(curses.ALL_MOUSE_EVENTS) + if mousemask == 0: + logging.error("Could not enable mouse support.") curses.curs_set(0) init_colors() @@ -233,7 +235,10 @@ class Browser: elif curses.ascii.isdigit(char): self.handle_digit_input(char) elif char == curses.KEY_MOUSE: - self.handle_mouse(*curses.getmouse()) + try: + self.handle_mouse(*curses.getmouse()) + except curses.error: + pass elif char == curses.KEY_RESIZE: self.handle_resize() elif char == curses.ascii.ESC: # Can be ESC or ALT char.