From 4726a5a281030771672cf6168bd620a3b1d55885 Mon Sep 17 00:00:00 2001 From: dece Date: Sun, 16 May 2021 17:24:17 +0200 Subject: [PATCH] command_line: fix nodelay mode reset --- bebop/browser/browser.py | 2 +- bebop/command_line.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bebop/browser/browser.py b/bebop/browser/browser.py index 9383ede..c7d8ae4 100644 --- a/bebop/browser/browser.py +++ b/bebop/browser/browser.py @@ -217,6 +217,7 @@ class Browser: elif char == curses.ascii.ESC: # Can be ESC or ALT char. self.screen.nodelay(True) char = self.screen.getch() + self.screen.nodelay(False) if char == -1: self.reset_status() else: # ALT keybinds. @@ -228,7 +229,6 @@ class Browser: self.scroll_page_vertically(-1) elif char == ord("l"): self.scroll_page_horizontally(1) - self.screen.nodelay(False) # elif char == ord("@"): # self.current_url = "bebop:debugzone" # t = "\n".join("* " + u for u in self.history.urls) diff --git a/bebop/command_line.py b/bebop/command_line.py index 34be040..56f654e 100644 --- a/bebop/command_line.py +++ b/bebop/command_line.py @@ -4,6 +4,7 @@ import curses import curses.ascii import curses.textpad import os +import logging import tempfile from typing import Optional @@ -108,12 +109,12 @@ class CommandLine: elif ch == curses.ascii.ESC: # Could be ESC or ALT self.window.nodelay(True) ch = self.window.getch() + self.window.nodelay(False) if ch == -1: raise EscapeCommandInterrupt() else: # ALT keybinds. if ch == ord("e"): self.open_editor(self.gather()) - self.window.nodelay(False) return ch def focus_for_link_navigation(self, init_char: int, links: Links): @@ -194,6 +195,7 @@ class CommandLine: temp_file.write(existing_content) temp_filepath = temp_file.name except OSError: + logging.error("Could not open or write to temporary file.") return command = self.editor_command + [temp_filepath] @@ -204,6 +206,7 @@ class CommandLine: content = temp_file.read().rstrip("\r\n") os.unlink(temp_filepath) except OSError: + logging.error("Could not read temporary file after user edition.") return raise TerminateCommandInterrupt(content)