browser: quit with ":quit" instead of pressing q

This commit is contained in:
dece 2021-02-28 18:51:15 +01:00
parent 33b1e497af
commit 62619f29fb

View file

@ -27,6 +27,7 @@ class Browser:
self.command_line = None self.command_line = None
self.status_data = ("", 0) self.status_data = ("", 0)
self.current_url = "" self.current_url = ""
self.running = True
self.history = History() self.history = History()
@property @property
@ -65,16 +66,13 @@ class Browser:
self.command_line = CommandLine(command_line_window) self.command_line = CommandLine(command_line_window)
pending_url = start_url pending_url = start_url
running = True while self.running:
while running:
if pending_url: if pending_url:
self.open_url(pending_url) self.open_url(pending_url)
pending_url = None pending_url = None
char = self.screen.getch() char = self.screen.getch()
if char == ord("q"): if char == ord(":"):
running = False
elif char == ord(":"):
self.quick_command("") self.quick_command("")
elif char == ord("r"): elif char == ord("r"):
self.reload_page() self.reload_page()
@ -297,8 +295,10 @@ class Browser:
def process_command(self, command_text: str): def process_command(self, command_text: str):
words = command_text.split() words = command_text.split()
command = words[0] command = words[0]
if command == "open": if command in ("o", "open"):
self.open_url(words[1], assume_absolute=True) self.open_url(words[1], assume_absolute=True)
elif command in ("q", "quit"):
self.running = False
def handle_digit_input(self, init_char: int): def handle_digit_input(self, init_char: int):
"""Handle a initial digit input by the user. """Handle a initial digit input by the user.