Log interprets a stream of text and ANSI escape codes.
init : LineDiscipline -> Model
Construct an empty model.
update : String -> Model -> Model
Parse and interpret a chunk of ANSI output.
Trailing partial ANSI escape codes will be prepended to the chunk in the next
call to update
.
view : Model -> Html x
Render the model's logs as HTML.
Wraps a
around the the result of callingviewLine
for each line.As a cheap optimization, each line is rendered lazily.
viewLine : Line -> Html x
Render an individual line as HTML.
The line is rendered as a
containing elements with styling and classes for each Chunk.The
span
elements will have the following attributes:
style="font-weight: bold|normal"
class="ansi-COLOR-fg ansi-COLOR-bg ansi-bold"
...where each class is optional, and
COLOR
is one of:
black
red
green
yellow
blue
magenta
cyan
white
bright-black
bright-red
bright-green
bright-yellow
bright-blue
bright-magenta
bright-cyan
bright-white
If the chunk is inverted, the
-fg
and-bg
classes will have their colors swapped. If the chunk is bold, theansi-bold
class will be present.{ lineDiscipline : LineDiscipline , lines : Array Line , position : CursorPosition , savedPosition : Maybe CursorPosition , style : Style , remainder : String }
Model is populated by parsing ANSI character sequences and escape codes via
update
.
lines
contains all of the output that's been parsedposition
is the current position of the cursorstyle
is the style to be applied to any text that's printedremainder
is a partial ANSI escape sequence left around from an incomplete segment from the streamHow to interpret linebreaks.
Raw
: interpret\n
as just\n
, i.e. move down a line, retaining the cursor columnCooked
: interpret\n
as\r\n
, i.e. move down a line and go to the first column( List Chunk, Basics.Int )
A list of arbitrarily-sized chunks of output.
{ text : String , style : Style }
A blob of text paired with the style that was configured at the time.
{ row : Basics.Int , column : Basics.Int }
The coordinate in the window where text will be printed.
{ foreground : Maybe Ansi.Color , background : Maybe Ansi.Color , bold : Basics.Bool , faint : Basics.Bool , italic : Basics.Bool , underline : Basics.Bool , blink : Basics.Bool , inverted : Basics.Bool , fraktur : Basics.Bool , framed : Basics.Bool }
The current presentation state for any text that's printed.