Skip to content

Commit c84a22f

Browse files
committed
buttons/views: Use Hyperlink widget for links in message info popup.
This commit introduces the use of the Hyperlink widget from the Urwidgets library for displaying links in the message information popup.
1 parent bef2a8f commit c84a22f

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,6 @@ def long_description():
105105
"pytz>=2022.7.1",
106106
"tzlocal>=2.1",
107107
"pyperclip>=1.8.1",
108+
"urwidgets>=0.1,<0.2",
108109
],
109110
)

zulipterminal/ui_tools/buttons.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from urllib.parse import urljoin, urlparse
99

1010
import urwid
11+
import urwidgets
1112
from typing_extensions import TypedDict
1213

1314
from zulipterminal.api_types import RESOLVED_TOPIC_PREFIX, EditPropagateMode
@@ -442,7 +443,12 @@ def update_widget(self, caption: str, display_attr: Optional[str] = None) -> Non
442443
Overrides the existing button widget for custom styling.
443444
"""
444445
# Set cursor position next to len(caption) to avoid the cursor.
445-
icon = urwid.SelectableIcon(caption, cursor_position=len(caption) + 1)
446+
icon = urwid.Pile(
447+
widget_list=[
448+
urwid.SelectableIcon(caption, cursor_position=len(caption) + 1),
449+
urwidgets.Hyperlink(uri=self.link),
450+
]
451+
)
446452
self._w = urwid.AttrMap(icon, display_attr, focus_map="selected")
447453

448454
def handle_link(self, *_: Any) -> None:

zulipterminal/ui_tools/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ def create_link_buttons(
15991599
for index, link in enumerate(links):
16001600
text, link_index, _ = links[link]
16011601
if text:
1602-
caption = f"{link_index}: {text}\n{link}"
1602+
caption = f"{link_index}: {text}"
16031603
else:
16041604
caption = f"{link_index}: {link}"
16051605
link_width = max(link_width, len(max(caption.split("\n"), key=len)))

0 commit comments

Comments
 (0)