browser: capture C-c
This commit is contained in:
parent
398f526b82
commit
2db721d48a
|
@ -69,13 +69,17 @@ class Browser:
|
|||
self.open_url(start_url, assume_absolute=True)
|
||||
|
||||
while self.running:
|
||||
try:
|
||||
self.handle_inputs()
|
||||
except KeyboardInterrupt:
|
||||
self.set_status("Cancelled.")
|
||||
|
||||
def handle_inputs(self):
|
||||
char = self.screen.getch()
|
||||
if char == ord(":"):
|
||||
self.quick_command("")
|
||||
elif char == ord("r"):
|
||||
self.reload_page()
|
||||
elif char == ord("s"):
|
||||
self.set_status(f"h {self.h} w {self.w}")
|
||||
elif char == ord("h"):
|
||||
self.scroll_page_horizontally(-1)
|
||||
elif char == ord("H"):
|
||||
|
@ -112,6 +116,14 @@ class Browser:
|
|||
self.handle_mouse(*curses.getmouse())
|
||||
elif char == curses.KEY_RESIZE:
|
||||
self.handle_resize()
|
||||
elif char == curses.ascii.ESC: # Can be ESC or ALT char.
|
||||
self.screen.nodelay(True)
|
||||
ch = self.screen.getch()
|
||||
if ch == -1:
|
||||
self.set_status(self.current_url)
|
||||
else:
|
||||
pass # No alt-key shortcuts for now!
|
||||
self.screen.nodelay(False)
|
||||
|
||||
@property
|
||||
def page_pad_size(self):
|
||||
|
@ -244,6 +256,9 @@ class Browser:
|
|||
self.set_status_error(error)
|
||||
elif response.generic_code == 10:
|
||||
self.handle_input_request(url, response)
|
||||
else:
|
||||
error = f"Unhandled response code {response.code}"
|
||||
self.set_status_error(error)
|
||||
|
||||
def load_page(self, gemtext: bytes):
|
||||
"""Load Gemtext data as the current page."""
|
||||
|
|
Reference in a new issue