command_line: fix nodelay mode reset

exec
dece 3 years ago
parent a65f7ceb39
commit 4726a5a281

@ -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)

@ -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)

Loading…
Cancel
Save