|Version 4 (modified by judah, 5 years ago)|
Escape Sequences in the Prompt String
As of version 0.6.3 (#78), Haskeline will compute the correct width for input prompts that contain POSIX escape sequences such as color changes. However, the prompt string must indicate the end of each escape sequence, since there's no way for Haskeline to detect it automatically.
The end is denoted by the control character '\STX' (i.e., ASCII '\002'). Any substring in the prompt of the form "\ESC...\STX" will be treated as zero-width for the purposes of line-breaking.
On Windows, escape sequences of the form "\ESC...\STX" will be ignored.
prints out the prompt string "Prompt:" in green text. The first escape sequence ("\ESC[1;32m\STX") changes the text color to green, and the second ("\ESC[0m") turns the color back to normal.
If GHC (or the ghci-haskeline package) has been compiled against haskeline-0.6.3 or newer, adding the following line to your ~/.ghci file will turn the prompt string green:
:set prompt "\ESC[1;32m\STX%s>\ESC[0m\STX"