Skip to content

Commit 5ca0225

Browse files
authored
Merge pull request #520 from mpilgrem/Fix75
Fix #75: Windows 10: Enable ANSI-capable terminals
2 parents 5072490 + 92c7429 commit 5ca0225

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test_script:
66
- set HASKELL_DEPENDENCIES=apply-refact
77
- ps: Invoke-Expression (Invoke-WebRequest 'https://raw.githubusercontent.com/ndmitchell/neil/master/appveyor.ps1')
88
# - set UNIPLATE_VERBOSE=-1 # Temporary
9-
- stack exec -- hlint test
9+
- stack exec -- hlint --test
1010
- stack exec -- hlint src
1111
# Test the documented way of running it in appveyor
1212
- ps: Invoke-Command ([Scriptblock]::Create((Invoke-WebRequest 'https://raw.githubusercontent.com/ndmitchell/hlint/master/misc/appveyor.ps1').Content)) -ArgumentList @('--version')

hlint.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ library
6565
cpphs >= 1.20.1,
6666
cmdargs >= 0.10,
6767
uniplate >= 1.5,
68-
ansi-terminal >= 0.6.2,
68+
ansi-terminal >= 0.8.1,
6969
extra >= 1.7.3,
7070
refact >= 0.3,
7171
aeson >= 1.1.2.0,

src/CmdLine.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Language.Haskell.GhclibParserEx.GHC.Driver.Session as GhclibParserEx
2020
import DynFlags hiding (verbosity)
2121

2222
import Language.Preprocessor.Cpphs
23-
import System.Console.ANSI(hSupportsANSI)
23+
import System.Console.ANSI(hSupportsANSIWithoutEmulation)
2424
import System.Console.CmdArgs.Explicit(helpText, HelpFormat(..))
2525
import System.Console.CmdArgs.Implicit
2626
import System.Directory.Extra
@@ -29,7 +29,6 @@ import System.Exit
2929
import System.FilePath
3030
import System.IO
3131
import System.IO.Error
32-
import System.Info.Extra
3332
import System.Process
3433
import System.FilePattern
3534

@@ -89,7 +88,7 @@ data ColorMode
8988

9089

9190
instance Default ColorMode where
92-
def = if isWindows then Never else Auto
91+
def = Auto
9392

9493

9594
data Cmd
@@ -138,7 +137,7 @@ mode = cmdArgsMode $ modes
138137
,cmdGivenHints = nam "hint" &= typFile &= help "Hint/ignore file to use"
139138
,cmdWithGroups = nam_ "with-group" &= typ "GROUP" &= help "Extra hint groups to use"
140139
,cmdGit = nam "git" &= help "Run on files tracked by git"
141-
,cmdColor = nam "colour" &= name "color" &= opt Always &= typ "always/never/auto" &= help "Color output (requires ANSI terminal; auto means on when $TERM is supported; by itself, selects always)"
140+
,cmdColor = nam "colour" &= name "color" &= opt Always &= typ "always/never/auto" &= help "Color output (requires an ANSI terminal; 'auto' means on if the standard output channel can support ANSI; by itself, selects 'always')"
142141
,cmdThreads = 1 &= name "threads" &= name "j" &= opt (0 :: Int) &= help "Number of threads to use (-j for all)"
143142
,cmdIgnore = nam "ignore" &= typ "HINT" &= help "Ignore a particular hint"
144143
,cmdShowAll = nam "show" &= help "Show all ignored ideas"
@@ -222,7 +221,9 @@ cmdUseColour :: Cmd -> IO Bool
222221
cmdUseColour cmd = case cmdColor cmd of
223222
Always -> pure True
224223
Never -> pure False
225-
Auto -> hSupportsANSI stdout
224+
Auto -> do
225+
supportsANSI <- hSupportsANSIWithoutEmulation stdout
226+
pure $ Just True == supportsANSI
226227

227228

228229
"." <\> x = x

0 commit comments

Comments
 (0)