@@ -1,14 +1,14 @@
1−module Graphics.Vty.Input.Terminfo.XTerm7Bit where
1+-- | Input mappings for ANSI/VT100/VT50 terminals that is missing from terminfo.
2+--
3+-- Or that are sent regardless of terminfo by terminal emulators. EG: Terminal emulators will often
4+-- use VT50 input bytes regardless of declared terminal type. This provides compatibility with
5+-- programs that don't follow terminfo.
6+module Graphics.Vty.Input.Terminfo.ANSIVT where
27
38import Graphics.Vty.Input.Events
49
510import Data.List (isInfixOf, isPrefixOf)
611
7−-- | The built in input augmentation for XTerm supports any TERM starting with xterm except those
8−-- containing 8bit.
9−supports :: String -> Bool
10−supports termName = "xterm" `isPrefixOf` termName && not ("8bit" `isInfixOf` termName)
11−
1212-- | Encoding for navigation keys.
1313--
1414-- TODO: This is not the same as the input bytes pulled from teh caps table.
@@ -26,7 +26,7 @@ navKeys0 =
2626 ]
2727 where k c s = ("\ESC["++c,EvKey s [])
2828
29−-- | VT 100 (?) encoding for shift, meta and ctrl plus arrows/home/end
29+-- | encoding for shift, meta and ctrl plus arrows/home/end
3030navKeys1 :: ClassifyTable
3131navKeys1 =
3232 [("\ESC[" ++ charCnt ++ show mc++c,EvKey s m)
@@ -36,21 +36,21 @@ navKeys1 =
3636 (c,s) <- [("A", KUp), ("B", KDown), ("C", KRight), ("D", KLeft), ("H", KHome), ("F", KEnd)] -- directions and their codes
3737 ]
3838
39−-- | VT 100 (?) encoding for ins, del, pageup, pagedown, home, end
39+-- | encoding for ins, del, pageup, pagedown, home, end
4040navKeys2 :: ClassifyTable
4141navKeys2 =
4242 let k n s = ("\ESC["++show n++"~",EvKey s [])
4343 in zipWith k [2::Int,3,5,6,1,4]
4444 [KIns,KDel,KPageUp,KPageDown,KHome,KEnd]
4545
46−-- | VT 100 (?) encoding for ctrl + ins, del, pageup, pagedown, home, end
46+-- | encoding for ctrl + ins, del, pageup, pagedown, home, end
4747navKeys3 :: ClassifyTable
4848navKeys3 =
4949 let k n s = ("\ESC["++show n++";5~",EvKey s [MCtrl])
5050 in zipWith k [2::Int,3,5,6,1,4]
5151 [KIns,KDel,KPageUp,KPageDown,KHome,KEnd]
5252
53−-- | VT 100 (?) encoding for shift plus function keys
53+-- | encoding for shift plus function keys
5454--
5555-- TODO: I suspect this should be generated by interpretting the terminals use of meta mode:
5656-- "If the terminal has a ``meta key'' which acts as a shift key, setting the 8th bit of any
@@ -64,7 +64,7 @@ functionKeys1 =
6464 let f ff nrs m = [ ("\ESC["++show n++"~",EvKey (KFun $ n-(nrs!!0)+ff) m) | n <- nrs ] in
6565 concat [f 1 [25,26] [MShift], f 3 [28,29] [MShift], f 5 [31..34] [MShift] ]
6666
67−-- | VT 100 (?) encoding for meta plus char
67+-- | encoding for meta plus char
6868--
6969-- TODO: resolve -
7070--
@@ -79,9 +79,8 @@ functionKeys2 = [ ('\ESC':[x],EvKey (KChar x) [MMeta])
7979 , x /= '['
8080 ]
8181
82−-- | classify table for ANSI terminals
83−tables :: [ClassifyTable]
84−tables =
82+classifyTable :: [ClassifyTable]
83+classifyTable =
8584 [ navKeys0
8685 , navKeys1
8786 , navKeys2