initial commit
This commit is contained in:
17
src/Lib.hs
Normal file
17
src/Lib.hs
Normal file
@ -0,0 +1,17 @@
|
||||
module Lib (e, modify, Format (..)) where
|
||||
|
||||
type Code = Int
|
||||
type Input = String
|
||||
data Format = Tail Input
|
||||
| Node Code Format
|
||||
deriving (Show)
|
||||
|
||||
instance Read Format where
|
||||
readsPrec _ s = [(Tail s, [])]
|
||||
|
||||
e :: Int -> Format -> Format
|
||||
e code input = Node code input
|
||||
|
||||
modify :: (Int -> Int) -> Format -> Format
|
||||
modify f (Tail input) = Tail input
|
||||
modify f (Node code input) = Node (f code) input
|
6
src/Text/Termcolor.hs
Normal file
6
src/Text/Termcolor.hs
Normal file
@ -0,0 +1,6 @@
|
||||
module Text.Termcolor (format) where
|
||||
import Lib
|
||||
|
||||
format :: Format -> String
|
||||
format (Tail input) = input
|
||||
format (Node code f) = "\ESC[" ++ (show code) ++ "m" ++ (format f)
|
23
src/Text/Termcolor/Background.hs
Normal file
23
src/Text/Termcolor/Background.hs
Normal file
@ -0,0 +1,23 @@
|
||||
module Text.Termcolor.Background ( red
|
||||
, black
|
||||
, green
|
||||
, yellow
|
||||
, magenta
|
||||
, blue
|
||||
, cyan
|
||||
, gray
|
||||
, white) where
|
||||
|
||||
import Lib
|
||||
|
||||
black = e 40
|
||||
red = e 41
|
||||
green = e 42
|
||||
yellow = e 44
|
||||
blue = e 44
|
||||
magenta = e 45
|
||||
cyan = e 46
|
||||
gray = e 47
|
||||
|
||||
white = e 107
|
||||
|
23
src/Text/Termcolor/Foreground.hs
Normal file
23
src/Text/Termcolor/Foreground.hs
Normal file
@ -0,0 +1,23 @@
|
||||
module Text.Termcolor.Foreground ( red
|
||||
, black
|
||||
, green
|
||||
, yellow
|
||||
, magenta
|
||||
, blue
|
||||
, cyan
|
||||
, gray
|
||||
, white) where
|
||||
|
||||
import Lib
|
||||
|
||||
black = e 30
|
||||
red = e 31
|
||||
green = e 32
|
||||
yellow = e 33
|
||||
blue = e 34
|
||||
magenta = e 35
|
||||
cyan = e 36
|
||||
gray = e 37
|
||||
|
||||
white = e 97
|
||||
|
22
src/Text/Termcolor/Style.hs
Normal file
22
src/Text/Termcolor/Style.hs
Normal file
@ -0,0 +1,22 @@
|
||||
module Text.Termcolor.Style ( bold
|
||||
, dim
|
||||
, underline
|
||||
, blink
|
||||
, invert
|
||||
, hidden
|
||||
, light
|
||||
, reset) where
|
||||
|
||||
import Lib
|
||||
|
||||
bold = e 1
|
||||
dim = e 2
|
||||
underline = e 4
|
||||
blink = e 5
|
||||
invert = e 7
|
||||
hidden = e 8
|
||||
|
||||
reset = e 0
|
||||
|
||||
light = modify (+60)
|
||||
|
Reference in New Issue
Block a user