module Opal::Terminal::OSC

Overview

Operating System Command (OSC) escape sequences for modern terminal emulators.

Defined in:

opal/terminal/osc.cr

Constant Summary

OSC8_REGEX = /\e\]8;([^;]*);([^\a\e]*)(?:\a|\e\\)(.*?)\e\]8;;(?:\a|\e\\)/m

Class Method Summary

Class Method Detail

def self.clipboard_copy(text : String, target : Char = 'c') : String #

Generates an OSC 52 clipboard copy escape sequence using strict Base64 encoding. Allows copying text directly into the host OS clipboard over SSH and local terminal sessions. clipboard target: 'c' = primary clipboard, 'p' = selection clipboard


[View source]
def self.copy_to_clipboard(text : String, io : IO = STDOUT, target : Char = 'c') : Nil #

Directly copies text to the system clipboard via STDOUT using OSC 52.


[View source]
def self.discussion_link(repo : String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Generates an OSC 8 clickable hyperlink for a GitHub Discussion (Discussion #XX).


[View source]
def self.github_link(repo : String, kind : Symbol | String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Generates an OSC 8 clickable hyperlink to a GitHub RFC/Discussion, Issue, or PR.


[View source]
def self.github_url(repo : String, kind : Symbol | String = :repo, number : Int32 | String | Nil = nil) : String #

Constructs a canonical GitHub URL for a repository, RFC/discussion, issue, or pull request.


[View source]
def self.hyperlink(text : String, url : String, id : String | Nil = nil) : String #

Generates an OSC 8 clickable hyperlink escape sequence. Supported by Windows Terminal, iTerm2, Kitty, WezTerm, Alacritty, GNOME Terminal, etc.


[View source]
def self.issue_link(repo : String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Generates an OSC 8 clickable hyperlink for a GitHub Issue (Issue #XX).


[View source]
def self.link(url : String, label : String | Nil = nil, id : String | Nil = nil) : String #

Declarative link(url, label) OSC 8 terminal hyperlink helper. If label is omitted, defaults to url. Also supports (label, url) if second is a URI.


[View source]
def self.normalize_github_repo(repo : String, default_owner : String = "sol-vin") : String #

Normalizes a GitHub repository identifier (e.g. "opal" -> "sol-vin/opal").


[View source]
def self.parse_links(text : String) : Array(LinkSpan) #

Parses all OSC 8 hyperlink spans contained within a string.


[View source]
def self.pr_link(repo : String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Generates an OSC 8 clickable hyperlink for a GitHub Pull Request (PR #XX).


[View source]
def self.resolve_link_args(first : String, second : String | Nil = nil) : Tuple(String, String) #

Normalizes (url, label) arguments while remaining backward-compatible with (label, url) when the second argument is an explicit URL.


[View source]
def self.rfc_link(repo : String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Generates an OSC 8 clickable hyperlink for a GitHub RFC Discussion (RFC #XX).


[View source]
def self.url_like?(value : String) : Bool #

Returns true if the string begins with a standard URI scheme.


[View source]