diff options
Diffstat (limited to 'users/xtonhasvim/xtonhasvim.c')
| -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 | } |
