Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Leader key feature #19632

Merged
merged 14 commits into from
Feb 12, 2023
338 changes: 235 additions & 103 deletions docs/feature_leader_key.md

Large diffs are not rendered by default.

55 changes: 24 additions & 31 deletions keyboards/7c8/framework/keymaps/steven/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,42 +78,35 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
)
};

LEADER_EXTERNS();

void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();

// qq, alt+f4 close window
SEQ_TWO_KEYS(KC_Q, KC_Q) {
tap_code16(A(KC_F4));
}
void leader_end_user(void) {
// qq, alt+f4 close window
if (leader_sequence_two_keys(KC_Q, KC_Q)) {
tap_code16(A(KC_F4));
}

// ee, open explorer
SEQ_TWO_KEYS(KC_E, KC_E) {
tap_code16(G(KC_E));
}
// ee, open explorer
if (leader_sequence_two_keys(KC_E, KC_E)) {
tap_code16(G(KC_E));
}

// rr, windows run prompt
SEQ_TWO_KEYS(KC_R, KC_R) {
tap_code16(G(KC_R));
}
// rr, windows run prompt
if (leader_sequence_two_keys(KC_R, KC_R)) {
tap_code16(G(KC_R));
}

// ww, maximize window
SEQ_TWO_KEYS(KC_W, KC_W) {
tap_code16(G(KC_UP));
}
// ww, maximize window
if (leader_sequence_two_keys(KC_W, KC_W)) {
tap_code16(G(KC_UP));
}

// ss, minimize window
SEQ_TWO_KEYS(KC_S, KC_S) {
tap_code16(G(KC_DOWN));
}
// ss, minimize window
if (leader_sequence_two_keys(KC_S, KC_S)) {
tap_code16(G(KC_DOWN));
}

// <space><space>, toggle desktop
SEQ_TWO_KEYS(KC_SPC, KC_SPC) {
tap_code16(G(KC_D));
}
// <space><space>, toggle desktop
if (leader_sequence_two_keys(KC_SPC, KC_SPC)) {
tap_code16(G(KC_D));
}
}

Expand Down
86 changes: 41 additions & 45 deletions keyboards/dz60/keymaps/jdelkins/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,47 @@ void keyboard_post_init_keymap(void) {
bspc_timer = 0;
}

LEADER_EXTERNS();
void leader_end_user(void) {
// layer navigation
if (leader_sequence_one_key(KC_R)) { layer_invert(_RPT); }
if (leader_sequence_one_key(KC_G)) { layer_invert(_GAME); }
if (leader_sequence_one_key(KC_K)) { layer_invert(_KP); }
if (leader_sequence_one_key(KC_KP_5)) { layer_invert(_KP); }

// tmux navigation
if (leader_sequence_one_key(KC_L)) { SEND_STRING(SS_LCTL("a") "n"); }
if (leader_sequence_one_key(KC_H)) { SEND_STRING(SS_LCTL("a") "p"); }
if (leader_sequence_one_key(KC_N)) { SEND_STRING(SS_LCTL("a") "c"); }
if (leader_sequence_one_key(KC_W)) { SEND_STRING(SS_LCTL("a") "x"); }
if (leader_sequence_one_key(KC_MINS)) { SEND_STRING(SS_LCTL("a") "-"); }
if (leader_sequence_one_key(KC_QUOT)) { SEND_STRING(SS_LCTL("a") "\""); }
if (leader_sequence_one_key(KC_1)) { SEND_STRING(SS_LCTL("a") "1"); }
if (leader_sequence_one_key(KC_2)) { SEND_STRING(SS_LCTL("a") "2"); }
if (leader_sequence_one_key(KC_3)) { SEND_STRING(SS_LCTL("a") "3"); }
if (leader_sequence_one_key(KC_4)) { SEND_STRING(SS_LCTL("a") "4"); }
if (leader_sequence_one_key(KC_5)) { SEND_STRING(SS_LCTL("a") "5"); }
if (leader_sequence_one_key(KC_6)) { SEND_STRING(SS_LCTL("a") "6"); }
if (leader_sequence_one_key(KC_7)) { SEND_STRING(SS_LCTL("a") "7"); }
if (leader_sequence_one_key(KC_8)) { SEND_STRING(SS_LCTL("a") "8"); }
if (leader_sequence_one_key(KC_9)) { SEND_STRING(SS_LCTL("a") "9"); }

// secrets
if (leader_sequence_two_keys(KC_SCLN, KC_M)) { send_secret_string(0); }
if (leader_sequence_two_keys(KC_SCLN, KC_COMM)) { send_secret_string(1); }
if (leader_sequence_two_keys(KC_SCLN, KC_DOT)) { send_secret_string(2); }
if (leader_sequence_two_keys(KC_SCLN, KC_J)) { send_secret_string(3); }
if (leader_sequence_two_keys(KC_SCLN, KC_K)) { send_secret_string(4); }
if (leader_sequence_two_keys(KC_SCLN, KC_L)) { send_secret_string(5); }

// fast control-C
if (leader_sequence_one_key(KC_C)) { tap_code16(C(KC_C)); }

// neovim: terminal escape
if (leader_sequence_one_key(KC_BSLS)) {
tap_code16(C(KC_BSLS));
tap_code16(C(KC_N));
}
}

void matrix_scan_keymap(void) {
if (rgblight_is_enabled() && timer_elapsed(rgb_timer) > 1000) {
Expand All @@ -248,50 +288,6 @@ void matrix_scan_keymap(void) {
bspc_timer = 0;
register_code(KC_BSPC);
}
LEADER_DICTIONARY() {
leading = false;
leader_end();

// layer navigation
SEQ_ONE_KEY(KC_R) { layer_invert(_RPT); }
SEQ_ONE_KEY(KC_G) { layer_invert(_GAME); }
SEQ_ONE_KEY(KC_K) { layer_invert(_KP); }
SEQ_ONE_KEY(KC_KP_5) { layer_invert(_KP); }

// tmux navigation
SEQ_ONE_KEY(KC_L) { SEND_STRING(SS_LCTL("a") "n"); }
SEQ_ONE_KEY(KC_H) { SEND_STRING(SS_LCTL("a") "p"); }
SEQ_ONE_KEY(KC_N) { SEND_STRING(SS_LCTL("a") "c"); }
SEQ_ONE_KEY(KC_W) { SEND_STRING(SS_LCTL("a") "x"); }
SEQ_ONE_KEY(KC_MINS) { SEND_STRING(SS_LCTL("a") "-"); }
SEQ_ONE_KEY(KC_QUOT) { SEND_STRING(SS_LCTL("a") "\""); }
SEQ_ONE_KEY(KC_1) { SEND_STRING(SS_LCTL("a") "1"); }
SEQ_ONE_KEY(KC_2) { SEND_STRING(SS_LCTL("a") "2"); }
SEQ_ONE_KEY(KC_3) { SEND_STRING(SS_LCTL("a") "3"); }
SEQ_ONE_KEY(KC_4) { SEND_STRING(SS_LCTL("a") "4"); }
SEQ_ONE_KEY(KC_5) { SEND_STRING(SS_LCTL("a") "5"); }
SEQ_ONE_KEY(KC_6) { SEND_STRING(SS_LCTL("a") "6"); }
SEQ_ONE_KEY(KC_7) { SEND_STRING(SS_LCTL("a") "7"); }
SEQ_ONE_KEY(KC_8) { SEND_STRING(SS_LCTL("a") "8"); }
SEQ_ONE_KEY(KC_9) { SEND_STRING(SS_LCTL("a") "9"); }

// secrets
SEQ_TWO_KEYS(KC_SCLN, KC_M) { send_secret_string(0); }
SEQ_TWO_KEYS(KC_SCLN, KC_COMM) { send_secret_string(1); }
SEQ_TWO_KEYS(KC_SCLN, KC_DOT) { send_secret_string(2); }
SEQ_TWO_KEYS(KC_SCLN, KC_J) { send_secret_string(3); }
SEQ_TWO_KEYS(KC_SCLN, KC_K) { send_secret_string(4); }
SEQ_TWO_KEYS(KC_SCLN, KC_L) { send_secret_string(5); }

// fast control-C
SEQ_ONE_KEY(KC_C) { tap_code16(C(KC_C)); }

// neovim: terminal escape
SEQ_ONE_KEY(KC_BSLS) {
tap_code16(C(KC_BSLS));
tap_code16(C(KC_N));
}
}
}

bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
Expand Down
Loading