@@ -24,6 +24,9 @@ data Event = EvKey Key [Modifier] | EvMouse Int Int Button [Modifier]
24 | EvResize Int Int
24 | EvResize Int Int
25 deriving (Eq,Show,Ord)
25 deriving (Eq,Show,Ord)
27+-- | representation of mapping from input bytes to output event
27type ClassifyTable = [(String, (Key, [Modifier]))]
30type ClassifyTable = [(String, (Key, [Modifier]))]
29map_to_legacy_table :: [(String, Event)] -> ClassifyTable
32map_to_legacy_table :: [(String, Event)] -> ClassifyTable
@@ -45,9 +48,13 @@ keys_from_caps_table =
45 , ("kRIT", EvKey KRight [MShift])
48 , ("kRIT", EvKey KRight [MShift])
46 ] ++ function_key_caps_table
49 ] ++ function_key_caps_table
51+-- | cap names for function keys
48function_key_caps_table :: [(String, Event)]
52function_key_caps_table :: [(String, Event)]
49function_key_caps_table = flip map [0..63] $ \n -> ("kf" ++ show n, EvKey (KFun n) [])
53function_key_caps_table = flip map [0..63] $ \n -> ("kf" ++ show n, EvKey (KFun n) [])
55+-- VT 100 encoding for navigation keys.
57+-- TODO: remove those that duplicate entries in caps table.
51nav_keys_0 :: ClassifyTable
58nav_keys_0 :: ClassifyTable
52nav_keys_0 =
59nav_keys_0 =
53 [ k "G" KNP5
60 [ k "G" KNP5
@@ -62,7 +69,7 @@ nav_keys_0 =
63 where k c s = ("\ESC["++c,(s,[]))
70 where k c s = ("\ESC["++c,(s,[]))
65−-- Support for arrows and KHome/KEnd
72+-- | VT 100 (?) encoding for arrows and KHome/KEnd
66nav_keys_1 :: ClassifyTable
73nav_keys_1 :: ClassifyTable
67nav_keys_1 =
74nav_keys_1 =
68 [("\ESC[" ++ charCnt ++ show mc++c,(s,m))
75 [("\ESC[" ++ charCnt ++ show mc++c,(s,m))
@@ -72,19 +79,22 @@ nav_keys_1 =
72 (c,s) <- [("A", KUp), ("B", KDown), ("C", KRight), ("D", KLeft), ("H", KHome), ("F", KEnd)] -- directions and their codes
79 (c,s) <- [("A", KUp), ("B", KDown), ("C", KRight), ("D", KLeft), ("H", KHome), ("F", KEnd)] -- directions and their codes
82+-- | VT 100 (?) encoding for ins, del, pageup, pagedown, home, end
75nav_keys_2 :: ClassifyTable
83nav_keys_2 :: ClassifyTable
76nav_keys_2 =
84nav_keys_2 =
77 let k n s = ("\ESC["++show n++"~",(s,[]))
85 let k n s = ("\ESC["++show n++"~",(s,[]))
78 in zipWith k [2::Int,3,5,6,1,4]
86 in zipWith k [2::Int,3,5,6,1,4]
79 [KIns,KDel,KPageUp,KPageDown,KHome,KEnd]
87 [KIns,KDel,KPageUp,KPageDown,KHome,KEnd]
89+-- | VT 100 (?) encoding for ctrl + ins, del, pageup, pagedown, home, end
81nav_keys_3 :: ClassifyTable
90nav_keys_3 :: ClassifyTable
82nav_keys_3 =
91nav_keys_3 =
83 let k n s = ("\ESC["++show n++";5~",(s,[MCtrl]))
92 let k n s = ("\ESC["++show n++";5~",(s,[MCtrl]))
84 in zipWith k [2::Int,3,5,6,1,4]
93 in zipWith k [2::Int,3,5,6,1,4]
85 [KIns,KDel,KPageUp,KPageDown,KHome,KEnd]
94 [KIns,KDel,KPageUp,KPageDown,KHome,KEnd]
87−-- Support for simple characters.
96+-- | Support for simple characters.
88-- we limit to < 0xC1. The UTF8 sequence detector will catch all values 0xC2 and above before this
98-- we limit to < 0xC1. The UTF8 sequence detector will catch all values 0xC2 and above before this
89-- classify table is reached.
99-- classify table is reached.
@@ -93,25 +103,25 @@ nav_keys_3 =
93simple_chars :: ClassifyTable
103simple_chars :: ClassifyTable
94simple_chars = [(x:[],(KASCII x,[])) | x <- [' ' .. toEnum 0xC1]]
104simple_chars = [(x:[],(KASCII x,[])) | x <- [' ' .. toEnum 0xC1]]
96−-- TODO: Support for function keys (should use terminfo)
106+-- | VT 100 (?) encoding for shift plus function keys
98-- (corey): yes. This definitely should. On my terminal these keys do not operate as expected.
108-- (corey): yes. This definitely should. On my terminal these keys do not operate as expected.
99-- function_keys_0 :: ClassifyTable
109-- function_keys_0 :: ClassifyTable
100-- function_keys_0 = [ ("\ESC[["++[toEnum(64+i)],(KFun i,[])) | i <- [1..5] ]
110-- function_keys_0 = [ ("\ESC[["++[toEnum(64+i)],(KFun i,[])) | i <- [1..5] ]
102-- TODO: I suspect this should be generated by interpretting the terminals use of meta mode:
111-- TODO: I suspect this should be generated by interpretting the terminals use of meta mode:
103-- "If the terminal has a ``meta key'' which acts as a shift key, setting the 8th bit of any
112-- "If the terminal has a ``meta key'' which acts as a shift key, setting the 8th bit of any
104-- character transmitted, this fact can be indicated with km. Other- wise, software will
113-- character transmitted, this fact can be indicated with km. Other- wise, software will
105-- assume that the 8th bit is parity and it will usually be cleared. If strings exist to turn this
114-- assume that the 8th bit is parity and it will usually be cleared. If strings exist to turn this
106-- ``meta mode'' on and off, they can be given as smm and rmm."
115-- ``meta mode'' on and off, they can be given as smm and rmm."
108−-- That is more complex that below. I cannot fault the original author for just hard coding a table
117+-- That is more complex than below. I cannot fault the original author for just hard coding a table.
110function_keys_1 :: ClassifyTable
118function_keys_1 :: ClassifyTable
111function_keys_1 =
119function_keys_1 =
112 let f ff nrs m = [ ("\ESC["++show n++"~",(KFun (n-(nrs!!0)+ff), m)) | n <- nrs ] in
120 let f ff nrs m = [ ("\ESC["++show n++"~",(KFun (n-(nrs!!0)+ff), m)) | n <- nrs ] in
113 concat [f 1 [25,26] [MShift], f 3 [28,29] [MShift], f 5 [31..34] [MShift] ]
121 concat [f 1 [25,26] [MShift], f 3 [28,29] [MShift], f 5 [31..34] [MShift] ]
123+-- | VT 100 (?) encoding for meta plus char
115-- TODO: resolve -
125-- TODO: resolve -
117-- 1. removed 'ESC' from second list due to duplication with "special_support_keys".
127-- 1. removed 'ESC' from second list due to duplication with "special_support_keys".
@@ -123,7 +133,7 @@ function_keys_2 :: ClassifyTable
123function_keys_2 = [ ('\ESC':[x],(KASCII x,[MMeta])) | x <- '\t':[' ' .. '~'],
133function_keys_2 = [ ('\ESC':[x],(KASCII x,[MMeta])) | x <- '\t':[' ' .. '~'],
124 x /= '[']
134 x /= '[']
126−-- Ctrl+Char
136+-- | Ctrl+Char
127ctrl_char_keys :: ClassifyTable
137ctrl_char_keys :: ClassifyTable
128ctrl_char_keys =
138ctrl_char_keys =
129 [ ([toEnum x],(KASCII y,[MCtrl]))
139 [ ([toEnum x],(KASCII y,[MCtrl]))
@@ -131,7 +141,7 @@ ctrl_char_keys =
131 y /= 'i' -- Resolve issue #3 where CTRL-i hides TAB.
141 y /= 'i' -- Resolve issue #3 where CTRL-i hides TAB.
134−-- Ctrl+Meta+Char
144+-- | Ctrl+Meta+Char
136-- TODO: CTRL-i is the same as tab thing
146-- TODO: CTRL-i is the same as tab thing
137ctrl_meta_keys :: ClassifyTable
147ctrl_meta_keys :: ClassifyTable
@@ -140,7 +150,7 @@ ctrl_meta_keys =
143−-- Special support
153+-- | Special support
144special_support_keys :: ClassifyTable
154special_support_keys :: ClassifyTable
145special_support_keys =
155special_support_keys =
146 [ -- special support for ESC
156 [ -- special support for ESC