Textualize / textual-serve

Serve Textual apps locally
MIT License
168 stars 8 forks source link

xterm.js Web Links #11

Open daddycocoaman opened 3 months ago

daddycocoaman commented 3 months ago

I have an application where I would like to allow the user to export the data. Since downloading isn't implemented in textual-serve yet, I decided to just provide the user a link which should be clickable in the browser. It seems like XTerm.js doesn't support this out the box, but has an official addon for this:

https://github.com/xtermjs/xterm.js/tree/master?tab=readme-ov-file#addons https://www.npmjs.com/package/@xterm/addon-web-links

This might be useful to add for textual-serve.

daddycocoaman commented 3 months ago

I forgot to mention, as a workaround in the meantime, you can make OSC 8 hyperlinks manually:

def terminal_link(url, text):
    """Return a terminal hyperlink."""
    return f"\033]8;;{url}\033\\{text}\033]8;;\033\\"

This will create a clickable link in the browser.

davidfokkema commented 1 day ago

I think Textual supports this now: https://textual.textualize.io/blog/2024/09/08/towards-textual-web-applications/#opening-web-links. Does that help? It is a bit flaky on Safari, though.