module Graphics.Vty.Input.Terminfo.ANSIVT
( classifyTable
)
where
import Graphics.Vty.Input.Events
navKeys0 :: ClassifyMap
navKeys0 :: ClassifyMap
navKeys0 =
[ [Char] -> Key -> ([Char], Event)
k [Char]
"G" Key
KCenter
, [Char] -> Key -> ([Char], Event)
k [Char]
"P" Key
KPause
, [Char] -> Key -> ([Char], Event)
k [Char]
"A" Key
KUp
, [Char] -> Key -> ([Char], Event)
k [Char]
"B" Key
KDown
, [Char] -> Key -> ([Char], Event)
k [Char]
"C" Key
KRight
, [Char] -> Key -> ([Char], Event)
k [Char]
"D" Key
KLeft
, [Char] -> Key -> ([Char], Event)
k [Char]
"H" Key
KHome
, [Char] -> Key -> ([Char], Event)
k [Char]
"F" Key
KEnd
, [Char] -> Key -> ([Char], Event)
k [Char]
"E" Key
KBegin
]
where k :: [Char] -> Key -> ([Char], Event)
k [Char]
c Key
s = ([Char]
"\ESC["forall a. [a] -> [a] -> [a]
++[Char]
c,Key -> [Modifier] -> Event
EvKey Key
s [])
navKeys1 :: ClassifyMap
navKeys1 :: ClassifyMap
navKeys1 =
[([Char]
"\ESC[" forall a. [a] -> [a] -> [a]
++ [Char]
charCnt forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show Int
mcforall a. [a] -> [a] -> [a]
++[Char]
c,Key -> [Modifier] -> Event
EvKey Key
s [Modifier]
m)
| [Char]
charCnt <- [[Char]
"1;", [Char]
""],
([Modifier]
m,Int
mc) <- [([Modifier
MShift],Int
2::Int), ([Modifier
MCtrl],Int
5), ([Modifier
MMeta],Int
3),
([Modifier
MShift, Modifier
MCtrl],Int
6), ([Modifier
MShift, Modifier
MMeta],Int
4)],
([Char]
c,Key
s) <- [([Char]
"A", Key
KUp), ([Char]
"B", Key
KDown), ([Char]
"C", Key
KRight), ([Char]
"D", Key
KLeft), ([Char]
"H", Key
KHome), ([Char]
"F", Key
KEnd)]
]
navKeys2 :: ClassifyMap
navKeys2 :: ClassifyMap
navKeys2 =
let k :: a -> Key -> ([Char], Event)
k a
n Key
s = ([Char]
"\ESC["forall a. [a] -> [a] -> [a]
++forall a. Show a => a -> [Char]
show a
nforall a. [a] -> [a] -> [a]
++[Char]
"~",Key -> [Modifier] -> Event
EvKey Key
s [])
in forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall {a}. Show a => a -> Key -> ([Char], Event)
k [Int
2::Int,Int
3,Int
5,Int
6,Int
1,Int
4]
[Key
KIns,Key
KDel,Key
KPageUp,Key
KPageDown,Key
KHome,Key
KEnd]
navKeys3 :: ClassifyMap
navKeys3 :: ClassifyMap
navKeys3 =
let k :: a -> Key -> ([Char], Event)
k a
n Key
s = ([Char]
"\ESC["forall a. [a] -> [a] -> [a]
++forall a. Show a => a -> [Char]
show a
nforall a. [a] -> [a] -> [a]
++[Char]
";5~",Key -> [Modifier] -> Event
EvKey Key
s [Modifier
MCtrl])
in forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall {a}. Show a => a -> Key -> ([Char], Event)
k [Int
2::Int,Int
3,Int
5,Int
6,Int
1,Int
4]
[Key
KIns,Key
KDel,Key
KPageUp,Key
KPageDown,Key
KHome,Key
KEnd]
functionKeys1 :: ClassifyMap
functionKeys1 :: ClassifyMap
functionKeys1 =
let f :: Int -> [Int] -> [Modifier] -> ClassifyMap
f Int
ff [Int]
nrs [Modifier]
m = [ ([Char]
"\ESC["forall a. [a] -> [a] -> [a]
++forall a. Show a => a -> [Char]
show Int
nforall a. [a] -> [a] -> [a]
++[Char]
"~",Key -> [Modifier] -> Event
EvKey (Int -> Key
KFun forall a b. (a -> b) -> a -> b
$ Int
nforall a. Num a => a -> a -> a
-forall a. [a] -> a
head [Int]
nrsforall a. Num a => a -> a -> a
+Int
ff) [Modifier]
m) | Int
n <- [Int]
nrs ] in
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [Int -> [Int] -> [Modifier] -> ClassifyMap
f Int
1 [Int
25,Int
26] [Modifier
MShift], Int -> [Int] -> [Modifier] -> ClassifyMap
f Int
3 [Int
28,Int
29] [Modifier
MShift], Int -> [Int] -> [Modifier] -> ClassifyMap
f Int
5 [Int
31..Int
34] [Modifier
MShift] ]
functionKeys2 :: ClassifyMap
functionKeys2 :: ClassifyMap
functionKeys2 = [ (Char
'\ESC'forall a. a -> [a] -> [a]
:[Char
x],Key -> [Modifier] -> Event
EvKey (Char -> Key
KChar Char
x) [Modifier
MMeta])
| Char
x <- Char
'\t'forall a. a -> [a] -> [a]
:[Char
' ' .. Char
'~']
, Char
x forall a. Eq a => a -> a -> Bool
/= Char
'['
]
classifyTable :: [ClassifyMap]
classifyTable :: [ClassifyMap]
classifyTable =
[ ClassifyMap
navKeys0
, ClassifyMap
navKeys1
, ClassifyMap
navKeys2
, ClassifyMap
navKeys3
, ClassifyMap
functionKeys1
, ClassifyMap
functionKeys2
]