termtab-0.1.0.0: TUI guitar tablature and score editor
Safe HaskellNone
LanguageGHC2021

Termtab.Graphics.Detect

Description

Runtime detection of which terminal graphics protocol to use for notation rendering.

No single protocol covers all target terminals: Kitty implements only its own graphics protocol (no Sixel), while iTerm2 supports Sixel but not the Kitty protocol. WezTerm and Ghostty support the Kitty protocol; iTerm2, foot, and xterm support Sixel. We therefore pick a backend at runtime and share the same rendered image buffer between them.

Detection is env-based (cheap, side-effect-free beyond reading the environment). A terminal Device Attributes (DA) probe for Sixel is a future refinement; for now an explicit TERMTAB_GRAPHICS override covers the cases env heuristics miss.

Synopsis

Documentation

data GraphicsProtocol Source #

Which terminal graphics protocol (if any) to render notation images through, chosen once at startup by detectProtocol and stored in asProtocol.

Constructors

Kitty

Kitty graphics protocol (Kitty, WezTerm, Ghostty)

Sixel

Sixel (iTerm2, WezTerm, foot, xterm, mlterm, contour)

TextOnly

No graphics support: fall back to the Unicode text staff

detectProtocol :: IO GraphicsProtocol Source #

Detect the graphics protocol from the environment.

Precedence:

  1. TERMTAB_GRAPHICS override (kitty | sixel | text)
  2. Kitty-protocol terminals (KITTY_WINDOW_ID, TERM=*kitty*, WezTerm, Ghostty)
  3. Sixel terminals (iTerm2, TERM=*sixel*)
  4. TextOnly

classifyProtocol :: Maybe String -> Maybe String -> Maybe String -> Maybe String -> GraphicsProtocol Source #

Pure classification core (unit-testable).

Arguments, in order: TERMTAB_GRAPHICS, TERM, TERM_PROGRAM, KITTY_WINDOW_ID.

classifyProtocolReason :: Maybe String -> Maybe String -> Maybe String -> Maybe String -> (GraphicsProtocol, String) Source #

Like classifyProtocol but also returns a human-readable explanation of which signal drove the decision (used by --health).

data DetectionInfo Source #

The full result of graphics detection, including the raw environment signals that were consulted. Rendered by --health.

Constructors

DetectionInfo 

Instances

Instances details
Show DetectionInfo Source # 
Instance details

Defined in Termtab.Graphics.Detect

Eq DetectionInfo Source # 
Instance details

Defined in Termtab.Graphics.Detect

detectProtocolInfo :: IO DetectionInfo Source #

Detect the protocol and capture the environment signals behind the decision.