Skip to content

Commit 898306c

Browse files
authored
🔀 Merge pull request #58 from davep/add-reload
Add a reload command
2 parents 4107f37 + 7194555 commit 898306c

5 files changed

Lines changed: 29 additions & 0 deletions

File tree

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Rogallo ChangeLog
22

3+
## Unreleased
4+
5+
**Released: WiP**
6+
7+
- Added a `Reload` command.
8+
([#58](https://github.com/davep/rogallo/pull/58))
9+
310
## v0.3.0
411

512
**Released: 2026-06-26**

src/rogallo/commands/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
ChangeCommandLineLocation,
77
JumpToCommandLine,
88
JumpToDocument,
9+
Reload,
910
ToggleHistory,
1011
)
1112
from .navigation import Backward, Forward
@@ -18,6 +19,7 @@
1819
"Forward",
1920
"JumpToCommandLine",
2021
"JumpToDocument",
22+
"Reload",
2123
"ToggleHistory",
2224
]
2325

src/rogallo/commands/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,11 @@ class ToggleHistory(Command):
3535
FOOTER_TEXT = "History"
3636

3737

38+
##############################################################################
39+
class Reload(Command):
40+
"""Reload the current document"""
41+
42+
BINDING_KEY = "ctrl+r, f5"
43+
44+
3845
### main.py ends here

src/rogallo/providers/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Forward,
1919
JumpToCommandLine,
2020
JumpToDocument,
21+
Reload,
2122
ToggleHistory,
2223
)
2324

@@ -41,6 +42,7 @@ def commands(self) -> CommandHits:
4142
yield from self.maybe(Backward)
4243
yield from self.maybe(Forward)
4344
yield from self.maybe(ToggleHistory)
45+
yield from self.maybe(Reload)
4446

4547

4648
### main.py ends here

src/rogallo/screens/main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
Forward,
3535
JumpToCommandLine,
3636
JumpToDocument,
37+
Reload,
3738
ToggleHistory,
3839
)
3940
from ..data import (
@@ -137,6 +138,7 @@ class Main(EnhancedScreen[None]):
137138
ChangeCommandLineLocation,
138139
JumpToCommandLine,
139140
JumpToDocument,
141+
Reload,
140142
]
141143

142144
BINDINGS = Command.bindings(*COMMAND_MESSAGES)
@@ -223,6 +225,8 @@ def check_action(self, action: str, parameters: tuple[object, ...]) -> bool | No
223225
return self._navigation_history.can_go_forward or None
224226
if action == ToggleHistory.action_name():
225227
return len(self._location_history) > 0 or None
228+
if action == Reload.action_name():
229+
return bool(self._viewer.document)
226230
return True
227231

228232
async def _handle_response(self, response: Response, request: OpenLocation) -> None:
@@ -447,5 +451,12 @@ def action_toggle_history_command(self) -> None:
447451
else:
448452
self._viewer.take_control()
449453

454+
def action_reload_command(self) -> None:
455+
"""Reload the current document."""
456+
if self._viewer.document.location:
457+
self.post_message(
458+
OpenLocation(self._viewer.document.location, from_history=True)
459+
)
460+
450461

451462
### main.py ends here

0 commit comments

Comments
 (0)