Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 22 additions & 0 deletions docs/source/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<kbd>Super</kbd>+<kbd>F8</kbd> 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
Expand Down
2 changes: 2 additions & 0 deletions src/rogallo/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
StripeLinks,
ToggleANSIEscapeSequenceHandling,
ToggleBookmarksManager,
ToggleCosyLinkNumbers,
ToggleEmojiRemoval,
ToggleHistoryManager,
ToggleLinkNumbers,
Expand Down Expand Up @@ -50,6 +51,7 @@
"StripeLinks",
"ToggleANSIEscapeSequenceHandling",
"ToggleBookmarksManager",
"ToggleCosyLinkNumbers",
"ToggleEmojiRemoval",
"ToggleHistoryManager",
"ToggleLinkNumbers",
Expand Down
7 changes: 7 additions & 0 deletions src/rogallo/commands/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
3 changes: 3 additions & 0 deletions src/rogallo/data/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
2 changes: 2 additions & 0 deletions src/rogallo/providers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
StripeLinks,
ToggleANSIEscapeSequenceHandling,
ToggleBookmarksManager,
ToggleCosyLinkNumbers,
ToggleEmojiRemoval,
ToggleHistoryManager,
ToggleLinkNumbers,
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions src/rogallo/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
StripeLinks,
ToggleANSIEscapeSequenceHandling,
ToggleBookmarksManager,
ToggleCosyLinkNumbers,
ToggleEmojiRemoval,
ToggleHistoryManager,
ToggleLinkNumbers,
Expand Down Expand Up @@ -236,6 +237,7 @@ class Main(EnhancedScreen[None]):
StripeLinks,
ToggleANSIEscapeSequenceHandling,
ToggleBookmarksManager,
ToggleCosyLinkNumbers,
ToggleEmojiRemoval,
ToggleHistoryManager,
ToggleLinkNumbers,
Expand Down Expand Up @@ -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 (
Expand Down
16 changes: 10 additions & 6 deletions src/rogallo/widgets/viewer/gemtext_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions src/rogallo/widgets/viewer/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
"""

Expand Down Expand Up @@ -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)
Expand Down
Loading