Skip to content

Commit 9d10af3

Browse files
authored
🔀 Merge pull request #95 from davep/discontent
Crop bookmarks and history the "improved" way
2 parents b309be1 + a84eda3 commit 9d10af3

File tree

2 files changed

+12
-44
lines changed

2 files changed

+12
-44
lines changed

src/hike/widgets/navigation/bookmarks_view.py

+5-21
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
# httpx imports.
1010
from httpx import URL
1111

12-
##############################################################################
13-
# Rich imports.
14-
from rich.text import Text
15-
1612
##############################################################################
1713
# Textual imports.
1814
from textual import on, work
@@ -46,23 +42,9 @@ def __init__(self, bookmark: Bookmark) -> None:
4642
self.bookmark = bookmark
4743
"""The bookmark."""
4844
super().__init__(
49-
# From Textual 2.x onwards overflow="ellipsis" is broken in the
50-
# "improved" OptionList.
51-
#
52-
# https://github.com/Textualize/textual/issues/5701
53-
#
54-
# The result is ugly as fuck, and as best as I can tell I can't
55-
# achieve the originally-intended layout; at least it isn't as
56-
# obvious and accessible as simply using a `Text` was. So for
57-
# now I'm going to wrap this in Textual's new `Content` -- which
58-
# seems to be Rich-like only worse -- and accept it looks as
59-
# ugly as fuck but less ugly than without this workaround.
60-
Content.from_rich_text(
61-
Text.from_markup(
62-
f"{REMOTE_FILE_ICON if isinstance(bookmark.location, URL) else LOCAL_FILE_ICON} "
63-
f"[bold]{bookmark.title}[/]\n[dim]{bookmark.location}[/]",
64-
overflow="ellipsis",
65-
)
45+
Content.from_markup(
46+
f"{REMOTE_FILE_ICON if isinstance(bookmark.location, URL) else LOCAL_FILE_ICON} "
47+
f"[bold]{bookmark.title}[/]\n[dim]{bookmark.location}[/]",
6648
),
6749
id=str(bookmark.location),
6850
)
@@ -76,6 +58,8 @@ class BookmarksView(EnhancedOptionList):
7658
BookmarksView {
7759
height: 1fr;
7860
border: none;
61+
text-wrap: nowrap;
62+
text-overflow: ellipsis;
7963
&:focus {
8064
border: none;
8165
}

src/hike/widgets/navigation/history_view.py

+7-23
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
from pathlib import Path
66
from typing import cast
77

8-
##############################################################################
9-
# Rich imports.
10-
from rich.text import Text
11-
128
##############################################################################
139
# Textual imports.
1410
from textual import on, work
@@ -42,25 +38,11 @@ def __init__(self, location_id: int, location: HikeLocation) -> None:
4238
self.location_id = location_id
4339
"""The ID of the location within the history."""
4440
super().__init__(
45-
# From Textual 2.x onwards overflow="ellipsis" is broken in the
46-
# "improved" OptionList.
47-
#
48-
# https://github.com/Textualize/textual/issues/5701
49-
#
50-
# The result is ugly as fuck, and as best as I can tell I can't
51-
# achieve the originally-intended layout; at least it isn't as
52-
# obvious and accessible as simply using a `Text` was. So for
53-
# now I'm going to wrap this in Textual's new `Content` -- which
54-
# seems to be Rich-like only worse -- and accept it looks as
55-
# ugly as fuck but less ugly than without this workaround.
56-
Content.from_rich_text(
57-
Text.from_markup(
58-
f"{LOCAL_FILE_ICON} [bold]{location.name}[/]\n[dim]{location.parent}[/]"
59-
if isinstance(location, Path)
60-
else f"{REMOTE_FILE_ICON} [bold]{Path(location.path).name}[/]"
61-
f"\n[dim]{Path(location.path).parent}\n{location.host}[/]",
62-
overflow="ellipsis",
63-
)
41+
Content.from_markup(
42+
f"{LOCAL_FILE_ICON} [bold]{location.name}[/]\n[dim]{location.parent}[/]"
43+
if isinstance(location, Path)
44+
else f"{REMOTE_FILE_ICON} [bold]{Path(location.path).name}[/]"
45+
f"\n[dim]{Path(location.path).parent}\n{location.host}[/]"
6446
),
6547
id=str(location_id),
6648
)
@@ -74,6 +56,8 @@ class HistoryView(EnhancedOptionList):
7456
HistoryView {
7557
height: 1fr;
7658
border: none;
59+
text-wrap: nowrap;
60+
text-overflow: ellipsis;
7761
&:focus {
7862
border: none;
7963
}

0 commit comments

Comments
 (0)