on master help sign in
Merge pull request #1035 from puffnfresh/bug/parser-nocolour
6857d73Edwin Brady
src/Idris/Parser.hs+7−1
@@ -17,6 +17,7 @@ import qualified Text.Parser.Char as Chr
17import qualified Text.Parser.Token.Highlight as Hi
17import qualified Text.Parser.Token.Highlight as Hi
18
18
19import Text.PrettyPrint.ANSI.Leijen (Doc, plain)
19import Text.PrettyPrint.ANSI.Leijen (Doc, plain)
20+import qualified Text.PrettyPrint.ANSI.Leijen as ANSI
20
21
21import Idris.AbsSyntax hiding (namespace, params)
22import Idris.AbsSyntax hiding (namespace, params)
22import Idris.DSL
23import Idris.DSL
@@ -1120,6 +1121,11 @@ findFC x = let s = show (plain x) in
1120 (col, ':':msg) -> let pos = (read line, read col) in
1121 (col, ':':msg) -> let pos = (read line, read col) in
1121 (FC failname pos pos, msg)
1122 (FC failname pos pos, msg)
1122
1123
1124+-- | Check if the coloring matches the options and corrects if necessary
1125+fixColour :: Bool -> ANSI.Doc -> ANSI.Doc
1126+fixColour False doc = ANSI.plain doc
1127+fixColour True doc = doc
1128+
1123-- | A program is a list of declarations, possibly with associated
1129-- | A program is a list of declarations, possibly with associated
1124-- documentation strings.
1130-- documentation strings.
1125parseProg :: SyntaxInfo -> FilePath -> String -> Maybe Delta ->
1131parseProg :: SyntaxInfo -> FilePath -> String -> Maybe Delta ->
@@ -1132,7 +1138,7 @@ parseProg syn fname input mrk
1132 let (fc, msg) = findFC doc
1138 let (fc, msg) = findFC doc
1133 i <- getIState
1139 i <- getIState
1134 case idris_outputmode i of
1140 case idris_outputmode i of
1135− RawOutput -> ihputStrLn (idris_outh i) (show doc)
1141+ RawOutput -> ihputStrLn (idris_outh i) (show $ fixColour (idris_colourRepl i) doc)
1136 IdeSlave n -> ihWarn (idris_outh i) fc (P.text msg)
1142 IdeSlave n -> ihWarn (idris_outh i) fc (P.text msg)
1137 putIState (i { errSpan = Just fc })
1143 putIState (i { errSpan = Just fc })
1138 return []
1144 return []
src/Idris/REPL.hs−7
@@ -79,8 +79,6 @@ import Data.Version
79import Data.Word (Word)
79import Data.Word (Word)
80import Control.DeepSeq
80import Control.DeepSeq
81
81
82−import qualified Text.PrettyPrint.ANSI.Leijen as ANSI
83−
84import Debug.Trace
82import Debug.Trace
85
83
86-- | Run the REPL
84-- | Run the REPL
@@ -1349,11 +1347,6 @@ execScript expr = do i <- getIState
1349 res <- execute tm
1347 res <- execute tm
1350 runIO $ exitWith ExitSuccess
1348 runIO $ exitWith ExitSuccess
1351
1349
1352−-- | Check if the coloring matches the options and corrects if necessary
1353−fixColour :: Bool -> ANSI.Doc -> ANSI.Doc
1354−fixColour False doc = ANSI.plain doc
1355−fixColour True doc = doc
1356−
1357-- | Get the platform-specific, user-specific Idris dir
1350-- | Get the platform-specific, user-specific Idris dir
1358getIdrisUserDataDir :: Idris FilePath
1351getIdrisUserDataDir :: Idris FilePath
1359getIdrisUserDataDir = runIO $ getAppUserDataDirectory "idris"
1352getIdrisUserDataDir = runIO $ getAppUserDataDirectory "idris"