Skip to content

prettyprinter-ansi-terminal: There should be a way to reset a color/style to terminal default #42

@fmthoma

Description

@fmthoma

Currently, it's possible to keep some colors and override others (e.g. keep foreground color, but change background color), but it's impossible to revert to terminal default for one or the other. This is particularly inconvenient when trying to use a »default« color like black or white in a color scheme that is required to work for both dark and light backgrounds.

This behavior is encoded in the type AnsiStyle:

data AnsiStyle = SetAnsiStyle
    { ansiForeground  :: Maybe (Intensity, Color) -- ^ Set the foreground color, or keep the old one.
    , ansiBackground  :: Maybe (Intensity, Color) -- ^ Set the background color, or keep the old one.
    , ansiBold        :: Maybe Bold               -- ^ Switch on boldness, or don’t do anything.
    , ansiItalics     :: Maybe Italicized         -- ^ Switch on italics, or don’t do anything.
    , ansiUnderlining :: Maybe Underlined         -- ^ Switch on underlining, or don’t do anything.
    } deriving (Eq, Ord, Show)

Instead of Maybe a, this should be a ternary Keep | Default | SetTo a just like vty's Attr does it with its MaybeDefault type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions