1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-23 07:27:12 +01:00

Add links to help overlay

This commit is contained in:
Ivan Habunek 2019-08-31 14:50:31 +02:00
parent 3a11e470fb
commit 7e04ad55c6
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
2 changed files with 14 additions and 2 deletions

View File

@ -18,6 +18,7 @@ PALETTE = [
# Functional
('hashtag', 'light cyan,bold', ''),
('link', ',italics', ''),
('link_focused', ',italics', 'dark magenta'),
# Colors
('bold', ',bold', ''),

View File

@ -1,11 +1,12 @@
import json
import traceback
import urwid
import webbrowser
from toot import __version__
from .utils import highlight_keys
from .widgets import Button, EditBox
from .widgets import Button, EditBox, SelectableText
class StatusSource(urwid.ListBox):
@ -80,10 +81,15 @@ class Help(urwid.Padding):
super().__init__(listbox, left=1, right=1)
def generate_contents(self):
def h(text):
return highlight_keys(text, "cyan")
def link(text, url):
attr_map = {"link": "link_focused"}
text = SelectableText([text, ("link", url)])
urwid.connect_signal(text, "click", lambda t: webbrowser.open(url))
return urwid.AttrMap(text, "", attr_map)
yield urwid.Text(("yellow_bold", "toot {}".format(__version__)))
yield urwid.Divider()
yield urwid.Text(("bold", "General usage"))
@ -111,3 +117,8 @@ class Help(urwid.Padding):
yield urwid.Text(h(" [T] - Show status thread (replies)"))
yield urwid.Text(h(" [U] - Show the status data in JSON as received from the server"))
yield urwid.Text(h(" [V] - Open status in default browser"))
yield urwid.Divider()
yield urwid.Text(("bold", "Links"))
yield urwid.Divider()
yield link("Documentation: ", "https://toot.readthedocs.io/")
yield link("Project home: ", "https://github.com/ihabunek/toot/")