on master help sign in
Merge pull request #1035 from puffnfresh/bug/parser-nocolour

Make parsing respect the nocolour flag

commit6857d73e5b55a641b0003d049a4a0957bfd0428b authorEdwin Brady <edwin.brady@gmail.com> dateWed 9 Apr 2014, 13:37 (13 years ago) parenta96684a6aeacd8
2 files changed+7−8
src/Idris/Parser.hs+7−1 src/Idris/REPL.hs−7
src/Idris/Parser.hs+7−1
@@ -17,6 +17,7 @@ import qualified Text.Parser.Char as Chr
1717import qualified Text.Parser.Token.Highlight as Hi
1818
1919import Text.PrettyPrint.ANSI.Leijen (Doc, plain)
20+import qualified Text.PrettyPrint.ANSI.Leijen as ANSI
2021
2122import Idris.AbsSyntax hiding (namespace, params)
2223import Idris.DSL
@@ -1120,6 +1121,11 @@ findFC x = let s = show (plain x) in
11201121 (col, ':':msg) -> let pos = (read line, read col) in
11211122 (FC failname pos pos, msg)
11221123
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+
11231129-- | A program is a list of declarations, possibly with associated
11241130-- documentation strings.
11251131parseProg :: SyntaxInfo -> FilePath -> String -> Maybe Delta ->
@@ -1132,7 +1138,7 @@ parseProg syn fname input mrk
11321138 let (fc, msg) = findFC doc
11331139 i <- getIState
11341140 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)
11361142 IdeSlave n -> ihWarn (idris_outh i) fc (P.text msg)
11371143 putIState (i { errSpan = Just fc })
11381144 return []
src/Idris/REPL.hs−7
@@ -79,8 +79,6 @@ import Data.Version
7979import Data.Word (Word)
8080import Control.DeepSeq
8181
82−import qualified Text.PrettyPrint.ANSI.Leijen as ANSI
83−
8482import Debug.Trace
8583
8684-- | Run the REPL
@@ -1349,11 +1347,6 @@ execScript expr = do i <- getIState
13491347 res <- execute tm
13501348 runIO $ exitWith ExitSuccess
13511349
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−
13571350-- | Get the platform-specific, user-specific Idris dir
13581351getIdrisUserDataDir :: Idris FilePath
13591352getIdrisUserDataDir = runIO $ getAppUserDataDirectory "idris"