Skip to content

Commit

Permalink
Add note on keymaps to home page, allow moving cursor in confirmation…
Browse files Browse the repository at this point in the history
… dialog using arrow keys
  • Loading branch information
darrenburns committed Oct 12, 2024
1 parent 24c6aba commit ce7c02b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/overrides/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,10 @@ <h2 class="feature-title">
</p>
<p class="feature-description">
Adjust the user interface to your liking through the <span data-text="configuration system" class="gradient-text subtle-purple-glow">configuration system</span> or at runtime.
</p>
</p>
<p class="feature-description">
Customize keybindings to your liking using the <span data-text="keymap" class="gradient-text subtle-purple-glow">keymap</span> system.
</p>
</div>
<div class="feature-image">
<img src="assets/themes.png" alt="A selection of Posting's themes stacked on top of each other.">
Expand Down
14 changes: 14 additions & 0 deletions src/posting/widgets/confirmation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Literal
from textual import on
from textual.app import ComposeResult
from textual.binding import Binding
from textual.containers import Horizontal, Vertical
from textual.screen import ModalScreen
from textual.widgets import Button, Static
Expand All @@ -26,6 +27,15 @@ class ConfirmationModal(ModalScreen[bool]):
}
"""

BINDINGS = [
Binding(
"left,right,up,down,h,j,k,l",
"move_focus",
"Navigate",
show=False,
)
]

def __init__(
self,
message: str,
Expand Down Expand Up @@ -68,3 +78,7 @@ def confirm(self) -> None:
@on(Button.Pressed, "#cancel-button")
def cancel(self) -> None:
self.dismiss(False)

def action_move_focus(self) -> None:
# It's enough to just call focus_next here as there are only two buttons.
self.screen.focus_next()

0 comments on commit ce7c02b

Please sign in to comment.