module Terminal
Extended Modules
Defined in:
styles.crterminal.cr
Constant Summary
-
OSC8_TERMS =
["xterm-kitty", "kitty", "alacritty", "foot", "wezterm", "ghostty", "contour"] -
Terminals whose TERM is known to support OSC 8 hyperlinks.
Instance Method Summary
-
#display_width(text : String) : Int32
Display width of a string in terminal columns: East Asian Wide/Fullwidth codepoints count 2 columns, combining marks and variation selectors count 0, everything else 1.
- #highlight(source : String, language : String, theme : String | Nil) : String
-
#osc8_capable? : Bool
OSC 8 support judged from the environment alone, so it can be asked about (and tested) without a terminal attached.
-
#parse_color(color) : Array(Int32) | Nil
Parse an X11-style color reply like "rgb:1c1c/1c1c/1c1c" into [red, green, blue], or nil if it doesn't parse
-
#query_terminal(color) : String
Query a terminal color via OSC and read the reply.
- #show_image(path : String) : String
- #supports_images? : Bool
- #supports_links? : Bool
- #terminal_light? : Bool
-
#terminal_width : Int32 | Nil
Get terminal width, with fallback Returns nil if not in a TTY or unable to determine
- #theme(name : String | Nil = nil) : Hash(String, Style)
Instance Method Detail
Display width of a string in terminal columns: East Asian Wide/Fullwidth codepoints count 2 columns, combining marks and variation selectors count 0, everything else 1. Wrapping and table sizing need this because a codepoint count mis-measures wide glyphs.
OSC 8 support judged from the environment alone, so it can be asked about (and tested) without a terminal attached.
Parse an X11-style color reply like "rgb:1c1c/1c1c/1c1c" into [red, green, blue], or nil if it doesn't parse
Query a terminal color via OSC and read the reply. If the terminal never replies (some don't support the query), time out instead of blocking forever.
Get terminal width, with fallback Returns nil if not in a TTY or unable to determine