on master help sign in
Indicate the end of each escape sequence in the prompt string, since there's no way for Haskeline to detect it automatically.

Fix #1744

commitef1bd2491afdb0f204f5438f4a8d3d3181554e42 authorMort Yao <mort.yao@gmail.com> dateFri 21 Nov 2014, 21:16 (12 years ago) parentefd6f8a
1 file changed+12−1
src/Idris/Colours.hs+12−1
src/Idris/Colours.hs+12−1
@@ -52,6 +52,17 @@ colourise (IdrisColour c v u b i) str = setSGRCode sgr ++ str ++ setSGRCode [Res
5252 fg Nothing = []
5353 fg (Just c) = [SetColor Foreground (if v then Vivid else Dull) c]
5454
55+-- | Set the colour of a string using POSIX escape codes, with trailing '\STX' denoting the end
56+-- (required by Haskeline in the prompt string)
57+colouriseWithSTX :: IdrisColour -> String -> String
58+colouriseWithSTX (IdrisColour c v u b i) str = setSGRCode sgr ++ "\STX" ++ str ++ setSGRCode [Reset] ++ "\STX"
59+ where sgr = fg c ++
60+ (if u then [SetUnderlining SingleUnderline] else []) ++
61+ (if b then [SetConsoleIntensity BoldIntensity] else []) ++
62+ (if i then [SetItalicized True] else [])
63+ fg Nothing = []
64+ fg (Just c) = [SetColor Foreground (if v then Vivid else Dull) c]
65+
5566colouriseKwd :: ColourTheme -> String -> String
5667colouriseKwd t = colourise (keywordColour t)
5768
@@ -71,7 +82,7 @@ colouriseData :: ColourTheme -> String -> String
7182colouriseData t = colourise (dataColour t)
7283
7384colourisePrompt :: ColourTheme -> String -> String
74−colourisePrompt t = colourise (promptColour t)
85+colourisePrompt t = colouriseWithSTX (promptColour t)
7586
7687colouriseKeyword :: ColourTheme -> String -> String
7788colouriseKeyword t = colourise (keywordColour t)