Skip to content

Commit

Permalink
Add parsing support for M- for lmeta
Browse files Browse the repository at this point in the history
  • Loading branch information
jtroo committed Jul 12, 2022
1 parent 2ccc6be commit bcf48f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 3 additions & 1 deletion cfg_samples/jtroo.kbd
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@
_ _ _ _ _ _ _
)

(defalias win M-tab)

(deflayer numbers
_ _ _ _ _ _ nlk kp7 kp8 kp9 _ _ _ _
_ _ _ _ _ XX _ kp4 kp5 kp6 - _ _ _
_ _ C-z _ _ XX _ kp1 kp2 kp3 + _ _
_ _ C-z C-y @win XX _ kp1 kp2 kp3 + _ _
_ C-z C-x C-c C-v XX _ kp0 kp0 . / _
_ _ _ _ _ _ _
)
Expand Down
17 changes: 11 additions & 6 deletions cfg_samples/kanata.kbd
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@

;; tap for capslk, hold for lctl
cap (tap-hold 200 200 caps lctl)

;; Chords. These ones are used for copying/pasting from some Linux terminals.
csv C-S-v
csc C-S-c
)

(defalias
Expand All @@ -131,12 +127,21 @@
;; for modifiers like shift. You probably want to use macro instead.
;;
;; Chording can be more succinctly described by the modifier prefixes
;; `C-`, `A-`, and `S-` for lctrl, lalt, lshift, but are possible by using
;; multi as well.
;; `C-`, `A-`, `S-`, and `M-` for lctrl, lalt, lshift, lmeta, but are possible
;; by using the `multi` as well. The lmeta key is also known by some other
;; names: "Windows", "GUI", "Command", "Super".
;;
;; One use case for multi could be typing an all-caps string.
alp (multi lsft a b c d e f g h i j k l m n o p q r s t u v w x y z)

;; Chords using the shortuct. These ones are used for copying/pasting
;; from some Linux terminals.
csv C-S-v
csc C-S-c

;; Windows shortcut for displaying all windows
win M-tab

;; macro accepts keys, chords, and numbers (a delay in ms). Note that numbers
;; will be parsed as delays, so they will need to be aliased to be used.
lch (macro h t t p @: / / 100 l o c a l h o s t @: @8 @0 @8 @0)
Expand Down
6 changes: 6 additions & 0 deletions src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,12 @@ fn parse_action_atom(ac: &str, aliases: &Aliases) -> Result<&'static KanataActio
}
key_stack.push(KeyCode::LAlt);
rem = rest;
} else if let Some(rest) = rem.strip_prefix("M-") {
if key_stack.contains(&KeyCode::LGui) {
bail!("Redundant \"M-\" in {}", ac)
}
key_stack.push(KeyCode::LGui);
rem = rest;
} else if let Some(oscode) = str_to_oscode(rem) {
key_stack.push(oscode.into());
return Ok(sref(Action::MultipleKeyCodes(sref(key_stack).as_ref())));
Expand Down

0 comments on commit bcf48f3

Please sign in to comment.