Compare commits
3 Commits
bc070c4162
...
737147b457
| Author | SHA1 | Date | |
|---|---|---|---|
| 737147b457 | |||
| 123d35068f | |||
| 258aabe10f |
@@ -6,9 +6,7 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
from textual import work
|
from textual import work
|
||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.containers import Container, Horizontal, ScrollableContainer
|
|
||||||
from textual.events import Key
|
from textual.events import Key
|
||||||
from textual.screen import ModalScreen
|
|
||||||
from textual.widgets import DataTable, Footer, Header, ProgressBar, Static
|
from textual.widgets import DataTable, Footer, Header, ProgressBar, Static
|
||||||
from textual.worker import get_current_worker
|
from textual.worker import get_current_worker
|
||||||
|
|
||||||
@@ -22,38 +20,12 @@ from .table_utils import (
|
|||||||
filter_unfinished_items,
|
filter_unfinished_items,
|
||||||
format_item_as_row,
|
format_item_as_row,
|
||||||
)
|
)
|
||||||
|
from .ui import HelpScreen
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from textual.widgets._data_table import ColumnKey
|
from textual.widgets._data_table import ColumnKey
|
||||||
|
|
||||||
|
|
||||||
class HelpScreen(ModalScreen):
|
|
||||||
"""Help screen displaying all available keybindings."""
|
|
||||||
|
|
||||||
BINDINGS = [("escape", "dismiss", "Close"), ("?", "dismiss", "Close")]
|
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
|
||||||
with Container(id="help_container"):
|
|
||||||
yield Static("Key Bindings", id="help_title")
|
|
||||||
with ScrollableContainer(id="help_content"):
|
|
||||||
bindings = self.app.BINDINGS
|
|
||||||
for binding in bindings:
|
|
||||||
if isinstance(binding, tuple):
|
|
||||||
key, action, description = binding
|
|
||||||
else:
|
|
||||||
key = binding.key
|
|
||||||
description = binding.description
|
|
||||||
key_display = key.replace(
|
|
||||||
"ctrl+", "^").replace("left", "←").replace("right", "→").replace("space", "Space").replace("enter", "Enter")
|
|
||||||
with Horizontal(classes="help_row"):
|
|
||||||
yield Static(f"[bold #f9e2af]{key_display}[/]", classes="help_key")
|
|
||||||
yield Static(description, classes="help_action")
|
|
||||||
yield Static("Press [bold #f9e2af]?[/] or [bold #f9e2af]Escape[/] to close", id="help_footer")
|
|
||||||
|
|
||||||
def action_dismiss(self) -> None:
|
|
||||||
self.dismiss()
|
|
||||||
|
|
||||||
|
|
||||||
class Auditui(App):
|
class Auditui(App):
|
||||||
"""Main application class for the Audible TUI app."""
|
"""Main application class for the Audible TUI app."""
|
||||||
|
|
||||||
|
|||||||
33
auditui/ui.py
Normal file
33
auditui/ui.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
"""UI components for the Auditui application."""
|
||||||
|
|
||||||
|
from textual.app import ComposeResult
|
||||||
|
from textual.containers import Container, Horizontal, ScrollableContainer
|
||||||
|
from textual.screen import ModalScreen
|
||||||
|
from textual.widgets import Static
|
||||||
|
|
||||||
|
|
||||||
|
class HelpScreen(ModalScreen):
|
||||||
|
"""Help screen displaying all available keybindings."""
|
||||||
|
|
||||||
|
BINDINGS = [("escape", "dismiss", "Close"), ("?", "dismiss", "Close")]
|
||||||
|
|
||||||
|
def compose(self) -> ComposeResult:
|
||||||
|
with Container(id="help_container"):
|
||||||
|
yield Static("Key Bindings", id="help_title")
|
||||||
|
with ScrollableContainer(id="help_content"):
|
||||||
|
bindings = self.app.BINDINGS
|
||||||
|
for binding in bindings:
|
||||||
|
if isinstance(binding, tuple):
|
||||||
|
key, action, description = binding
|
||||||
|
else:
|
||||||
|
key = binding.key
|
||||||
|
description = binding.description
|
||||||
|
key_display = key.replace(
|
||||||
|
"ctrl+", "^").replace("left", "←").replace("right", "→").replace("space", "Space").replace("enter", "Enter")
|
||||||
|
with Horizontal(classes="help_row"):
|
||||||
|
yield Static(f"[bold #f9e2af]{key_display}[/]", classes="help_key")
|
||||||
|
yield Static(description, classes="help_action")
|
||||||
|
yield Static("Press [bold #f9e2af]?[/] or [bold #f9e2af]Escape[/] to close", id="help_footer")
|
||||||
|
|
||||||
|
def action_dismiss(self) -> None:
|
||||||
|
self.dismiss()
|
||||||
Reference in New Issue
Block a user