restman-0.7.8.0: Web request TUI program.
Safe HaskellNone
LanguageGHC2024

Skylighting.Format.Vty

Description

Converts skylighting token streams into Vty Image values for display in the response body viewport.

The public API mirrors the skylighting Format convention:

  • formatVty is the top-level formatter analogous to formatANSI / formatHtml.
  • vtyStyleAttr maps skylighting colour/style information to a Vty Attr.
  • attrStyle and attrColor handle the individual style and colour components.
  • colorDistance computes a simple L1 distance between two Color values, used by the colour-approximation instances when a terminal does not support true-colour.

The module also provides orphan ToColor / FromColor instances for Xterm256ColorCode and (ColorIntensity, Color).

Synopsis

Documentation

formatVty :: FormatOptions -> Style -> [SourceLine] -> Image Source #

Format a list of highlighted source lines as a Vty Image.

This is the primary entry point for the Vty formatter. It zips line numbers (starting from startNumber in FormatOptions) with the token-annotated source lines and concatenates the resulting row images vertically.

attrStyle :: Bool -> Bool -> Bool -> Style Source #

Combine bold, italic, and underline flags into a Vty Style bitmask.

attrColor :: ANSIColorLevel -> Maybe Color -> Maybe Color Source #

Map a skylighting Color to a Vty Color at the requested colour-depth level.

Currently all three ANSIColorLevel variants produce a true-colour RGB value; the distinction is preserved for future refinement (e.g. quantising to the nearest palette entry for 16-colour terminals).

colorDistance :: Color -> Color -> Int16 Source #

L1 (Manhattan) distance between two Color values in RGB space. Used by findApproximateColor to find the nearest palette entry.

vtyStyleAttr Source #

Arguments

:: ANSIColorLevel

colour support level reported by the terminal

-> Maybe Color

foreground colour (Nothing → terminal default)

-> Maybe Color

background colour (Nothing → terminal default)

-> Bool

bold

-> Bool

italic

-> Bool

underlined

-> Attr 

Build a Vty Attr from skylighting style components.

The URL field of the attribute is always left at Default because Vty's hyperlink support is not used by RESTman.

Orphan instances

FromColor (ColorIntensity, Color) Source #

Warning: this conversion is extremely approximate!

Instance details

ToColor (ColorIntensity, Color) Source # 
Instance details