1
0
Fork 0

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.
This commit is contained in:
xton 2018-05-12 15:37:20 -07:00 committed by Drashna Jaelre
parent 6dda0d6e34
commit 975c48efe6
2 changed files with 25 additions and 28 deletions

View file

@ -152,16 +152,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if(process_record_xtonhasvim(keycode, record)) {
// do nothing so far
return true;
} else {
// already handled by vim
return false;
}
}
/** Set just 4 LEDs closest to the user. Slightly less annoying to bystanders.*/
void rgbflag(uint8_t r, uint8_t g, uint8_t b) {
for(int i = 0; i < RGBLED_NUM; i++){

View file

@ -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;
}
}