command_line: fix nodelay mode reset
This commit is contained in:
parent
a65f7ceb39
commit
4726a5a281
|
@ -217,6 +217,7 @@ class Browser:
|
||||||
elif char == curses.ascii.ESC: # Can be ESC or ALT char.
|
elif char == curses.ascii.ESC: # Can be ESC or ALT char.
|
||||||
self.screen.nodelay(True)
|
self.screen.nodelay(True)
|
||||||
char = self.screen.getch()
|
char = self.screen.getch()
|
||||||
|
self.screen.nodelay(False)
|
||||||
if char == -1:
|
if char == -1:
|
||||||
self.reset_status()
|
self.reset_status()
|
||||||
else: # ALT keybinds.
|
else: # ALT keybinds.
|
||||||
|
@ -228,7 +229,6 @@ class Browser:
|
||||||
self.scroll_page_vertically(-1)
|
self.scroll_page_vertically(-1)
|
||||||
elif char == ord("l"):
|
elif char == ord("l"):
|
||||||
self.scroll_page_horizontally(1)
|
self.scroll_page_horizontally(1)
|
||||||
self.screen.nodelay(False)
|
|
||||||
# elif char == ord("@"):
|
# elif char == ord("@"):
|
||||||
# self.current_url = "bebop:debugzone"
|
# self.current_url = "bebop:debugzone"
|
||||||
# t = "\n".join("* " + u for u in self.history.urls)
|
# t = "\n".join("* " + u for u in self.history.urls)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import curses
|
||||||
import curses.ascii
|
import curses.ascii
|
||||||
import curses.textpad
|
import curses.textpad
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
@ -108,12 +109,12 @@ class CommandLine:
|
||||||
elif ch == curses.ascii.ESC: # Could be ESC or ALT
|
elif ch == curses.ascii.ESC: # Could be ESC or ALT
|
||||||
self.window.nodelay(True)
|
self.window.nodelay(True)
|
||||||
ch = self.window.getch()
|
ch = self.window.getch()
|
||||||
|
self.window.nodelay(False)
|
||||||
if ch == -1:
|
if ch == -1:
|
||||||
raise EscapeCommandInterrupt()
|
raise EscapeCommandInterrupt()
|
||||||
else: # ALT keybinds.
|
else: # ALT keybinds.
|
||||||
if ch == ord("e"):
|
if ch == ord("e"):
|
||||||
self.open_editor(self.gather())
|
self.open_editor(self.gather())
|
||||||
self.window.nodelay(False)
|
|
||||||
return ch
|
return ch
|
||||||
|
|
||||||
def focus_for_link_navigation(self, init_char: int, links: Links):
|
def focus_for_link_navigation(self, init_char: int, links: Links):
|
||||||
|
@ -194,6 +195,7 @@ class CommandLine:
|
||||||
temp_file.write(existing_content)
|
temp_file.write(existing_content)
|
||||||
temp_filepath = temp_file.name
|
temp_filepath = temp_file.name
|
||||||
except OSError:
|
except OSError:
|
||||||
|
logging.error("Could not open or write to temporary file.")
|
||||||
return
|
return
|
||||||
|
|
||||||
command = self.editor_command + [temp_filepath]
|
command = self.editor_command + [temp_filepath]
|
||||||
|
@ -204,6 +206,7 @@ class CommandLine:
|
||||||
content = temp_file.read().rstrip("\r\n")
|
content = temp_file.read().rstrip("\r\n")
|
||||||
os.unlink(temp_filepath)
|
os.unlink(temp_filepath)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
logging.error("Could not read temporary file after user edition.")
|
||||||
return
|
return
|
||||||
raise TerminateCommandInterrupt(content)
|
raise TerminateCommandInterrupt(content)
|
||||||
|
|
||||||
|
|
Reference in a new issue