Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/Text/ANSI.idr
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@ Show DecoratedString where
show dstr = escapeSGR dstr.sgr ++ dstr.str ++ escapeSGR [Reset]

export
colored : Color -> String -> DecoratedString
colored c = MkDString [SetForeground c]
fromString : String -> DecoratedString
fromString = MkDString []

export
background : Color -> String -> DecoratedString
background c = MkDString [SetBackground c]
addSGR : SGR -> DecoratedString -> DecoratedString
addSGR sgr (MkDString sgrs str) = MkDString (sgr :: sgrs) str

export
bolden : String -> DecoratedString
bolden = MkDString [SetStyle Bold]
colored : Color -> DecoratedString -> DecoratedString
colored c = addSGR $ SetForeground c

export
italicize : String -> DecoratedString
italicize = MkDString [SetStyle Italic]
background : Color -> DecoratedString -> DecoratedString
background c = addSGR $ SetBackground c

export
underline : String -> DecoratedString
underline = MkDString [SetStyle SingleUnderline]
bolden : DecoratedString -> DecoratedString
bolden = addSGR $ SetStyle Bold

export
italicize : DecoratedString -> DecoratedString
italicize = addSGR $ SetStyle Italic

export
underline : DecoratedString -> DecoratedString
underline = addSGR $ SetStyle SingleUnderline