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