@@ -24,6 +24,9 @@ data Event = EvKey Key [Modifier] | EvMouse Int Int Button [Modifier]
2424 | EvResize Int Int
2525 deriving (Eq,Show,Ord)
2626
27+-- | representation of mapping from input bytes to output event
28+--
29+-- deprecated
2730type ClassifyTable = [(String, (Key, [Modifier]))]
2831
2932map_to_legacy_table :: [(String, Event)] -> ClassifyTable
@@ -45,9 +48,13 @@ keys_from_caps_table =
4548 , ("kRIT", EvKey KRight [MShift])
4649 ] ++ function_key_caps_table
4750
51+-- | cap names for function keys
4852function_key_caps_table :: [(String, Event)]
4953function_key_caps_table = flip map [0..63] $ \n -> ("kf" ++ show n, EvKey (KFun n) [])
5054
55+-- VT 100 encoding for navigation keys.
56+--
57+-- TODO: remove those that duplicate entries in caps table.
5158nav_keys_0 :: ClassifyTable
5259nav_keys_0 =
5360 [ k "G" KNP5
@@ -62,7 +69,7 @@ nav_keys_0 =
6269 ]
6370 where k c s = ("\ESC["++c,(s,[]))
6471
65−-- Support for arrows and KHome/KEnd
72+-- | VT 100 (?) encoding for arrows and KHome/KEnd
6673nav_keys_1 :: ClassifyTable
6774nav_keys_1 =
6875 [("\ESC[" ++ charCnt ++ show mc++c,(s,m))
@@ -72,19 +79,22 @@ nav_keys_1 =
7279 (c,s) <- [("A", KUp), ("B", KDown), ("C", KRight), ("D", KLeft), ("H", KHome), ("F", KEnd)] -- directions and their codes
7380 ]
7481
82+-- | VT 100 (?) encoding for ins, del, pageup, pagedown, home, end
7583nav_keys_2 :: ClassifyTable
7684nav_keys_2 =
7785 let k n s = ("\ESC["++show n++"~",(s,[]))
7886 in zipWith k [2::Int,3,5,6,1,4]
7987 [KIns,KDel,KPageUp,KPageDown,KHome,KEnd]
8088
89+-- | VT 100 (?) encoding for ctrl + ins, del, pageup, pagedown, home, end
8190nav_keys_3 :: ClassifyTable
8291nav_keys_3 =
8392 let k n s = ("\ESC["++show n++";5~",(s,[MCtrl]))
8493 in zipWith k [2::Int,3,5,6,1,4]
8594 [KIns,KDel,KPageUp,KPageDown,KHome,KEnd]
8695
87−-- Support for simple characters.
96+-- | Support for simple characters.
97+--
8898-- we limit to < 0xC1. The UTF8 sequence detector will catch all values 0xC2 and above before this
8999-- classify table is reached.
90100--
@@ -93,25 +103,25 @@ nav_keys_3 =
93103simple_chars :: ClassifyTable
94104simple_chars = [(x:[],(KASCII x,[])) | x <- [' ' .. toEnum 0xC1]]
95105
96−-- TODO: Support for function keys (should use terminfo)
106+-- | VT 100 (?) encoding for shift plus function keys
97107--
98108-- (corey): yes. This definitely should. On my terminal these keys do not operate as expected.
99109-- function_keys_0 :: ClassifyTable
100110-- function_keys_0 = [ ("\ESC[["++[toEnum(64+i)],(KFun i,[])) | i <- [1..5] ]
101−
102111-- TODO: I suspect this should be generated by interpretting the terminals use of meta mode:
103112-- "If the terminal has a ``meta key'' which acts as a shift key, setting the 8th bit of any
104113-- character transmitted, this fact can be indicated with km. Other- wise, software will
105114-- assume that the 8th bit is parity and it will usually be cleared. If strings exist to turn this
106115-- ``meta mode'' on and off, they can be given as smm and rmm."
107116--
108−-- That is more complex that below. I cannot fault the original author for just hard coding a table
109−-- ;-)
117+-- That is more complex than below. I cannot fault the original author for just hard coding a table.
110118function_keys_1 :: ClassifyTable
111119function_keys_1 =
112120 let f ff nrs m = [ ("\ESC["++show n++"~",(KFun (n-(nrs!!0)+ff), m)) | n <- nrs ] in
113121 concat [f 1 [25,26] [MShift], f 3 [28,29] [MShift], f 5 [31..34] [MShift] ]
114122
123+-- | VT 100 (?) encoding for meta plus char
124+--
115125-- TODO: resolve -
116126--
117127-- 1. removed 'ESC' from second list due to duplication with "special_support_keys".
@@ -123,7 +133,7 @@ function_keys_2 :: ClassifyTable
123133function_keys_2 = [ ('\ESC':[x],(KASCII x,[MMeta])) | x <- '\t':[' ' .. '~'],
124134 x /= '[']
125135
126−-- Ctrl+Char
136+-- | Ctrl+Char
127137ctrl_char_keys :: ClassifyTable
128138ctrl_char_keys =
129139 [ ([toEnum x],(KASCII y,[MCtrl]))
@@ -131,7 +141,7 @@ ctrl_char_keys =
131141 y /= 'i' -- Resolve issue #3 where CTRL-i hides TAB.
132142 ]
133143
134−-- Ctrl+Meta+Char
144+-- | Ctrl+Meta+Char
135145--
136146-- TODO: CTRL-i is the same as tab thing
137147ctrl_meta_keys :: ClassifyTable
@@ -140,7 +150,7 @@ ctrl_meta_keys =
140150 y /= 'i'
141151 ]
142152
143−-- Special support
153+-- | Special support
144154special_support_keys :: ClassifyTable
145155special_support_keys =
146156 [ -- special support for ESC