Refactor HostsManagerApp and keybindings: update footer item arrangement for better usability and modify key bindings to hide unused keys for a cleaner interface.
This commit is contained in:
parent
e8faa48e22
commit
c941a4ba24
2 changed files with 16 additions and 20 deletions
|
@ -53,7 +53,6 @@ class HostsManagerApp(App):
|
|||
def __init__(self):
|
||||
super().__init__()
|
||||
self.title = "/etc/hosts Manager"
|
||||
self.sub_title = "" # Will be set by update_status
|
||||
|
||||
# Initialize core components
|
||||
self.parser = HostsParser()
|
||||
|
@ -143,14 +142,16 @@ class HostsManagerApp(App):
|
|||
footer = self.query_one("#custom-footer", CustomFooter)
|
||||
|
||||
# Left section - common actions
|
||||
footer.add_left_item("q: Quit")
|
||||
footer.add_left_item("r: Reload")
|
||||
footer.add_left_item("?: Help")
|
||||
footer.add_right_item("^e: Edit Mode")
|
||||
footer.add_right_item("c: Config")
|
||||
footer.add_right_item("?: Help")
|
||||
footer.add_right_item("q: Quit")
|
||||
|
||||
# Right section - sort and edit actions
|
||||
footer.add_right_item("i: Sort IP")
|
||||
footer.add_right_item("n: Sort Host")
|
||||
footer.add_right_item("Ctrl+E: Edit Mode")
|
||||
footer.add_left_item("i: Sort IP")
|
||||
footer.add_left_item("n: Sort Host")
|
||||
footer.add_left_item("r: Reload")
|
||||
|
||||
|
||||
# Status section will be updated by update_status
|
||||
self._update_footer_status()
|
||||
|
@ -194,9 +195,7 @@ class HostsManagerApp(App):
|
|||
active_count = len(self.hosts_file.get_active_entries())
|
||||
|
||||
# Format: "29 entries (6 active) | Read-only mode"
|
||||
self.sub_title = f"{entry_count} entries ({active_count} active) | {mode}"
|
||||
|
||||
# Also update the footer status
|
||||
# Update the footer status
|
||||
self._update_footer_status()
|
||||
|
||||
def _clear_status_message(self) -> None:
|
||||
|
@ -325,7 +324,6 @@ class HostsManagerApp(App):
|
|||
success, message = self.manager.exit_edit_mode()
|
||||
if success:
|
||||
self.edit_mode = False
|
||||
self.sub_title = "Read-only mode"
|
||||
self.update_status(message)
|
||||
else:
|
||||
self.update_status(f"Error exiting edit mode: {message}")
|
||||
|
@ -334,7 +332,6 @@ class HostsManagerApp(App):
|
|||
success, message = self.manager.enter_edit_mode()
|
||||
if success:
|
||||
self.edit_mode = True
|
||||
self.sub_title = "Edit mode"
|
||||
self.update_status(message)
|
||||
elif "Password required" in message:
|
||||
# Show password modal
|
||||
|
@ -355,7 +352,6 @@ class HostsManagerApp(App):
|
|||
success, message = self.manager.enter_edit_mode(password)
|
||||
if success:
|
||||
self.edit_mode = True
|
||||
self.sub_title = "Edit mode"
|
||||
self.update_status(message)
|
||||
elif "Incorrect password" in message:
|
||||
# Show error and try again
|
||||
|
|
|
@ -9,13 +9,13 @@ from textual.binding import Binding
|
|||
|
||||
# Key bindings for the hosts manager application
|
||||
HOSTS_MANAGER_BINDINGS = [
|
||||
Binding("q", "quit", "Quit"),
|
||||
Binding("r", "reload", "Reload hosts file"),
|
||||
Binding("question_mark", "help", "Show help", True, key_display="?"),
|
||||
Binding("i", "sort_by_ip", "Sort by IP address"),
|
||||
Binding("n", "sort_by_hostname", "Sort by hostname"),
|
||||
Binding("c", "config", "Configuration"),
|
||||
Binding("ctrl+e", "toggle_edit_mode", "Toggle edit mode"),
|
||||
Binding("q", "quit", "Quit", show=False),
|
||||
Binding("r", "reload", "Reload hosts file", show=False),
|
||||
Binding("question_mark", "help", "Show help", True, key_display="?", show=False),
|
||||
Binding("i", "sort_by_ip", "Sort by IP address", show=False),
|
||||
Binding("n", "sort_by_hostname", "Sort by hostname", show=False),
|
||||
Binding("c", "config", "Configuration", show=False),
|
||||
Binding("ctrl+e", "toggle_edit_mode", "Toggle edit mode", show=False),
|
||||
Binding("a", "add_entry", "Add new entry", show=False),
|
||||
Binding("d", "delete_entry", "Delete entry", show=False),
|
||||
Binding("e", "edit_entry", "Edit entry", show=False),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue