Skip to content

HyperlinkWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A widget that renders text as a clickable hyperlink using OSC 8 escape sequences. In terminals that support OSC 8 (most modern terminals), the text will be rendered as a clickable link. In unsupported terminals, the text will be rendered normally.

csharp
public sealed record HyperlinkWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<HyperlinkWidget>

Inheritance

ObjectHex1bWidgetHyperlinkWidget

Implements

Constructors

HyperlinkWidget(string, string, TextOverflow)

A widget that renders text as a clickable hyperlink using OSC 8 escape sequences. In terminals that support OSC 8 (most modern terminals), the text will be rendered as a clickable link. In unsupported terminals, the text will be rendered normally.

Parameters:

  • Text (String): The visible text to display.
  • Uri (String): The URI to link to when clicked (or hovered in terminal).
  • Overflow (TextOverflow): How to handle text that exceeds the available width.
csharp
public HyperlinkWidget(string Text, string Uri, TextOverflow Overflow = TextOverflow.Truncate)

Properties

Overflow

How to handle text that exceeds the available width.

Returns: TextOverflow

csharp
public TextOverflow Overflow { get; init; }

Parameters

Optional parameters for the hyperlink (e.g., "id=unique-id"). Per the OSC 8 spec, the id parameter can be used to group multiple hyperlink segments that should be treated as a single logical link.

Returns: String

csharp
public string Parameters { get; init; }

Text

The visible text to display.

Returns: String

csharp
public string Text { get; init; }

Uri

The URI to link to when clicked (or hovered in terminal).

Returns: String

csharp
public string Uri { get; init; }

Methods

OnClick(Action<HyperlinkClickedEventArgs>)

Sets a synchronous click handler. Called when the hyperlink is activated via Enter or mouse click.

Parameters:

Returns: HyperlinkWidget

csharp
public HyperlinkWidget OnClick(Action<HyperlinkClickedEventArgs> handler)

OnClick(Func<HyperlinkClickedEventArgs, Task>)

Sets an asynchronous click handler. Called when the hyperlink is activated via Enter or mouse click.

Parameters:

Returns: HyperlinkWidget

csharp
public HyperlinkWidget OnClick(Func<HyperlinkClickedEventArgs, Task> handler)

WithId(string)

Sets a unique ID parameter for the hyperlink. This is useful for grouping multiple hyperlink segments together.

Parameters:

Returns: HyperlinkWidget

csharp
public HyperlinkWidget WithId(string id)

WithParameters(string)

Sets the optional parameters for the hyperlink.

Parameters:

Returns: HyperlinkWidget

csharp
public HyperlinkWidget WithParameters(string parameters)

Fields

ActivateActionId

Action ID for activating the hyperlink.

Returns: ActionId

csharp
public static readonly ActionId ActivateActionId

Released under the MIT License.