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 | |
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')
-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 85048401d8..0ec331b684 100644 --- a/users/xtonhasvim/xtonhasvim.c +++ b/users/xtonhasvim/xtonhasvim.c @@ -53,24 +53,17 @@ static void ALT(uint16_t keycode) { } -uint16_t vstate = VIM_START; -bool yank_was_lines = false; -bool SHIFTED = false; -uint32_t mod_override_layer_state = 0; -uint16_t mod_override_triggering_key = 0; -bool do_check_kb_clear = false; +static uint16_t vstate = VIM_START; +static bool yank_was_lines = false; +static bool SHIFTED = false; +static uint32_t mod_override_layer_state = 0; +static uint16_t mod_override_triggering_key = 0; -void vim_reset(void) { - vstate = VIM_START; - SHIFTED = false; - yank_was_lines = false; -} - -void edit(void) { vstate = VIM_START; layer_on(_EDIT); layer_off(_CMD); } +static void edit(void) { vstate = VIM_START; layer_on(_EDIT); layer_off(_CMD); } #define EDIT edit() -void simple_movement(uint16_t keycode) { +static void simple_movement(uint16_t keycode) { switch(keycode) { case VIM_B: PRESS(KC_LALT); @@ -109,18 +102,25 @@ void simple_movement(uint16_t keycode) { } } -bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) { +__attribute__ ((weak)) +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + return true; +} + +#define PASS_THRU process_record_keymap(keycode, record) + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { if(record->event.pressed && layer_state_is(_CMD) && IS_MOD(keycode)) { mod_override_layer_state = layer_state; mod_override_triggering_key = keycode; layer_clear(); - return true; // let the event fall through... + return PASS_THRU; // let the event fall through... } if(mod_override_layer_state && !record->event.pressed && keycode == mod_override_triggering_key) { layer_state_set(mod_override_layer_state); mod_override_layer_state = 0; mod_override_triggering_key = 0; - return true; + return PASS_THRU; } if (VIM_START <= keycode && keycode <= VIM_ESC) { @@ -134,6 +134,13 @@ bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) { // entry from anywhere layer_on(_CMD); vstate = VIM_START; + + // reset state + yank_was_lines = false; + SHIFTED = false; + mod_override_layer_state = 0; + mod_override_triggering_key = 0; + return false; } switch(vstate) { @@ -594,6 +601,6 @@ bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) { } return false; } else { - return true; + return PASS_THRU; } } |