Modifications to compile on Windows

This commit is contained in:
Randy Valis 2019-03-03 17:23:13 -05:00
parent f1b580a2f7
commit b1c78ef216
4 changed files with 15 additions and 10 deletions

View File

@ -55,7 +55,7 @@ library
, blaze-html
, blaze-markup
, text
, unix
, ansi-terminal >= 0.9
, cmark
default-language: Haskell2010

View File

@ -4,7 +4,11 @@
#include <assert.h>
#include "carp_stdbool.h"
#include <stddef.h>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#include <windows.h>
#else
#include <sys/wait.h>
#endif
#include <signal.h>
typedef char* String;

View File

@ -1,7 +1,7 @@
module ColorText where
import System.Posix.Terminal (queryTerminal)
import System.Posix.IO (stdOutput)
import System.Console.ANSI hiding (Blue, Red, Yellow, Green, White)
import System.IO
import Util
@ -9,10 +9,11 @@ data TextColor = Blue | Red | Yellow | Green | White
strWithColor :: TextColor -> String -> String
strWithColor color str =
if useColors
then "\x1b[" ++ col ++ "m" ++ str ++ "\x1b[0m"
else str
where useColors = platform /= Windows
--if useColors
"\x1b[" ++ col ++ "m" ++ str ++ "\x1b[0m"
--then "\x1b[" ++ col ++ "m" ++ str ++ "\x1b[0m"
--else str
where --useColors = platform /= Windows
col = case color of
Red -> "31"
Green -> "32"
@ -23,7 +24,7 @@ strWithColor color str =
putStrWithColor :: TextColor -> String -> IO ()
putStrWithColor color str =
do
istty <- queryTerminal stdOutput
istty <- hSupportsANSIColor stdout
putStr $ if istty then strWithColor color str else str
putStrLnWithColor :: TextColor -> String -> IO ()

View File

@ -39,7 +39,7 @@ packages:
- '.'
# Dependency packages to be pulled from upstream that are not in the resolver
# (e.g., acme-missiles-0.3)
extra-deps: [intero-0.1.28]
extra-deps: [intero-0.1.28, ansi-terminal-0.9]
# Override default flag values for local packages and extra-deps
flags: {}
@ -63,4 +63,4 @@ extra-package-dbs: []
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
# compiler-check: newer-minor