| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Skylighting.Format.Vty
Contents
Description
Converts skylighting token streams into Vty Image values for display in the response
body viewport.
The public API mirrors the skylighting Format convention:
formatVtyis the top-level formatter analogous toformatANSI/formatHtml.vtyStyleAttrmaps skylighting colour/style information to a VtyAttr.attrStyleandattrColorhandle the individual style and colour components.colorDistancecomputes a simple L1 distance between twoColorvalues, 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
- formatVty :: FormatOptions -> Style -> [SourceLine] -> Image
- attrStyle :: Bool -> Bool -> Bool -> Style
- attrColor :: ANSIColorLevel -> Maybe Color -> Maybe Color
- colorDistance :: Color -> Color -> Int16
- vtyStyleAttr :: ANSIColorLevel -> Maybe Color -> Maybe Color -> Bool -> Bool -> Bool -> Attr
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.