Ansi

ANSI escape sequences.

Functions and strings to control the screen, cursor, and text formatting in the terminal.

Color

wrapColor : Color -> String -> String

Display the given text in the given color.

setColor : Color -> String

Change all subsequent terminal output to the given color (even after program exit).

type Color
= NoColor
| Black
| Red
| Green
| Yellow
| Blue
| Magenta
| Cyan
| White

Font Styling

wrapFontWeight : FontWeight -> String -> String

Display string with the given font weight.

setFontWeight : FontWeight -> String

Change all terminal output from this point to the given font weight (even after program exit).

wrapItalic : String -> String

Display the given string as italic.

wrapUnderline : String -> String

Display the given string as underline.

wrapStrikeThrough : String -> String

Display the given string with a strikethrough.

setItalic : String

Change all terminal output from this point to italic (even after program exit).

unsetItalic : String

Stop displaying terminal output as italic.

setUnderline : String

Change all terminal output from this point to underline (even after program exit).

unsetUnderline : String

Stop displaying terminal output as underline.

setStrikeThrough : String

Change all terminal output from this point with a strikethrough (even after program exit).

unsetStrikeThrough : String

Stop displaying terminal output with a strikethrough.

type FontWeight
= NormalWeight
| Bold
| Faint

Screen

clearScreen : Direction -> String

Clear screen in the given Direction.

clearLine : Direction -> String

Clear the current line in the given direction.

type Direction
= Up
| Down
| Full

Direction for clear functions.

  • Down: Clear things after the cursor.
  • Up: Clear things before the cursor.
  • Full: Clear both directions.

Cursor

moveUpLines : Int -> String

Move the cursor up the given number of lines.

moveDownLines : Int -> String

Move the cursor down the given number of lines.

showCursor : String

Show the cursor.

hideCursor : String

Hide the cursor.

You should call showCursor before exiting your program, or the cursor will still be gone after exiting (gren-tui will handle this automatically if someone ctrl-c's out of your program).

Arrow Keys

arrowUp : String

ANSI escape sequence for the up arrow key.

arrowDown : String

ANSI escape sequence for the down arrow key.

arrowLeft : String

ANSI escape sequence for the left arrow key.

arrowRight : String

ANSI escape sequence for the right arrow key.