mirror of
https://github.com/github/semantic.git
synced 2024-12-25 16:02:43 +03:00
Format strings with attributes.
This commit is contained in:
parent
f0286335fb
commit
5617cceee2
@ -1,5 +1,7 @@
|
||||
module Console where
|
||||
|
||||
import Data.Char
|
||||
|
||||
data Colour = Black | Red | Green | Yellow | Blue | Purple | Cyan | White
|
||||
deriving Bounded
|
||||
|
||||
@ -36,3 +38,6 @@ instance Enum Style where
|
||||
toEnum 4 = Underline
|
||||
|
||||
data Attribute = Attribute { colour :: Colour, style :: Style }
|
||||
|
||||
applyAttribute :: Attribute -> String -> String
|
||||
applyAttribute attribute string = "\x001b[" ++ [ chr . fromEnum $ style attribute ] ++ ";" ++ [ chr . fromEnum $ colour attribute ] ++ "m" ++ string ++ "\x001b[0m"
|
||||
|
Loading…
Reference in New Issue
Block a user