Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
63d44818
Commit
63d44818
authored
Jan 15, 2015
by
Andrey Mokhov
Browse files
Add putColoured.
parent
11ad7076
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Oracles/Builder.hs
View file @
63d44818
...
...
@@ -7,6 +7,7 @@ module Oracles.Builder (
import
Data.Char
import
Base
import
Util
import
Oracles.Base
import
Oracles.Flag
import
Oracles.Option
...
...
@@ -108,9 +109,11 @@ run builder as = do
terseRun
::
ShowArgs
a
=>
Builder
->
a
->
Action
()
terseRun
builder
as
=
do
args
<-
showArgs
as
putNormal
$
"/--------
\n
| Running "
++
show
builder
++
" with arguments:"
mapM_
(
putNormal
.
(
"| "
++
))
$
interestingInfo
builder
args
putNormal
"
\\
--------"
putColoured
Vivid
White
$
"/--------
\n
"
++
"| Running "
++
show
builder
++
" with arguments:"
mapM_
(
putColoured
Vivid
White
.
(
"| "
++
))
$
interestingInfo
builder
args
putColoured
Vivid
White
$
"
\\
--------"
quietly
$
run
builder
as
interestingInfo
::
Builder
->
[
String
]
->
[
String
]
...
...
src/Util.hs
View file @
63d44818
module
Util
(
module
Data
.
Char
,
module
System
.
Console
.
ANSI
,
replaceIf
,
replaceEq
,
replaceSeparators
,
chunksOfSize
chunksOfSize
,
putColoured
)
where
import
Base
import
Data.Char
import
System.Console.ANSI
import
System.IO
replaceIf
::
(
a
->
Bool
)
->
a
->
[
a
]
->
[
a
]
replaceIf
p
to
=
map
(
\
from
->
if
p
from
then
to
else
from
)
...
...
@@ -30,3 +34,10 @@ chunksOfSize size ss = reverse chunk : chunksOfSize size rest
if
newSize
>
size
then
(
chunk
,
s
:
ss
)
else
(
newChunk
,
rest
)
putColoured
::
ColorIntensity
->
Color
->
String
->
Action
()
putColoured
intensity
colour
msg
=
do
liftIO
$
setSGR
[
SetColor
Foreground
intensity
colour
]
putNormal
msg
liftIO
$
setSGR
[]
liftIO
$
hFlush
stdout
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment