purebred-mua / purebred

A terminal based mail user agent based on notmuch
GNU Affero General Public License v3.0
139 stars 19 forks source link

Long URLs not wrapped #434

Open frasertweedale opened 3 years ago

frasertweedale commented 3 years ago

Describe the bug When viewing a URL in the pager, if it is too wide it gets clipped, not wrapped. I suppose this is a general issue with long "words", but it is unlikely to arise in ordinary text (even in German!) But long URLs are common. So we need to handle this better.

To Reproduce Read a mail that contains a URL wider than the terminal.

Expected behavior URL should be wrapped, with the following expectations:

Additional context

An alternative approach, and one I have occasionally wished for in Mutt, is to automatically rewrite long links to a shortened URL, pointing to a local (perhaps ephemeral) HTTP server that can direct the client. For example, rewrite https://REALLY_LONG to http://localhost/SHORT that serves up a 301 pointing to the former.

For now, it is enough to ensure that copy/paste works.

frasertweedale commented 3 years ago

Also, we can maybe look at finding URLs ourselves and using hyperlink escapes to add links: https://hackage.haskell.org/package/vty-5.33/docs/Graphics-Vty-Attributes.html#v:withURL. (Not mutually exclusive with other suggestions).

romanofski commented 3 years ago

I think it should be as simple as rendering them as a hyperlink.

frasertweedale commented 3 years ago

I think it should be as simple as rendering them as a hyperlink.

After some more investigation, no, this won't work. Not all terminals support it. Indeed neither xterm nor xfce4-terminal support it. tmux also swallows the hyperlink escapes - even if the "outer" terminal supports hyperlink.

frasertweedale commented 3 years ago

I think as a baseline, copy+paste must work, even if it means that "smart" terminal rendering of http links breaks for wrapped URIs.

romanofski commented 3 years ago

Yeah fair enough. I guess due to the problem that it only sometimes works, tools like urlscan or urlview exist ...