71 lines
2.5 KiB
Python
71 lines
2.5 KiB
Python
"""Dedicated keyboard reference overlay."""
|
|
|
|
from textual.app import ComposeResult
|
|
from textual.binding import Binding
|
|
from textual.containers import Vertical
|
|
from textual.screen import ModalScreen
|
|
from textual.widgets import Button, Static
|
|
|
|
|
|
class HelpModal(ModalScreen[None]):
|
|
"""Show the complete binding reference without shrinking the workspace."""
|
|
|
|
BINDINGS = [
|
|
Binding("escape", "close", "Close"),
|
|
Binding("question_mark", "close", "Close"),
|
|
]
|
|
|
|
CSS = """
|
|
HelpModal { align: center middle; }
|
|
#help-container {
|
|
width: 72;
|
|
height: auto;
|
|
max-height: 90%;
|
|
background: $surface;
|
|
border: thick $primary;
|
|
padding: 1 2;
|
|
}
|
|
.help-title { text-style: bold; color: $primary; text-align: center; }
|
|
.help-section { margin-top: 1; text-style: bold; }
|
|
.help-copy { color: $text-muted; }
|
|
#help-close { margin-top: 1; width: 12; }
|
|
"""
|
|
|
|
def compose(self) -> ComposeResult:
|
|
with Vertical(id="help-container"):
|
|
yield Static("Keyboard help", classes="help-title")
|
|
yield Static("General", classes="help-section")
|
|
yield Static(
|
|
"q Quit ? Close help c Configuration", classes="help-copy"
|
|
)
|
|
yield Static("Navigation", classes="help-section")
|
|
yield Static(
|
|
"↑/↓ Select Host Entry i Sort IP h Sort hostname",
|
|
classes="help-copy",
|
|
)
|
|
yield Static("Filtering", classes="help-section")
|
|
yield Static(
|
|
"Type in Search for immediate filtering Ctrl+F Advanced filters",
|
|
classes="help-copy",
|
|
)
|
|
yield Static(
|
|
"Ctrl+X Export Host Entries Ctrl+O Import Host Entries",
|
|
classes="help-copy",
|
|
)
|
|
yield Static("Privileged Mode", classes="help-section")
|
|
yield Static(
|
|
"Ctrl+E Enter or leave Privileged Mode n Add Host Entry\n"
|
|
"Shift+N New from selected (N fallback) b Review Pre-edit Backup",
|
|
classes="help-copy",
|
|
)
|
|
yield Button("Close", id="help-close", variant="primary")
|
|
|
|
def on_mount(self) -> None:
|
|
self.query_one("#help-close", Button).focus()
|
|
|
|
def action_close(self) -> None:
|
|
self.dismiss(None)
|
|
|
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
if event.button.id == "help-close":
|
|
self.action_close()
|