vito / elm-ansi / Ansi

This library primarily exposes the parse function and the types that it will yield.

parse : String -> List Action

Convert an arbitrary String of text into a sequence of actions.

If the input string ends with a partial ANSI escape sequence, it will be yielded as a Remainder action, which should then be prepended to the next call to parse.

parseInto : a -> (Action -> a -> a) -> String -> a

Update a structure with actions parsed out of the given string.


type Action
    = Print String
    | Remainder String
    | SetForeground (Maybe Color)
    | SetBackground (Maybe Color)
    | SetBold Basics.Bool
    | SetFaint Basics.Bool
    | SetItalic Basics.Bool
    | SetUnderline Basics.Bool
    | SetBlink Basics.Bool
    | SetInverted Basics.Bool
    | SetFraktur Basics.Bool
    | SetFramed Basics.Bool
    | Linebreak
    | CarriageReturn
    | CursorUp Basics.Int
    | CursorDown Basics.Int
    | CursorForward Basics.Int
    | CursorBack Basics.Int
    | CursorPosition Basics.Int Basics.Int
    | CursorColumn Basics.Int
    | EraseDisplay EraseMode
    | EraseLine EraseMode
    | SaveCursorPosition
    | RestoreCursorPosition

The events relevant to interpreting the stream.


type Color
    = Black
    | Red
    | Green
    | Yellow
    | Blue
    | Magenta
    | Cyan
    | White
    | BrightBlack
    | BrightRed
    | BrightGreen
    | BrightYellow
    | BrightBlue
    | BrightMagenta
    | BrightCyan
    | BrightWhite
    | Custom Basics.Int Basics.Int Basics.Int

The colors applied to the foreground/background.


type EraseMode
    = EraseToBeginning
    | EraseToEnd
    | EraseAll

Method to erase the display or line.