module Internal.Terminal (write, read, red, blue, green, magenta, yellow, cyan, lightBlue, black, white, reset, underline, italic, newline, indent, message, header, blank, paragraphs) where
import Basics
import qualified Data.Text
import List (List)
import qualified Text
import qualified Prelude as P
write :: Text.Text -> P.IO ()
write :: Text -> IO ()
write Text
string =
String -> IO ()
P.putStr (Text -> String
Data.Text.unpack Text
string)
read :: P.IO Text.Text
read :: IO Text
read =
IO String
P.getLine
IO String -> (IO String -> IO Text) -> IO Text
forall a b. a -> (a -> b) -> b
|> (String -> Text) -> IO String -> IO Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
P.fmap String -> Text
Data.Text.pack
red :: Text.Text
red :: Text
red =
Text
"\x1b[31m"
blue :: Text.Text
blue :: Text
blue =
Text
"\x1b[34m"
magenta :: Text.Text
magenta :: Text
magenta =
Text
"\x1b[35m"
green :: Text.Text
green :: Text
green =
Text
"\x1b[32m"
yellow :: Text.Text
yellow :: Text
yellow =
Text
"\x1b[33m"
cyan :: Text.Text
cyan :: Text
cyan =
Text
"\x1b[36m"
lightBlue :: Text.Text
lightBlue :: Text
lightBlue =
Text
"\x1b[94m"
black :: Text.Text
black :: Text
black =
Text
"\x1b[30m"
white :: Text.Text
white :: Text
white =
Text
"\x1b[37m"
reset :: Text.Text
reset :: Text
reset =
Text
"\x1b[0m"
newline :: Text.Text
newline :: Text
newline =
Text
"\n"
blank :: Text.Text
blank :: Text
blank =
Text
newline Text -> Text -> Text
forall appendable.
Semigroup appendable =>
appendable -> appendable -> appendable
++ Text
newline
underline :: Text.Text
underline :: Text
underline =
Text
"\x1b[4m"
italic :: Text.Text
italic :: Text
italic =
Text
"\x1b[3m"
indent :: Int -> Text.Text
indent :: Int -> Text
indent Int
number =
Int -> Text -> Text
Text.repeat Int
number Text
" "
message :: Text.Text -> Text.Text -> Text.Text -> List Text.Text -> P.IO ()
message :: Text -> Text -> Text -> List Text -> IO ()
message Text
color Text
title Text
location List Text
content = do
Text -> IO ()
write (Text
color Text -> Text -> Text
forall appendable.
Semigroup appendable =>
appendable -> appendable -> appendable
++ Text -> Text -> Text
header Text
title Text
location Text -> Text -> Text
forall appendable.
Semigroup appendable =>
appendable -> appendable -> appendable
++ Text
reset)
Text -> IO ()
write Text
blank
Text -> IO ()
write (List Text -> Text
paragraphs List Text
content)
Text -> IO ()
write Text
blank
header :: Text.Text -> Text.Text -> Text.Text
Text
title Text
location =
let number :: Int
number = Int
75 Int -> Int -> Int
forall number. Num number => number -> number -> number
- Text -> Int
Text.length Text
title Int -> Int -> Int
forall number. Num number => number -> number -> number
- Text -> Int
Text.length Text
location
dashes :: Text
dashes = Int -> Text -> Text
Text.repeat Int
number Text
"-"
in Text
"-- " Text -> Text -> Text
forall appendable.
Semigroup appendable =>
appendable -> appendable -> appendable
++ Text -> Text
Text.toUpper Text
title Text -> Text -> Text
forall appendable.
Semigroup appendable =>
appendable -> appendable -> appendable
++ Text
" " Text -> Text -> Text
forall appendable.
Semigroup appendable =>
appendable -> appendable -> appendable
++ Text
dashes Text -> Text -> Text
forall appendable.
Semigroup appendable =>
appendable -> appendable -> appendable
++ Text
" " Text -> Text -> Text
forall appendable.
Semigroup appendable =>
appendable -> appendable -> appendable
++ Text
location Text -> Text -> Text
forall appendable.
Semigroup appendable =>
appendable -> appendable -> appendable
++ Text
" "
paragraphs :: List Text.Text -> Text.Text
paragraphs :: List Text -> Text
paragraphs =
Text -> List Text -> Text
Text.join Text
blank