From 149a8178c796ff944b0086bf51df3e5798e7288d Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Mon, 20 Jul 2026 09:41:05 +0100 Subject: [PATCH 1/2] :sparkles: Add a command to toggle the position of the link jump labels Closes #190. --- ChangeLog.md | 3 +++ src/rogallo/commands/__init__.py | 2 ++ src/rogallo/commands/main.py | 7 +++++++ src/rogallo/data/config.py | 3 +++ src/rogallo/providers/main.py | 2 ++ src/rogallo/screens/main.py | 8 ++++++++ src/rogallo/widgets/viewer/gemtext_blocks.py | 16 ++++++++++------ src/rogallo/widgets/viewer/widget.py | 7 +++++++ 8 files changed, 42 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index fa872ac..8220e06 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,6 +9,9 @@ - Entering the name of an existing directory in the command line now opens that directory in the file picker dialog. ([#188](https://github.com/davep/rogallo/pull/188)) +- Added a `ToggleCosyLinkNumbers` command, which moves the link jump numbers + over to the left of the link text or back to the right. + ([#193](https://github.com/davep/rogallo/pull/193)) ## v0.11.0 diff --git a/src/rogallo/commands/__init__.py b/src/rogallo/commands/__init__.py index b5d0c07..ecc388e 100644 --- a/src/rogallo/commands/__init__.py +++ b/src/rogallo/commands/__init__.py @@ -17,6 +17,7 @@ StripeLinks, ToggleANSIEscapeSequenceHandling, ToggleBookmarksManager, + ToggleCosyLinkNumbers, ToggleEmojiRemoval, ToggleHistoryManager, ToggleLinkNumbers, @@ -50,6 +51,7 @@ "StripeLinks", "ToggleANSIEscapeSequenceHandling", "ToggleBookmarksManager", + "ToggleCosyLinkNumbers", "ToggleEmojiRemoval", "ToggleHistoryManager", "ToggleLinkNumbers", diff --git a/src/rogallo/commands/main.py b/src/rogallo/commands/main.py index ab8fdc0..d572922 100644 --- a/src/rogallo/commands/main.py +++ b/src/rogallo/commands/main.py @@ -110,6 +110,13 @@ class ToggleLinkNumbers(Command): BINDING_KEY = "shift+f8" +############################################################################## +class ToggleCosyLinkNumbers(Command): + """Toggle the position of link numbers when they're being displayed""" + + BINDING_KEY = "super+f8" + + ############################################################################## class ToggleEmojiRemoval(Command): """Toggle the removal of emoji from text content""" diff --git a/src/rogallo/data/config.py b/src/rogallo/data/config.py index 97dc975..afb7d0d 100644 --- a/src/rogallo/data/config.py +++ b/src/rogallo/data/config.py @@ -82,6 +82,9 @@ class Configuration: with_link_jumps: bool = True """Should the application support jumping to links via numeric labels?""" + cosy_link_jumps: bool = False + """Should the numeric labels be displayed in a cosy way?""" + maximum_document_width: int = 0 """The maximum width of a document, in characters. A value of 0 means no limit.""" diff --git a/src/rogallo/providers/main.py b/src/rogallo/providers/main.py index e3d3d86..796e888 100644 --- a/src/rogallo/providers/main.py +++ b/src/rogallo/providers/main.py @@ -35,6 +35,7 @@ StripeLinks, ToggleANSIEscapeSequenceHandling, ToggleBookmarksManager, + ToggleCosyLinkNumbers, ToggleEmojiRemoval, ToggleHistoryManager, ToggleLinkNumbers, @@ -77,6 +78,7 @@ def commands(self) -> CommandHits: yield StripeLinks() yield ToggleANSIEscapeSequenceHandling() yield from self.maybe(ToggleBookmarksManager) + yield ToggleCosyLinkNumbers() yield ToggleEmojiRemoval() yield from self.maybe(ToggleHistoryManager) yield ToggleLinkNumbers() diff --git a/src/rogallo/screens/main.py b/src/rogallo/screens/main.py index 3714f0f..eb577de 100644 --- a/src/rogallo/screens/main.py +++ b/src/rogallo/screens/main.py @@ -74,6 +74,7 @@ StripeLinks, ToggleANSIEscapeSequenceHandling, ToggleBookmarksManager, + ToggleCosyLinkNumbers, ToggleEmojiRemoval, ToggleHistoryManager, ToggleLinkNumbers, @@ -236,6 +237,7 @@ class Main(EnhancedScreen[None]): StripeLinks, ToggleANSIEscapeSequenceHandling, ToggleBookmarksManager, + ToggleCosyLinkNumbers, ToggleEmojiRemoval, ToggleHistoryManager, ToggleLinkNumbers, @@ -1087,6 +1089,12 @@ def action_toggle_link_numbers_command(self) -> None: with update_configuration() as config: config.with_link_jumps = self._viewer.with_link_numbers + def action_toggle_cosy_link_numbers_command(self) -> None: + """Toggle cosy link numbers.""" + self._viewer.cosy_link_numbers = not self._viewer.cosy_link_numbers + with update_configuration() as config: + config.cosy_link_jumps = self._viewer.cosy_link_numbers + def action_go_to_parent_command(self) -> None: """Go to the parent of the current document's location.""" if ( diff --git a/src/rogallo/widgets/viewer/gemtext_blocks.py b/src/rogallo/widgets/viewer/gemtext_blocks.py index 5b4795e..4229225 100644 --- a/src/rogallo/widgets/viewer/gemtext_blocks.py +++ b/src/rogallo/widgets/viewer/gemtext_blocks.py @@ -28,7 +28,7 @@ # Textual imports. from textual import on from textual.app import ComposeResult -from textual.containers import Horizontal +from textual.containers import Horizontal, HorizontalGroup from textual.events import Click from textual.getters import query_one from textual.highlight import HighlightTheme, highlight @@ -315,11 +315,15 @@ def _watch_jump_number(self) -> None: def compose(self) -> ComposeResult: """Compose the Gemtext link widget.""" yield Label(self._icon, id="icon") - with Horizontal(id="text-wrap"): - yield Label( - GemtextContent.filter(self._link), id="text", markup=False, shrink=True - ) - yield Label(id="jump", markup=False) + with HorizontalGroup(): + with HorizontalGroup(id="text-wrap"): + yield Label( + GemtextContent.filter(self._link), + id="text", + markup=False, + shrink=True, + ) + yield Label(id="jump", markup=False) @on(Click) def _action_open_link(self) -> None: diff --git a/src/rogallo/widgets/viewer/widget.py b/src/rogallo/widgets/viewer/widget.py index 5ace16b..7672606 100644 --- a/src/rogallo/widgets/viewer/widget.py +++ b/src/rogallo/widgets/viewer/widget.py @@ -66,6 +66,11 @@ class Viewer(Vertical, can_focus=False): &.--with-link-numbers GemtextLink #jump { display: block; } + + &.--cosy-link-numbers GemtextLink #jump { + dock: left; + padding-right: 1; + } } """ @@ -93,6 +98,8 @@ class Viewer(Vertical, can_focus=False): """Whether the viewer is showing the source of the document or not.""" with_link_numbers: var[bool] = var(False, toggle_class="--with-link-numbers") """Whether the viewer is showing link numbers or not.""" + cosy_link_numbers: var[bool] = var(False, toggle_class="--cosy-link-numbers") + """Whether the viewer is showing link numbers in a cosy way or not.""" stripe_links: var[bool] = var(False, toggle_class="--stripe-links") """Whether the viewer is showing links with stripes or not.""" location_history: var[LocationHistory] = var(LocationHistory) From 4c574c5dd050c4ec3549046a5309da1cfa717c14 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Mon, 20 Jul 2026 10:12:25 +0100 Subject: [PATCH 2/2] :books: Document cosy link jump labels --- docs/source/configuration.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/source/configuration.md b/docs/source/configuration.md index 8de7b13..943044c 100644 --- a/docs/source/configuration.md +++ b/docs/source/configuration.md @@ -321,6 +321,28 @@ valid values. It will be `true` (with labels) by default. "with_link_jumps": true ``` +### Cosy link jumps + +By default the numeric labels for the jumps are positioned to the right of +the display. This is done to keep a readable flow of text. While [link +stripes](#striped-links) are provided to make it easier to know which label +goes with which link, some people might prefer the labels to really cosy up +with the links. For those folk the `Toggle Cosy Link Numbers` +([`ToggleCosyLinkNumbers`](#bindable-commands) command, bound to +Super+F8 by default) command is available. The result +of using it will be: + +```{.textual path="docs/screenshots/stripes_screenshot.py" title="Cosy link number labels" lines=30 columns=70 press="super+f8"} +``` + +The setting itself is saved in the configuration file as the `cosy_link_jumps` +configuration setting. It accepts `true` or `false` as valid values. It will +be `false` (labels on the right) by default: + +```json +"cosy_link_jumps": false +``` + ## Link tooltips By default, when using a mouse, Rogallo will show a tooltip containing the