@@ -139,8 +139,8 @@ impl Parser {
139139 }
140140
141141 fn parse_attr ( & mut self , attr : & mut Attr , env : & Env ) -> Result < ( ) , ParserError > {
142- // [width, height, border_color, highlight]
143- self . consume ( TokenType :: LBracket ) ?; // [
142+ // [width, border_color, highlight]
143+ self . consume ( TokenType :: LBracket ) ?;
144144
145145 let mut pos = 0 ;
146146
@@ -163,22 +163,14 @@ impl Parser {
163163 }
164164 }
165165 1 => {
166- // height
167- if let Value :: Number ( h) = self . parse_value ( env) ? {
168- attr. height = h;
169- } else {
170- return Err ( ParserError :: Err ( "Height must be a number" . into ( ) ) ) ;
171- }
172- }
173- 2 => {
174166 // border_color
175167 if let Value :: RGB ( r, g, b) = self . parse_value ( env) ? {
176168 attr. border_color = Some ( Color :: Rgb ( r, g, b) ) ;
177169 } else {
178170 return Err ( ParserError :: Err ( "Border color must be RGB" . into ( ) ) ) ;
179171 }
180172 }
181- 3 => {
173+ 2 => {
182174 // highlight
183175 if let Value :: RGB ( r, g, b) = self . parse_value ( env) ? {
184176 attr. highlight = Some ( Color :: Rgb ( r, g, b) ) ;
@@ -204,7 +196,6 @@ impl Parser {
204196
205197fn get_rdev_key ( name : & str ) -> Option < Key > {
206198 match name. to_lowercase ( ) . as_str ( ) {
207- "esc" | "escape" => Some ( Key :: Escape ) ,
208199 "1" => Some ( Key :: Num1 ) ,
209200 "2" => Some ( Key :: Num2 ) ,
210201 "3" => Some ( Key :: Num3 ) ,
@@ -215,8 +206,7 @@ fn get_rdev_key(name: &str) -> Option<Key> {
215206 "8" => Some ( Key :: Num8 ) ,
216207 "9" => Some ( Key :: Num9 ) ,
217208 "0" => Some ( Key :: Num0 ) ,
218- "back" | "backspace" => Some ( Key :: Backspace ) ,
219- "tab" => Some ( Key :: Tab ) ,
209+
220210 "q" => Some ( Key :: KeyQ ) ,
221211 "w" => Some ( Key :: KeyW ) ,
222212 "e" => Some ( Key :: KeyE ) ,
@@ -227,8 +217,6 @@ fn get_rdev_key(name: &str) -> Option<Key> {
227217 "i" => Some ( Key :: KeyI ) ,
228218 "o" => Some ( Key :: KeyO ) ,
229219 "p" => Some ( Key :: KeyP ) ,
230- "enter" | "return" => Some ( Key :: Return ) ,
231- "caps" | "capslock" => Some ( Key :: CapsLock ) ,
232220 "a" => Some ( Key :: KeyA ) ,
233221 "s" => Some ( Key :: KeyS ) ,
234222 "d" => Some ( Key :: KeyD ) ,
@@ -238,20 +226,65 @@ fn get_rdev_key(name: &str) -> Option<Key> {
238226 "j" => Some ( Key :: KeyJ ) ,
239227 "k" => Some ( Key :: KeyK ) ,
240228 "l" => Some ( Key :: KeyL ) ,
241- "lshift" | "shift" => Some ( Key :: ShiftLeft ) ,
242- "rshift" => Some ( Key :: ShiftRight ) ,
243229 "z" => Some ( Key :: KeyZ ) ,
244230 "x" => Some ( Key :: KeyX ) ,
245231 "c" => Some ( Key :: KeyC ) ,
246232 "v" => Some ( Key :: KeyV ) ,
247233 "b" => Some ( Key :: KeyB ) ,
248234 "n" => Some ( Key :: KeyN ) ,
249235 "m" => Some ( Key :: KeyM ) ,
236+
237+ "lshift" | "shift" => Some ( Key :: ShiftLeft ) ,
238+ "rshift" => Some ( Key :: ShiftRight ) ,
239+ "esc" | "escape" => Some ( Key :: Escape ) ,
250240 "ctrl" | "lctrl" => Some ( Key :: ControlLeft ) ,
251241 "rctrl" => Some ( Key :: ControlRight ) ,
252242 "alt" | "lalt" => Some ( Key :: Alt ) ,
253243 "ralt" | "altgr" => Some ( Key :: AltGr ) ,
254244 "space" => Some ( Key :: Space ) ,
245+ "enter" | "return" => Some ( Key :: Return ) ,
246+ "caps" | "capslock" => Some ( Key :: CapsLock ) ,
247+ "back" | "backspace" => Some ( Key :: Backspace ) ,
248+ "tab" => Some ( Key :: Tab ) ,
249+
250+ "up" => Some ( Key :: UpArrow ) ,
251+ "down" => Some ( Key :: DownArrow ) ,
252+ "left" => Some ( Key :: LeftArrow ) ,
253+ "right" => Some ( Key :: RightArrow ) ,
254+
255+ "ins" | "insert" => Some ( Key :: Insert ) ,
256+ "del" | "delete" => Some ( Key :: Delete ) ,
257+ "home" => Some ( Key :: Home ) ,
258+ "end" => Some ( Key :: End ) ,
259+ "pgup" | "pageup" => Some ( Key :: PageUp ) ,
260+ "pgdn" | "pagedown" => Some ( Key :: PageDown ) ,
261+
262+ "`" | "backquote" => Some ( Key :: BackQuote ) ,
263+ "-" | "minus" => Some ( Key :: Minus ) ,
264+ "=" | "equal" => Some ( Key :: Equal ) ,
265+ "[" | "leftbracket" => Some ( Key :: LeftBracket ) ,
266+ "]" | "rightbracket" => Some ( Key :: RightBracket ) ,
267+ ";" | "semicolon" => Some ( Key :: SemiColon ) ,
268+ "'" | "quote" => Some ( Key :: Quote ) ,
269+ "\\ " | "backslash" => Some ( Key :: BackSlash ) ,
270+ "," | "comma" => Some ( Key :: Comma ) ,
271+ "." | "dot" => Some ( Key :: Dot ) ,
272+ "/" | "slash" => Some ( Key :: Slash ) ,
273+
274+ "f1" => Some ( Key :: F1 ) ,
275+ "f2" => Some ( Key :: F2 ) ,
276+ "f3" => Some ( Key :: F3 ) ,
277+ "f4" => Some ( Key :: F4 ) ,
278+ "f5" => Some ( Key :: F5 ) ,
279+ "f6" => Some ( Key :: F6 ) ,
280+ "f7" => Some ( Key :: F7 ) ,
281+ "f8" => Some ( Key :: F8 ) ,
282+ "f9" => Some ( Key :: F9 ) ,
283+ "f10" => Some ( Key :: F10 ) ,
284+ "f11" => Some ( Key :: F11 ) ,
285+ "f12" => Some ( Key :: F12 ) ,
286+
287+ "win" | "meta" | "command" => Some ( Key :: MetaLeft ) ,
255288 _ => None ,
256289 }
257290}
@@ -470,7 +503,7 @@ mod tests {
470503 assert_eq ! ( result. layer[ 0 ] [ 0 ] . binds[ 0 ] . 0 . as_ref( ) , "Tab" ) ;
471504 assert_eq ! ( result. layer[ 0 ] [ 0 ] . binds[ 0 ] . 1 , Some ( Key :: Tab ) ) ;
472505 assert_eq ! ( result. layer[ 0 ] [ 0 ] . attr. width, 10 ) ;
473- assert_eq ! ( result. layer[ 0 ] [ 0 ] . attr. border_color , Some ( Color :: Rgb ( 1 , 1 , 1 ) ) ) ;
506+ assert_eq ! ( result. layer[ 0 ] [ 0 ] . attr. highlight , Some ( Color :: Rgb ( 1 , 1 , 1 ) ) ) ;
474507 }
475508
476509 #[ test]
0 commit comments