Skip to main content

Module style

Module style 

Source
Expand description

Colour and emphasis.

Three rules hold here, and they are the reason this is a module rather than scattered \x1b[ literals:

  1. Styling never changes the data. The same fields, in the same order, with the same words, whether or not anything is painted. Only the escape codes differ, so a pipe and a terminal disagree about nothing that matters.
  2. Machine output is never styled. Not stripped afterwards — never produced. Snapshot tests then pin the real bytes a caller receives.
  3. Untrusted text is never given our chrome. Descriptions and comments are dimmed and nothing more. Painting them like tool output would let an issue’s text impersonate the tool talking, which is exactly the confusion the fence exists to prevent (ADR 1).

Structs§

Painter
Applies the palette, or does not.
Palette
The palette. Small on purpose: a listing that uses six colours communicates less than one that uses two.