initial commit

This commit is contained in:
Mahdi Dibaiee
2017-03-30 15:40:17 +04:30
commit 9e3de66aab
11 changed files with 901 additions and 0 deletions

17
src/Lib.hs Normal file
View 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
View 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)

View 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

View 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

View 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)