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.
ef1bd24Mort Yao
src/Idris/Colours.hs+12−1
@@ -52,6 +52,17 @@ colourise (IdrisColour c v u b i) str = setSGRCode sgr ++ str ++ setSGRCode [Res
52 fg Nothing = []
52 fg Nothing = []
53 fg (Just c) = [SetColor Foreground (if v then Vivid else Dull) c]
53 fg (Just c) = [SetColor Foreground (if v then Vivid else Dull) c]
54
54
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+
55colouriseKwd :: ColourTheme -> String -> String
66colouriseKwd :: ColourTheme -> String -> String
56colouriseKwd t = colourise (keywordColour t)
67colouriseKwd t = colourise (keywordColour t)
57
68
@@ -71,7 +82,7 @@ colouriseData :: ColourTheme -> String -> String
71colouriseData t = colourise (dataColour t)
82colouriseData t = colourise (dataColour t)
72
83
73colourisePrompt :: ColourTheme -> String -> String
84colourisePrompt :: ColourTheme -> String -> String
74−colourisePrompt t = colourise (promptColour t)
85+colourisePrompt t = colouriseWithSTX (promptColour t)
75
86
76colouriseKeyword :: ColourTheme -> String -> String
87colouriseKeyword :: ColourTheme -> String -> String
77colouriseKeyword t = colourise (keywordColour t)
88colouriseKeyword t = colourise (keywordColour t)