Terminal.hyperlink

Outputs a hyperlink to my custom terminal (v0.0.7 or later) or to version TerminalDirectToEmulator. The way it works is a bit strange...

More...
struct Terminal
void
hyperlink
(
string text
,
ushort identifier = 0
,
bool autoStyle = true
)

Parameters

text string

text displayed in the terminal

identifier ushort

an additional number attached to the text and returned to you in a LinkEvent. Possible uses of this are to have a small number of "link classes" that are handled based on the text. For example, maybe identifier == 0 means paste text into the line. identifier == 1 could mean open a browser. identifier == 2 might open details for it. Just be sure to encode the bulk of the information into the text so the user can copy/paste it out too.

You may also create a mapping of (identifier,text) back to some other activity, but if you do that, be sure to check hyperlinkSupported and fallback in your own code so it still makes sense to users on other terminals.

autoStyle bool

set to false to suppress the automatic color and underlining of the text.

Detailed Description

If using a terminal that supports it, it outputs the given text with the given identifier attached (one bit of identifier per grapheme of text!). When the user clicks on it, it will send a LinkEvent with the text and the identifier for you to respond, if in real-time input mode, or a simple paste event with the text if not (you will not be able to distinguish this from a user pasting the same text).

If the user's terminal does not support my feature, it writes plain text instead.

It is important that you make sure your program still works even if the hyperlinks never work - ideally, make them out of text the user can type manually or copy/paste into your command line somehow too.

Hyperlinks may not work correctly after your program exits or if you are capturing mouse input (the user will have to hold shift in that case). It is really designed for linear mode with direct to emulator mode. If you are using cellular mode with full input capturing, you should manage the clicks yourself.

Similarly, if it horizontally scrolls off the screen, it can be corrupted since it packs your text and identifier into free bits in the screen buffer itself. I may be able to fix that later.

Bugs

there's no keyboard interaction with it at all right now. i might make the terminal emulator offer the ids or something through a hold ctrl or something interface. idk. or tap ctrl twice to turn that on.

Meta

History

Added March 18, 2020