module System.Terminal.Emulator.Parsing.Types where
import Data.Text (Text)
import Data.Vector (Vector)
import System.Console.ANSI.Types (SGR)
import qualified System.Console.ANSI.Types as SGR
import System.Terminal.Emulator.DECPrivateMode (DECPrivateMode)
data TermAtom
= TermAtom_VisibleChar !Char
| TermAtom_SingleCharacterFunction !SingleCharacterFunction
| TermAtom_SingleCharacterFunctionUnknown !Char
| TermAtom_EscapeSequence !EscapeSequence
| TermAtom_EscapeSequenceUnknown !Text
deriving (TermAtom -> TermAtom -> Bool
(TermAtom -> TermAtom -> Bool)
-> (TermAtom -> TermAtom -> Bool) -> Eq TermAtom
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TermAtom -> TermAtom -> Bool
$c/= :: TermAtom -> TermAtom -> Bool
== :: TermAtom -> TermAtom -> Bool
$c== :: TermAtom -> TermAtom -> Bool
Eq, Int -> TermAtom -> ShowS
[TermAtom] -> ShowS
TermAtom -> String
(Int -> TermAtom -> ShowS)
-> (TermAtom -> String) -> ([TermAtom] -> ShowS) -> Show TermAtom
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TermAtom] -> ShowS
$cshowList :: [TermAtom] -> ShowS
show :: TermAtom -> String
$cshow :: TermAtom -> String
showsPrec :: Int -> TermAtom -> ShowS
$cshowsPrec :: Int -> TermAtom -> ShowS
Show)
data SingleCharacterFunction
=
Control_Bell
|
Control_Backspace
|
Control_CarriageReturn
|
Control_ReturnTerminalStatus
|
Control_FormFeed
|
Control_LineFeed
|
Control_SwitchToStandardCharacterSet
|
Control_SwitchToAlternateCharacterSet
|
Control_Tab
|
Control_VerticalTab
deriving (SingleCharacterFunction -> SingleCharacterFunction -> Bool
(SingleCharacterFunction -> SingleCharacterFunction -> Bool)
-> (SingleCharacterFunction -> SingleCharacterFunction -> Bool)
-> Eq SingleCharacterFunction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SingleCharacterFunction -> SingleCharacterFunction -> Bool
$c/= :: SingleCharacterFunction -> SingleCharacterFunction -> Bool
== :: SingleCharacterFunction -> SingleCharacterFunction -> Bool
$c== :: SingleCharacterFunction -> SingleCharacterFunction -> Bool
Eq, Int -> SingleCharacterFunction -> ShowS
[SingleCharacterFunction] -> ShowS
SingleCharacterFunction -> String
(Int -> SingleCharacterFunction -> ShowS)
-> (SingleCharacterFunction -> String)
-> ([SingleCharacterFunction] -> ShowS)
-> Show SingleCharacterFunction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SingleCharacterFunction] -> ShowS
$cshowList :: [SingleCharacterFunction] -> ShowS
show :: SingleCharacterFunction -> String
$cshow :: SingleCharacterFunction -> String
showsPrec :: Int -> SingleCharacterFunction -> ShowS
$cshowsPrec :: Int -> SingleCharacterFunction -> ShowS
Show)
data EscapeSequence
=
Esc_ReverseIndex
|
Esc_RIS
|
Esc_DECPAM
|
Esc_DECPNM
|
ESC_SetG0CharacterSet !Text
| Esc_CSI !ControlSequenceIntroducer
| Esc_OSC !OperatingSystemCommand
deriving (EscapeSequence -> EscapeSequence -> Bool
(EscapeSequence -> EscapeSequence -> Bool)
-> (EscapeSequence -> EscapeSequence -> Bool) -> Eq EscapeSequence
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EscapeSequence -> EscapeSequence -> Bool
$c/= :: EscapeSequence -> EscapeSequence -> Bool
== :: EscapeSequence -> EscapeSequence -> Bool
$c== :: EscapeSequence -> EscapeSequence -> Bool
Eq, Int -> EscapeSequence -> ShowS
[EscapeSequence] -> ShowS
EscapeSequence -> String
(Int -> EscapeSequence -> ShowS)
-> (EscapeSequence -> String)
-> ([EscapeSequence] -> ShowS)
-> Show EscapeSequence
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EscapeSequence] -> ShowS
$cshowList :: [EscapeSequence] -> ShowS
show :: EscapeSequence -> String
$cshow :: EscapeSequence -> String
showsPrec :: Int -> EscapeSequence -> ShowS
$cshowsPrec :: Int -> EscapeSequence -> ShowS
Show)
data ControlSequenceIntroducer
=
CSI_CharacterPositionAbsolute !Int
|
CSI_CharacterPositionRelative !Int
|
CSI_CursorUp !Int
|
CSI_CursorDown !Int
|
CSI_CursorForward !Int
|
CSI_CursorBack !Int
|
CSI_EraseInLine !EraseInLineParam
|
CSI_InsertBlankCharacters !Int
|
CSI_InsertBlankLines !Int
|
CSI_DeleteChars !Int
|
CSI_DeleteLines !Int
|
CSI_CursorCharacterAbsolute !Int
|
CSI_CursorPosition !Int !Int
|
CSI_HorizontalVerticalPosition !Int !Int
|
CSI_LinePositionAbsolute !Int
|
CSI_LinePositionRelative !Int
|
CSI_ScrollUp !Int
|
CSI_ScrollDown !Int
|
CSI_EraseInDisplay !EraseInDisplayParam
|
CSI_EraseCharacters !Int
|
CSI_WindowManipulation !WindowManipulation
|
CSI_DeviceStatusReport !DeviceStatusReport
|
CSI_SoftTerminalReset
|
CSI_SetMode !Mode
|
CSI_ResetMode !Mode
|
CSI_SendDeviceAttributes
|
CSI_SendDeviceAttributesSecondary !SendDeviceAttributesSecondary
|
CSI_RequestDECPrivateMode !Int
|
CSI_DECSTBM !(Maybe Int) !(Maybe Int)
|
CSI_DECSET !DECPrivateMode
|
CSI_DECSET_Unknown !Int
|
CSI_DECRST !DECPrivateMode
|
CSI_DECRST_Unknown !Int
| CSI_SGR !(Vector SGR)
deriving (ControlSequenceIntroducer -> ControlSequenceIntroducer -> Bool
(ControlSequenceIntroducer -> ControlSequenceIntroducer -> Bool)
-> (ControlSequenceIntroducer -> ControlSequenceIntroducer -> Bool)
-> Eq ControlSequenceIntroducer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ControlSequenceIntroducer -> ControlSequenceIntroducer -> Bool
$c/= :: ControlSequenceIntroducer -> ControlSequenceIntroducer -> Bool
== :: ControlSequenceIntroducer -> ControlSequenceIntroducer -> Bool
$c== :: ControlSequenceIntroducer -> ControlSequenceIntroducer -> Bool
Eq, Int -> ControlSequenceIntroducer -> ShowS
[ControlSequenceIntroducer] -> ShowS
ControlSequenceIntroducer -> String
(Int -> ControlSequenceIntroducer -> ShowS)
-> (ControlSequenceIntroducer -> String)
-> ([ControlSequenceIntroducer] -> ShowS)
-> Show ControlSequenceIntroducer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ControlSequenceIntroducer] -> ShowS
$cshowList :: [ControlSequenceIntroducer] -> ShowS
show :: ControlSequenceIntroducer -> String
$cshow :: ControlSequenceIntroducer -> String
showsPrec :: Int -> ControlSequenceIntroducer -> ShowS
$cshowsPrec :: Int -> ControlSequenceIntroducer -> ShowS
Show)
data EraseInLineParam
=
ClearFromCursorToEndOfLine
|
ClearFromCursorToBeginningOfLine
|
ClearEntireLine
deriving (EraseInLineParam -> EraseInLineParam -> Bool
(EraseInLineParam -> EraseInLineParam -> Bool)
-> (EraseInLineParam -> EraseInLineParam -> Bool)
-> Eq EraseInLineParam
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EraseInLineParam -> EraseInLineParam -> Bool
$c/= :: EraseInLineParam -> EraseInLineParam -> Bool
== :: EraseInLineParam -> EraseInLineParam -> Bool
$c== :: EraseInLineParam -> EraseInLineParam -> Bool
Eq, Int -> EraseInLineParam -> ShowS
[EraseInLineParam] -> ShowS
EraseInLineParam -> String
(Int -> EraseInLineParam -> ShowS)
-> (EraseInLineParam -> String)
-> ([EraseInLineParam] -> ShowS)
-> Show EraseInLineParam
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EraseInLineParam] -> ShowS
$cshowList :: [EraseInLineParam] -> ShowS
show :: EraseInLineParam -> String
$cshow :: EraseInLineParam -> String
showsPrec :: Int -> EraseInLineParam -> ShowS
$cshowsPrec :: Int -> EraseInLineParam -> ShowS
Show)
data EraseInDisplayParam
=
EraseBelow
|
EraseAbove
|
EraseAll
|
EraseSavedLines
deriving (EraseInDisplayParam -> EraseInDisplayParam -> Bool
(EraseInDisplayParam -> EraseInDisplayParam -> Bool)
-> (EraseInDisplayParam -> EraseInDisplayParam -> Bool)
-> Eq EraseInDisplayParam
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EraseInDisplayParam -> EraseInDisplayParam -> Bool
$c/= :: EraseInDisplayParam -> EraseInDisplayParam -> Bool
== :: EraseInDisplayParam -> EraseInDisplayParam -> Bool
$c== :: EraseInDisplayParam -> EraseInDisplayParam -> Bool
Eq, Int -> EraseInDisplayParam -> ShowS
[EraseInDisplayParam] -> ShowS
EraseInDisplayParam -> String
(Int -> EraseInDisplayParam -> ShowS)
-> (EraseInDisplayParam -> String)
-> ([EraseInDisplayParam] -> ShowS)
-> Show EraseInDisplayParam
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EraseInDisplayParam] -> ShowS
$cshowList :: [EraseInDisplayParam] -> ShowS
show :: EraseInDisplayParam -> String
$cshow :: EraseInDisplayParam -> String
showsPrec :: Int -> EraseInDisplayParam -> ShowS
$cshowsPrec :: Int -> EraseInDisplayParam -> ShowS
Show)
data WindowManipulation
=
SaveIconAndWindowTitleOnStack
|
RestoreIconAndWindowTitleOnStack
deriving (WindowManipulation -> WindowManipulation -> Bool
(WindowManipulation -> WindowManipulation -> Bool)
-> (WindowManipulation -> WindowManipulation -> Bool)
-> Eq WindowManipulation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WindowManipulation -> WindowManipulation -> Bool
$c/= :: WindowManipulation -> WindowManipulation -> Bool
== :: WindowManipulation -> WindowManipulation -> Bool
$c== :: WindowManipulation -> WindowManipulation -> Bool
Eq, Int -> WindowManipulation -> ShowS
[WindowManipulation] -> ShowS
WindowManipulation -> String
(Int -> WindowManipulation -> ShowS)
-> (WindowManipulation -> String)
-> ([WindowManipulation] -> ShowS)
-> Show WindowManipulation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WindowManipulation] -> ShowS
$cshowList :: [WindowManipulation] -> ShowS
show :: WindowManipulation -> String
$cshow :: WindowManipulation -> String
showsPrec :: Int -> WindowManipulation -> ShowS
$cshowsPrec :: Int -> WindowManipulation -> ShowS
Show)
data DeviceStatusReport
=
StatusReport
|
ReportCursorPosition
deriving (DeviceStatusReport -> DeviceStatusReport -> Bool
(DeviceStatusReport -> DeviceStatusReport -> Bool)
-> (DeviceStatusReport -> DeviceStatusReport -> Bool)
-> Eq DeviceStatusReport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeviceStatusReport -> DeviceStatusReport -> Bool
$c/= :: DeviceStatusReport -> DeviceStatusReport -> Bool
== :: DeviceStatusReport -> DeviceStatusReport -> Bool
$c== :: DeviceStatusReport -> DeviceStatusReport -> Bool
Eq, Int -> DeviceStatusReport -> ShowS
[DeviceStatusReport] -> ShowS
DeviceStatusReport -> String
(Int -> DeviceStatusReport -> ShowS)
-> (DeviceStatusReport -> String)
-> ([DeviceStatusReport] -> ShowS)
-> Show DeviceStatusReport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeviceStatusReport] -> ShowS
$cshowList :: [DeviceStatusReport] -> ShowS
show :: DeviceStatusReport -> String
$cshow :: DeviceStatusReport -> String
showsPrec :: Int -> DeviceStatusReport -> ShowS
$cshowsPrec :: Int -> DeviceStatusReport -> ShowS
Show)
data Mode
=
KeyboardActionMode
|
InsertReplaceMode
|
SendReceive
|
AutomaticNewlineNormalLinefeed
deriving (Mode -> Mode -> Bool
(Mode -> Mode -> Bool) -> (Mode -> Mode -> Bool) -> Eq Mode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Mode -> Mode -> Bool
$c/= :: Mode -> Mode -> Bool
== :: Mode -> Mode -> Bool
$c== :: Mode -> Mode -> Bool
Eq, Int -> Mode -> ShowS
[Mode] -> ShowS
Mode -> String
(Int -> Mode -> ShowS)
-> (Mode -> String) -> ([Mode] -> ShowS) -> Show Mode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Mode] -> ShowS
$cshowList :: [Mode] -> ShowS
show :: Mode -> String
$cshow :: Mode -> String
showsPrec :: Int -> Mode -> ShowS
$cshowsPrec :: Int -> Mode -> ShowS
Show)
data SendDeviceAttributesSecondary
= RequestTerminalIdentificationCode
deriving (SendDeviceAttributesSecondary
-> SendDeviceAttributesSecondary -> Bool
(SendDeviceAttributesSecondary
-> SendDeviceAttributesSecondary -> Bool)
-> (SendDeviceAttributesSecondary
-> SendDeviceAttributesSecondary -> Bool)
-> Eq SendDeviceAttributesSecondary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendDeviceAttributesSecondary
-> SendDeviceAttributesSecondary -> Bool
$c/= :: SendDeviceAttributesSecondary
-> SendDeviceAttributesSecondary -> Bool
== :: SendDeviceAttributesSecondary
-> SendDeviceAttributesSecondary -> Bool
$c== :: SendDeviceAttributesSecondary
-> SendDeviceAttributesSecondary -> Bool
Eq, Int -> SendDeviceAttributesSecondary -> ShowS
[SendDeviceAttributesSecondary] -> ShowS
SendDeviceAttributesSecondary -> String
(Int -> SendDeviceAttributesSecondary -> ShowS)
-> (SendDeviceAttributesSecondary -> String)
-> ([SendDeviceAttributesSecondary] -> ShowS)
-> Show SendDeviceAttributesSecondary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendDeviceAttributesSecondary] -> ShowS
$cshowList :: [SendDeviceAttributesSecondary] -> ShowS
show :: SendDeviceAttributesSecondary -> String
$cshow :: SendDeviceAttributesSecondary -> String
showsPrec :: Int -> SendDeviceAttributesSecondary -> ShowS
$cshowsPrec :: Int -> SendDeviceAttributesSecondary -> ShowS
Show)
data OperatingSystemCommand
=
OSC_SetTitle
!Bool
!Bool
!Text
|
OSC_ChangeTextForegroundColor !Text
|
OSC_RequestTextForegroundColor
|
OSC_ChangeTextBackgroundColor !Text
|
OSC_RequestTextBackgroundColor
|
OSC_ResetTextCursorColor
deriving (OperatingSystemCommand -> OperatingSystemCommand -> Bool
(OperatingSystemCommand -> OperatingSystemCommand -> Bool)
-> (OperatingSystemCommand -> OperatingSystemCommand -> Bool)
-> Eq OperatingSystemCommand
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OperatingSystemCommand -> OperatingSystemCommand -> Bool
$c/= :: OperatingSystemCommand -> OperatingSystemCommand -> Bool
== :: OperatingSystemCommand -> OperatingSystemCommand -> Bool
$c== :: OperatingSystemCommand -> OperatingSystemCommand -> Bool
Eq, Int -> OperatingSystemCommand -> ShowS
[OperatingSystemCommand] -> ShowS
OperatingSystemCommand -> String
(Int -> OperatingSystemCommand -> ShowS)
-> (OperatingSystemCommand -> String)
-> ([OperatingSystemCommand] -> ShowS)
-> Show OperatingSystemCommand
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OperatingSystemCommand] -> ShowS
$cshowList :: [OperatingSystemCommand] -> ShowS
show :: OperatingSystemCommand -> String
$cshow :: OperatingSystemCommand -> String
showsPrec :: Int -> OperatingSystemCommand -> ShowS
$cshowsPrec :: Int -> OperatingSystemCommand -> ShowS
Show)
codeToSGR :: Int -> Maybe SGR.SGR
codeToSGR :: Int -> Maybe SGR
codeToSGR Int
0 = SGR -> Maybe SGR
forall a. a -> Maybe a
Just SGR
SGR.Reset
codeToSGR Int
1 = SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ ConsoleIntensity -> SGR
SGR.SetConsoleIntensity ConsoleIntensity
SGR.BoldIntensity
codeToSGR Int
2 = SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ ConsoleIntensity -> SGR
SGR.SetConsoleIntensity ConsoleIntensity
SGR.FaintIntensity
codeToSGR Int
4 = SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ Underlining -> SGR
SGR.SetUnderlining Underlining
SGR.SingleUnderline
codeToSGR Int
21 = SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ Underlining -> SGR
SGR.SetUnderlining Underlining
SGR.DoubleUnderline
codeToSGR Int
22 = SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ ConsoleIntensity -> SGR
SGR.SetConsoleIntensity ConsoleIntensity
SGR.NormalIntensity
codeToSGR Int
24 = SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ Underlining -> SGR
SGR.SetUnderlining Underlining
SGR.NoUnderline
codeToSGR Int
39 = SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ ConsoleLayer -> SGR
SGR.SetDefaultColor ConsoleLayer
SGR.Foreground
codeToSGR Int
49 = SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ ConsoleLayer -> SGR
SGR.SetDefaultColor ConsoleLayer
SGR.Background
codeToSGR Int
code
| Int
code Int -> (Int, Int) -> Bool
forall a. Ord a => a -> (a, a) -> Bool
`between` (Int
30, Int
37) = do
Color
color <- Int -> Maybe Color
codeToColor (Int
code Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
30)
SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ ConsoleLayer -> ColorIntensity -> Color -> SGR
SGR.SetColor ConsoleLayer
SGR.Foreground ColorIntensity
SGR.Dull Color
color
| Int
code Int -> (Int, Int) -> Bool
forall a. Ord a => a -> (a, a) -> Bool
`between` (Int
90, Int
97) = do
Color
color <- Int -> Maybe Color
codeToColor (Int
code Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
90)
SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ ConsoleLayer -> ColorIntensity -> Color -> SGR
SGR.SetColor ConsoleLayer
SGR.Foreground ColorIntensity
SGR.Vivid Color
color
| Int
code Int -> (Int, Int) -> Bool
forall a. Ord a => a -> (a, a) -> Bool
`between` (Int
40, Int
47) = do
Color
color <- Int -> Maybe Color
codeToColor (Int
code Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
40)
SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ ConsoleLayer -> ColorIntensity -> Color -> SGR
SGR.SetColor ConsoleLayer
SGR.Background ColorIntensity
SGR.Dull Color
color
| Int
code Int -> (Int, Int) -> Bool
forall a. Ord a => a -> (a, a) -> Bool
`between` (Int
100, Int
107) = do
Color
color <- Int -> Maybe Color
codeToColor (Int
code Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
100)
SGR -> Maybe SGR
forall a. a -> Maybe a
Just (SGR -> Maybe SGR) -> SGR -> Maybe SGR
forall a b. (a -> b) -> a -> b
$ ConsoleLayer -> ColorIntensity -> Color -> SGR
SGR.SetColor ConsoleLayer
SGR.Background ColorIntensity
SGR.Vivid Color
color
| Bool
otherwise = Maybe SGR
forall a. Maybe a
Nothing
codeToColor :: Int -> Maybe SGR.Color
codeToColor :: Int -> Maybe Color
codeToColor Int
0 = Color -> Maybe Color
forall a. a -> Maybe a
Just Color
SGR.Black
codeToColor Int
1 = Color -> Maybe Color
forall a. a -> Maybe a
Just Color
SGR.Red
codeToColor Int
2 = Color -> Maybe Color
forall a. a -> Maybe a
Just Color
SGR.Green
codeToColor Int
3 = Color -> Maybe Color
forall a. a -> Maybe a
Just Color
SGR.Yellow
codeToColor Int
4 = Color -> Maybe Color
forall a. a -> Maybe a
Just Color
SGR.Blue
codeToColor Int
5 = Color -> Maybe Color
forall a. a -> Maybe a
Just Color
SGR.Magenta
codeToColor Int
6 = Color -> Maybe Color
forall a. a -> Maybe a
Just Color
SGR.Cyan
codeToColor Int
7 = Color -> Maybe Color
forall a. a -> Maybe a
Just Color
SGR.White
codeToColor Int
_ = Maybe Color
forall a. Maybe a
Nothing
between :: Ord a => a -> (a, a) -> Bool
between :: a -> (a, a) -> Bool
between a
val (a
low, a
high) = a
val a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
low Bool -> Bool -> Bool
&& a
val a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
high