|
| 1 | +/* Original code copied from Sunaku's Keymap modified to use zmk-helpers - https://github.com/sunaku/glove80-keymaps */ |
| 2 | + |
| 3 | +////////////////////////////////////////////////////////////////////////// |
| 4 | +// |
| 5 | +// Approximation of Pascal Getreuer's Select Word macro from QMK |
| 6 | +// - https://getreuer.info/posts/keyboards/select-word/index.html |
| 7 | +// |
| 8 | +////////////////////////////////////////////////////////////////////////// |
| 9 | + |
| 10 | +// |
| 11 | +// SELECT_WORD_DELAY defines how long the macro waits (milliseconds) |
| 12 | +// after moving the cursor before it selects a word. A larger delay |
| 13 | +// may allow the macro to move to the next word upon each invocation. |
| 14 | +// |
| 15 | +#ifndef SELECT_WORD_DELAY |
| 16 | +#define SELECT_WORD_DELAY 1 |
| 17 | +#endif |
| 18 | + |
| 19 | +////////////////////////////////////////////////////////////////////////// |
| 20 | +// |
| 21 | +// Approximation of Pascal Getreuer's Select Word macro from QMK |
| 22 | +// - https://getreuer.info/posts/keyboards/select-word/index.html |
| 23 | +// |
| 24 | +////////////////////////////////////////////////////////////////////////// |
| 25 | + |
| 26 | +// |
| 27 | +// SELECT_WORD_DELAY defines how long the macro waits (milliseconds) |
| 28 | +// after moving the cursor before it selects a word. A larger delay |
| 29 | +// may allow the macro to move to the next word upon each invocation. |
| 30 | +// |
| 31 | +#ifndef SELECT_WORD_DELAY |
| 32 | +#define SELECT_WORD_DELAY 1 |
| 33 | +#endif |
| 34 | + |
| 35 | +// select all alias for shortcut |
| 36 | +#define select_all kp _C(A) |
| 37 | + |
| 38 | +ZMK_MACRO(select_none, |
| 39 | + wait-ms = <SELECT_WORD_DELAY>; |
| 40 | + tap-ms = <SELECT_WORD_DELAY>; |
| 41 | + bindings = <&kp DOWN &kp UP &kp RIGHT &kp LEFT>; |
| 42 | +) |
| 43 | + |
| 44 | +// |
| 45 | +// select a word (jumps to next word upon each successive invocation) |
| 46 | +// |
| 47 | +ZMK_MOD_MORPH(select_word, |
| 48 | + bindings = <&select_word_right>, <&select_word_left>; |
| 49 | + mods = <(MOD_LSFT|MOD_RSFT)>; |
| 50 | +) |
| 51 | +ZMK_MACRO(select_word_right, |
| 52 | + wait-ms = <SELECT_WORD_DELAY>; |
| 53 | + tap-ms = <SELECT_WORD_DELAY>; |
| 54 | + bindings = <&kp _W(RIGHT) &kp _W(LEFT) &kp _W(LS(RIGHT))>; |
| 55 | +) |
| 56 | +ZMK_MACRO(select_word_left, |
| 57 | + wait-ms = <SELECT_WORD_DELAY>; |
| 58 | + tap-ms = <SELECT_WORD_DELAY>; |
| 59 | + bindings = <&kp _W(LEFT) &kp _W(RIGHT) &kp _W(LS(LEFT))>; |
| 60 | +) |
| 61 | +// |
| 62 | +// extend current selection by one word |
| 63 | +// |
| 64 | +ZMK_MOD_MORPH(extend_word, |
| 65 | + bindings = <&extend_word_right>, <&extend_word_left>; |
| 66 | + mods = <(MOD_LSFT|MOD_RSFT)>; |
| 67 | +) |
| 68 | +ZMK_MACRO(extend_word_right, |
| 69 | + wait-ms = <SELECT_WORD_DELAY>; |
| 70 | + tap-ms = <SELECT_WORD_DELAY>; |
| 71 | + bindings = <&kp _W(LS(RIGHT))>; |
| 72 | +) |
| 73 | +ZMK_MACRO(extend_word_left, |
| 74 | + wait-ms = <SELECT_WORD_DELAY>; |
| 75 | + tap-ms = <SELECT_WORD_DELAY>; |
| 76 | + bindings = <&kp _W(LS(LEFT))>; |
| 77 | +) |
| 78 | + |
| 79 | +// |
| 80 | +// select current line |
| 81 | +// |
| 82 | +ZMK_MOD_MORPH(select_line, |
| 83 | + bindings = <&select_line_right>, <&select_line_left>; |
| 84 | + mods = <(MOD_LSFT|MOD_RSFT)>; |
| 85 | +) |
| 86 | +ZMK_MACRO(select_line_right, |
| 87 | + wait-ms = <SELECT_WORD_DELAY>; |
| 88 | + tap-ms = <SELECT_WORD_DELAY>; |
| 89 | + bindings = <&kp _HOME &kp LS(_END)>; |
| 90 | +) |
| 91 | +ZMK_MACRO(select_line_left, |
| 92 | + wait-ms = <SELECT_WORD_DELAY>; |
| 93 | + tap-ms = <SELECT_WORD_DELAY>; |
| 94 | + bindings = <&kp _END &kp LS(_HOME)>; |
| 95 | +) |
| 96 | + |
| 97 | +// |
| 98 | +// extend current selection by one line |
| 99 | +// |
| 100 | +ZMK_MOD_MORPH(extend_line, |
| 101 | + bindings = <&extend_line_right>, <&extend_line_left>; |
| 102 | + mods = <(MOD_LSFT|MOD_RSFT)>; |
| 103 | +) |
| 104 | +ZMK_MACRO(extend_line_right, |
| 105 | + wait-ms = <SELECT_WORD_DELAY>; |
| 106 | + tap-ms = <SELECT_WORD_DELAY>; |
| 107 | + bindings = <&kp LS(DOWN) &kp LS(_END)>; |
| 108 | +) |
| 109 | +ZMK_MACRO(extend_line_left, |
| 110 | + wait-ms = <SELECT_WORD_DELAY>; |
| 111 | + tap-ms = <SELECT_WORD_DELAY>; |
| 112 | + bindings = <&kp LS(UP) &kp LS(_HOME)>; |
| 113 | +) |
0 commit comments