Skip to content

Commit 9fac259

Browse files
author
Nejc Stebe
committed
add pause key binding to TUI
1 parent 2a004b1 commit 9fac259

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

plain2code_events.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,10 @@ class RenderModuleCompleted(BaseEvent):
6161
@dataclass
6262
class RenderModuleStarted(BaseEvent):
6363
module_name: str
64+
65+
66+
@dataclass
67+
class PauseRequested(BaseEvent):
68+
"""Event emitted when the user requests to pause rendering."""
69+
70+
pass

tui/components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class CustomFooter(Horizontal):
1414
"""A custom footer with keyboard shortcuts and render ID."""
1515

16-
FOOTER_TEXT = "ctrl+c: copy * ctrl+d: quit * ctrl+l: toggle logs"
16+
FOOTER_TEXT = "ctrl+c: copy * ctrl+d: quit * ctrl+l: toggle logs * ctrl+shift+p: pause"
1717
RENDER_FINISHED_TEXT = "enter: exit * ctrl+c: copy * ctrl+l: toggle logs"
1818

1919
def __init__(self, render_id: str = "", **kwargs):

tui/plain2code_tui.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from event_bus import EventBus
1010
from plain2code_events import (
1111
LogMessageEmitted,
12+
PauseRequested,
1213
RenderCompleted,
1314
RenderContextSnapshot,
1415
RenderFailed,
@@ -51,6 +52,7 @@ class Plain2CodeTUI(App):
5152
Binding("ctrl+c", "copy_selection", "Copy", show=False),
5253
Binding("ctrl+d", "quit", "Quit", show=False),
5354
Binding("enter", "enter_exit", "Exit", show=False),
55+
Binding("ctrl+shift+p", "pause", "Pause", show=False),
5456
("ctrl+l", "toggle_logs", "Toggle Logs"),
5557
]
5658

@@ -270,6 +272,11 @@ async def action_copy_selection(self) -> None:
270272
self.screen.clear_selection()
271273
self.notify("Copied to clipboard", timeout=2)
272274

275+
def action_pause(self) -> None:
276+
"""Handle ctrl+shift+p: request the render machine to pause."""
277+
if not self._render_finished:
278+
self.event_bus.publish(PauseRequested())
279+
273280
def action_enter_exit(self) -> None:
274281
"""Handle enter: exit the TUI only after rendering has finished."""
275282
if self._render_finished:

0 commit comments

Comments
 (0)