From f9d09e7fad2b5e2243f9f335de73bfe44d44f720 Mon Sep 17 00:00:00 2001 From: phg Date: Fri, 4 Sep 2026 18:40:57 +0200 Subject: [PATCH] Refine entry search and field ordering --- src/hosts/tui/app.py | 16 ++++++++-------- src/hosts/tui/edit_handler.py | 14 ++++++-------- src/hosts/tui/styles.py | 8 ++++++++ src/hosts/tui/table_handler.py | 6 +++--- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/hosts/tui/app.py b/src/hosts/tui/app.py index 09d6013..7656d60 100644 --- a/src/hosts/tui/app.py +++ b/src/hosts/tui/app.py @@ -215,6 +215,14 @@ class HostsManagerApp(App): "DNS Name Entry", id="edit-dns-entry-radio" ) + with Vertical(classes="default-section") as hostnames: + hostnames.border_title = "Hostnames (comma-separated)" + yield Input( + placeholder="Enter hostnames", + id="hostname-input", + classes="default-input", + ) + with Vertical( classes="default-section", id="edit-ip-section" ) as ip_address: @@ -235,14 +243,6 @@ class HostsManagerApp(App): classes="default-input", ) - with Vertical(classes="default-section") as hostnames: - hostnames.border_title = "Hostnames (comma-separated)" - yield Input( - placeholder="Enter hostnames", - id="hostname-input", - classes="default-input", - ) - with Vertical(classes="default-section") as comment: comment.border_title = "Comment:" yield Input( diff --git a/src/hosts/tui/edit_handler.py b/src/hosts/tui/edit_handler.py index ff8b505..5e94121 100644 --- a/src/hosts/tui/edit_handler.py +++ b/src/hosts/tui/edit_handler.py @@ -425,9 +425,9 @@ class EditHandler: active_checkbox = self.app.query_one("#active-checkbox", Checkbox) # Build field list based on current entry type - fields = [radio_set] + fields = [radio_set, hostname_input] - # Add IP or DNS field based on visibility + # The address field follows Hostnames in the visual editor. try: ip_section = self.app.query_one("#edit-ip-section") if not ip_section.has_class("hidden"): @@ -444,8 +444,7 @@ class EditHandler: except Exception: pass - # Add remaining fields - fields.extend([hostname_input, comment_input, active_checkbox]) + fields.extend([comment_input, active_checkbox]) # Find currently focused field and move to next for i, field in enumerate(fields): @@ -471,9 +470,9 @@ class EditHandler: active_checkbox = self.app.query_one("#active-checkbox", Checkbox) # Build field list based on current entry type - fields = [radio_set] + fields = [radio_set, hostname_input] - # Add IP or DNS field based on visibility + # The address field follows Hostnames in the visual editor. try: ip_section = self.app.query_one("#edit-ip-section") if not ip_section.has_class("hidden"): @@ -490,8 +489,7 @@ class EditHandler: except Exception: pass - # Add remaining fields - fields.extend([hostname_input, comment_input, active_checkbox]) + fields.extend([comment_input, active_checkbox]) # Find currently focused field and move to previous for i, field in enumerate(fields): diff --git a/src/hosts/tui/styles.py b/src/hosts/tui/styles.py index f37bdeb..117e65d 100644 --- a/src/hosts/tui/styles.py +++ b/src/hosts/tui/styles.py @@ -132,6 +132,14 @@ HOSTS_MANAGER_CSS = ( border: none; } +#filter-summary { + width: auto; + height: 1; + padding: 0 1; + content-align: right middle; + color: $text-muted; +} + .hosts-container { height: 1fr; margin-top: 0; diff --git a/src/hosts/tui/table_handler.py b/src/hosts/tui/table_handler.py index bd2c391..1ec9da8 100644 --- a/src/hosts/tui/table_handler.py +++ b/src/hosts/tui/table_handler.py @@ -168,8 +168,8 @@ class TableHandler: arrow = "↑" if self.app.sort_ascending else "↓" hostname_label = f"{arrow} Canonical Hostname" - # Add columns with proper labels (Active, IP, Hostname, DNS) - table.add_columns(active_label, ip_label, hostname_label, dns_label) + # Keep the canonical hostname beside state for fast table scanning. + table.add_columns(active_label, hostname_label, ip_label, dns_label) # Get visible entries (after filtering) visible_entries = self.get_visible_entries() @@ -199,7 +199,7 @@ class TableHandler: active_text = Text("· Inactive", style="dim") ip_text = Text(entry.ip_address, style="dim") hostname_text = Text(canonical_hostname, style="dim") - table.add_row(active_text, ip_text, hostname_text, dns_text) + table.add_row(active_text, hostname_text, ip_text, dns_text) def restore_cursor_position(self, previous_entry) -> None: """Restore cursor position after reload, maintaining selection if possible."""