diff --git a/src/hosts/main.py b/src/hosts/main.py index 9d8bb97..81b30dd 100644 --- a/src/hosts/main.py +++ b/src/hosts/main.py @@ -9,6 +9,7 @@ from textual.containers import Horizontal, Vertical from textual.widgets import Header, Footer, Static, DataTable from textual.binding import Binding from textual.reactive import reactive +from rich.text import Text from .core.parser import HostsParser from .core.models import HostsFile @@ -73,6 +74,8 @@ class HostsManagerApp(App): #entries-table .datatable--odd-row { background: $surface; } + + /* DataTable row styling - colors are now handled via Rich Text objects */ """ BINDINGS = [ @@ -180,10 +183,15 @@ class HostsManagerApp(App): # Add row with styling based on active status if entry.is_active: - table.add_row(entry.ip_address, canonical_hostname) + # Active entries in green + ip_text = Text(entry.ip_address, style="green") + hostname_text = Text(canonical_hostname, style="green") + table.add_row(ip_text, hostname_text) else: - # For inactive entries, we'll style them differently - table.add_row(f"# {entry.ip_address}", canonical_hostname) + # Inactive entries in yellow/orange with # prefix and italic + ip_text = Text(f"# {entry.ip_address}", style="yellow italic") + hostname_text = Text(canonical_hostname, style="yellow italic") + table.add_row(ip_text, hostname_text) def restore_cursor_position(self, previous_entry) -> None: """Restore cursor position after reload, maintaining selection if possible."""