diff options
| author | xton <cmdpix@mac.com> | 2018-05-12 15:37:20 -0700 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-05-12 15:37:20 -0700 |
| commit | 975c48efe6fcc0a1523ea1b9a98e0804b7ff33f6 (patch) | |
| tree | ed1cba58626be04d3bbbb5b1c456ba0d9dd5c267 /users/xtonhasvim | |
| parent | 6dda0d6e34ac47c6dfdee1429937b445bf941425 (diff) | |
| download | qmk_firmware-975c48efe6fcc0a1523ea1b9a98e0804b7ff33f6.tar.gz qmk_firmware-975c48efe6fcc0a1523ea1b9a98e0804b7ff33f6.zip | |
xtonhasvim cleanup (#2947)
* FORK!
* WIP - just how i like it
* empty
* more movement
* mouse keys
* more vimminess
* append/insert shift
* WIP - vim macros
* blocked out layer below in cmd mode.
also, about to restart my cmd approach.
* WIP - new vim layer
ripoff of the ergodox one, but rewritten as a state machine.
* debugged some, got key repeat working
* moooar coverage
* moooar coverage
* regular vis mode
* basically done with basics.
* some refactoring
- common movement sequences into helper function
- added some rgb controls
* modkey passthru feature
* stdized on cmd-left/right instead of ctrl-a/e
sadly. as there's no reliable shift-ctrl-e
* indicator lights
* moved vim layer into userspace
* cleaned up some yanking edge cases
* docs and some tweaks to layerescapes
* updated/added license strings
* updated comments
* moved config changes to keymap
* spurious changes removed
* cleanup pass, HT drashna for suggestions
- used _keymap() pattern to better modularize event processing in userspace
- made some static things static
- removed unused function
- improved reset.
Diffstat (limited to 'users/xtonhasvim')
| -rw-r--r-- | users/xtonhasvim/xtonhasvim.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/users/xtonhasvim/xtonhasvim.c b/users/xtonhasvim/xtonhasvim.c index 85048401d..0ec331b68 100644 --- a/users/xtonhasvim/xtonhasvim.c +++ b/users/xtonhasvim/xtonhasvim.c | |||
| @@ -53,24 +53,17 @@ static void ALT(uint16_t keycode) { | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | uint16_t vstate = VIM_START; | 56 | static uint16_t vstate = VIM_START; |
| 57 | bool yank_was_lines = false; | 57 | static bool yank_was_lines = false; |
| 58 | bool SHIFTED = false; | 58 | static bool SHIFTED = false; |
| 59 | uint32_t mod_override_layer_state = 0; | 59 | static uint32_t mod_override_layer_state = 0; |
| 60 | uint16_t mod_override_triggering_key = 0; | 60 | static uint16_t mod_override_triggering_key = 0; |
| 61 | bool do_check_kb_clear = false; | ||
| 62 | 61 | ||
| 63 | void vim_reset(void) { | 62 | static void edit(void) { vstate = VIM_START; layer_on(_EDIT); layer_off(_CMD); } |
| 64 | vstate = VIM_START; | ||
| 65 | SHIFTED = false; | ||
| 66 | yank_was_lines = false; | ||
| 67 | } | ||
| 68 | |||
| 69 | void edit(void) { vstate = VIM_START; layer_on(_EDIT); layer_off(_CMD); } | ||
| 70 | #define EDIT edit() | 63 | #define EDIT edit() |
| 71 | 64 | ||
| 72 | 65 | ||
| 73 | void simple_movement(uint16_t keycode) { | 66 | static void simple_movement(uint16_t keycode) { |
| 74 | switch(keycode) { | 67 | switch(keycode) { |
| 75 | case VIM_B: | 68 | case VIM_B: |
| 76 | PRESS(KC_LALT); | 69 | PRESS(KC_LALT); |
| @@ -109,18 +102,25 @@ void simple_movement(uint16_t keycode) { | |||
| 109 | } | 102 | } |
| 110 | } | 103 | } |
| 111 | 104 | ||
| 112 | bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) { | 105 | __attribute__ ((weak)) |
| 106 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | ||
| 107 | return true; | ||
| 108 | } | ||
| 109 | |||
| 110 | #define PASS_THRU process_record_keymap(keycode, record) | ||
| 111 | |||
| 112 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 113 | if(record->event.pressed && layer_state_is(_CMD) && IS_MOD(keycode)) { | 113 | if(record->event.pressed && layer_state_is(_CMD) && IS_MOD(keycode)) { |
| 114 | mod_override_layer_state = layer_state; | 114 | mod_override_layer_state = layer_state; |
| 115 | mod_override_triggering_key = keycode; | 115 | mod_override_triggering_key = keycode; |
| 116 | layer_clear(); | 116 | layer_clear(); |
| 117 | return true; // let the event fall through... | 117 | return PASS_THRU; // let the event fall through... |
| 118 | } | 118 | } |
| 119 | if(mod_override_layer_state && !record->event.pressed && keycode == mod_override_triggering_key) { | 119 | if(mod_override_layer_state && !record->event.pressed && keycode == mod_override_triggering_key) { |
| 120 | layer_state_set(mod_override_layer_state); | 120 | layer_state_set(mod_override_layer_state); |
| 121 | mod_override_layer_state = 0; | 121 | mod_override_layer_state = 0; |
| 122 | mod_override_triggering_key = 0; | 122 | mod_override_triggering_key = 0; |
| 123 | return true; | 123 | return PASS_THRU; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | if (VIM_START <= keycode && keycode <= VIM_ESC) { | 126 | if (VIM_START <= keycode && keycode <= VIM_ESC) { |
| @@ -134,6 +134,13 @@ bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) { | |||
| 134 | // entry from anywhere | 134 | // entry from anywhere |
| 135 | layer_on(_CMD); | 135 | layer_on(_CMD); |
| 136 | vstate = VIM_START; | 136 | vstate = VIM_START; |
| 137 | |||
| 138 | // reset state | ||
| 139 | yank_was_lines = false; | ||
| 140 | SHIFTED = false; | ||
| 141 | mod_override_layer_state = 0; | ||
| 142 | mod_override_triggering_key = 0; | ||
| 143 | |||
| 137 | return false; | 144 | return false; |
| 138 | } | 145 | } |
| 139 | switch(vstate) { | 146 | switch(vstate) { |
| @@ -594,6 +601,6 @@ bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) { | |||
| 594 | } | 601 | } |
| 595 | return false; | 602 | return false; |
| 596 | } else { | 603 | } else { |
| 597 | return true; | 604 | return PASS_THRU; |
| 598 | } | 605 | } |
| 599 | } | 606 | } |
