Skip to content

Commit

Permalink
AnsiColor.hs: cleanup exported bits
Browse files Browse the repository at this point in the history
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information
Sergei Trofimovich committed Jul 31, 2014
1 parent 36172f1 commit 58c6ff7
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions AnsiColor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
-}

module AnsiColor
where
( Color(..)
, bold
, inColor
) where

import Data.List

Expand All @@ -33,30 +36,11 @@ col fg bf bg = show (fromEnum fg + 30) : bf' [show (fromEnum bg + 40)]
inColor :: Color -> Bool -> Color -> String -> String
inColor c bf bg txt = esc (col c bf bg) ++ txt ++ esc ["00"]

bold, italic, underline, inverse :: String -> String
bold = ansi "1" "22"
italic = ansi "3" "23"
underline = ansi "4" "24"
inverse = ansi "7" "27"
bold :: String -> String
bold = ansi "1" "22"
-- italic = ansi "3" "23"
-- underline = ansi "4" "24"
-- inverse = ansi "7" "27"

ansi :: String -> String -> String -> String
ansi on off txt = esc [on] ++ txt ++ esc [off]

{-
data Doc = Doc (Bool -> String -> String)
char chr = Doc (\_ c -> chr:c)
text str = Doc (\_ c -> str ++ c)
(Doc t) <> (Doc u) = Doc (\b c -> t b (u b c))
t <+> u = t <> char ' ' <> u
showDoc (Doc d) b = d b ""
color (Doc d) color = Doc (\ b c ->
if not b
then d b c
else inColor color False Default (d b ""))
-}

0 comments on commit 58c6ff7

Please sign in to comment.