From 116752135566e7732db1907ed7fdff159b5208db Mon Sep 17 00:00:00 2001 From: phg Date: Wed, 30 Jul 2025 16:17:01 +0200 Subject: [PATCH] Refactor status handling: remove status bar widget and update to use footer subtitle for status messages --- src/hosts/tui/app.py | 25 +++++-------------------- src/hosts/tui/styles.py | 17 ----------------- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/src/hosts/tui/app.py b/src/hosts/tui/app.py index 6ce6bdb..4309555 100644 --- a/src/hosts/tui/app.py +++ b/src/hosts/tui/app.py @@ -87,9 +87,6 @@ class HostsManagerApp(App): yield Input(placeholder="Enter comment (optional)", id="comment-input") yield Checkbox("Active", id="active-checkbox") - # Status bar - yield Static("", id="status", classes="status-bar") - def on_ready(self) -> None: """Called when the app is ready.""" self.load_hosts_file() @@ -114,30 +111,18 @@ class HostsManagerApp(App): self.update_status(f"❌ Error loading hosts file: {e}") def update_status(self, message: str = "") -> None: - """Update the status bar.""" - status_widget = self.query_one("#status", Static) - + """Update the footer subtitle with status information.""" if message: - # Check if this is an error message (starts with ❌) + # Set temporary status message + self.sub_title = message if message.startswith("❌"): - # Use error styling for error messages - status_widget.remove_class("status-bar") - status_widget.add_class("status-error") - status_widget.update(message) # Auto-clear error message after 5 seconds self.set_timer(5.0, lambda: self.update_status()) else: - # Use normal styling for regular messages - status_widget.remove_class("status-error") - status_widget.add_class("status-bar") - status_widget.update(message) - # Auto-clear regular message after 3 seconds + # Auto-clear regular message after 3 seconds self.set_timer(3.0, lambda: self.update_status()) else: # Reset to normal status display - status_widget.remove_class("status-error") - status_widget.add_class("status-bar") - mode = "Edit mode" if self.edit_mode else "Read-only mode" entry_count = len(self.hosts_file.entries) active_count = len(self.hosts_file.get_active_entries()) @@ -149,7 +134,7 @@ class HostsManagerApp(App): if file_info["exists"]: status_text += f" | {file_info['path']}" - status_widget.update(status_text) + self.sub_title = status_text # Event handlers def on_data_table_row_highlighted(self, event: DataTable.RowHighlighted) -> None: diff --git a/src/hosts/tui/styles.py b/src/hosts/tui/styles.py index 2b39cc1..3b2551e 100644 --- a/src/hosts/tui/styles.py +++ b/src/hosts/tui/styles.py @@ -34,23 +34,6 @@ HOSTS_MANAGER_CSS = """ text-style: italic; } -.status-bar { - background: $surface; - color: $text; - height: 1; - padding: 0 1; - dock: bottom; -} - -.status-error { - background: $error; - color: $text; - height: 1; - padding: 0 1; - text-style: bold; - dock: bottom; -} - /* DataTable styling to match background */ #entries-table { background: $background;