def main(self) -> None: screen = Screen() screen.set_terminal_properties(colors=self.color_depth) self.loop = urwid.MainLoop(self.view, self.theme, screen=screen) self.update_pipe = self.loop.watch_pipe(self.draw_screen) # Register new ^C handler signal.signal(signal.SIGINT, self.exit_handler) try: # TODO: Enable resuming? (in which case, remove ^Z below) disabled_keys = { 'susp': 'undefined', # Disable ^Z - no suspending 'stop': 'undefined', # Disable ^S - enabling shortcut key use 'quit': 'undefined', # Disable ^\, ^4 } old_signal_list = screen.tty_signal_keys(**disabled_keys) self.loop.run() except Exception: self.restore_stdout() screen.tty_signal_keys(*old_signal_list) raise finally: self.restore_stdout() screen.tty_signal_keys(*old_signal_list)
def main(self) -> None: screen = Screen() screen.set_terminal_properties(colors=256) self.loop = urwid.MainLoop(self.view, self.theme, screen=screen) self.update_pipe = self.loop.watch_pipe(self.draw_screen) try: # TODO: Enable resuming? (in which case, remove ^Z below) disabled_keys = { 'susp': 'undefined', # Disable ^Z for suspending 'stop': 'undefined', # Disable ^S, enabling shortcut key use } old_signal_list = screen.tty_signal_keys(**disabled_keys) self.loop.run() except Exception: self.restore_stdout() screen.tty_signal_keys(*old_signal_list) raise finally: self.restore_stdout() screen.tty_signal_keys(*old_signal_list)