Skip to content

Commit 423de4a

Browse files
authored
🔀 Merge pull request #148 from davep/allow-trad-quit
Allow for traditional quitting, as an option
2 parents b75aa83 + 9662d7e commit 423de4a

4 files changed

Lines changed: 35 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
# Hike ChangeLog
22

3+
## Unrealsed
4+
5+
**Released: WiP**
6+
7+
- Add a configuration option to allow for "traditional quit".
8+
([#148](https://github.com/davep/hike/pull/148))
9+
310
## v1.2.1
411

512
**Released: 2025-10-08**

docs/source/configuration.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ generally use a name (`number_sign`, `at`, `asterisk`, etc...).
8888
If you need help with keyboard bindings [please feel free to
8989
ask](index.md#questions-and-feedback).
9090

91+
## Allow for traditional quit keystroke
92+
93+
Because Hike is built with Textual, and some of Textual's widgets use
94+
<kbd>ctrl</kbd>+<kbd>c</kbd> to copy text to the clipboard, in all other
95+
situations <kbd>ctrl</kbd>+<kbd>c</kbd> will pop up a notification reminding
96+
you what the actual binding is to quit the application.
97+
98+
For those who really need to lean into their muscle memory you can enable
99+
<kbd>ctrl</kbd>+<kbd>c</kbd> as a quit key combination:
100+
101+
```json
102+
"allow_traditional_quit": true
103+
```
104+
105+
If this is set *and* if you aren't in a widget with marked text that can be
106+
copied, Hike will quit. If set to `false` (the default) the default
107+
behaviour for Hike (and most Textual applications) will happen.
108+
91109
## Local file system start location
92110

93111
By default Hike's local file system browser (the tree that appears in the

src/hike/data/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class Configuration:
5757
show_front_matter: bool = True
5858
"""Should the viewer allow for the viewing of front matter?"""
5959

60+
allow_traditional_quit: bool = False
61+
"""Ignore Textual's safety net for Ctrl+c?"""
62+
6063

6164
##############################################################################
6265
def configuration_file() -> Path:

src/hike/hike.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,12 @@ def get_default_screen(self) -> Main:
8585
"""
8686
return Main(self._arguments)
8787

88+
def action_help_quit(self) -> None:
89+
"""Override Textual's default handling of ctrl+c."""
90+
if load_configuration().allow_traditional_quit:
91+
self.exit()
92+
else:
93+
super().action_help_quit()
94+
8895

8996
### hike.py ends here

0 commit comments

Comments
 (0)