1
0
Fork 0

Refactor Leader key feature (#19632)

Co-authored-by: Drashna Jaelre <drashna@live.com>
This commit is contained in:
Ryan 2023-02-13 03:19:02 +11:00 committed by GitHub
parent d10350cd2c
commit bbf7a20b33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 2457 additions and 1968 deletions

View file

@ -7,7 +7,12 @@ uint16_t muse_counter = 0;
uint8_t muse_offset = 70;
uint16_t muse_tempo = 50;
LEADER_EXTERNS();
void leader_end_user(void) {
// reset keyboard to bootloader
if (leader_sequence_five_keys(KC_R, KC_E, KC_S, KC_E, KC_T)) {
reset_keyboard();
}
}
void matrix_scan_user(void) {
#ifdef AUDIO_ENABLE
@ -28,15 +33,6 @@ void matrix_scan_user(void) {
}
}
#endif
LEADER_DICTIONARY() {
leading = false;
// reset keyboard to bootloader
SEQ_FIVE_KEYS(KC_R, KC_E, KC_S, KC_E, KC_T) {
reset_keyboard();
}
leader_end();
}
}
bool syml_pressed = false;

View file

@ -303,146 +303,141 @@ void pri_mod_keystroke(uint16_t key) {
pri_mod(false);
}
void leader_end_user(void) {
// begin OS functions
if (leader_sequence_two_keys(KC_P, KC_B)) {
if (current_os == OS_WIN) {
long_keystroke(2, (uint16_t[]){KC_LGUI, KC_PAUSE});
} else {
return;
}
}
if (leader_sequence_two_keys(KC_S, KC_S)) {
if (current_os == OS_MAC) {
long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4});
} else if (current_os == OS_WIN) {
long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_S});
} else {
return;
}
}
if (leader_sequence_three_keys(KC_C, KC_A, KC_D)) {
if (current_os == OS_WIN) {
long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LALT, KC_DEL});
} else {
}
}
if (leader_sequence_three_keys(KC_C, KC_A, KC_E)) {
if (current_os == OS_WIN) {
long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LALT, KC_END});
} else {
}
}
// end OS functions
// begin format functions
if (leader_sequence_one_key(KC_B)) {
surround_type(2, KC_8, true);
}
if (leader_sequence_one_key(KC_I)) {
surround_type(2, KC_MINS, true);
}
if (leader_sequence_one_key(KC_U)) {
surround_type(4, KC_MINS, true);
}
if (leader_sequence_one_key(KC_S)) {
surround_type(4, KC_GRAVE, true);
}
if (leader_sequence_one_key(KC_C)) {
register_unicode(0x00E7); // ç
}
if (leader_sequence_two_keys(KC_A, KC_V)) {
surround_type(2, KC_QUOT, true);
pair_surround_type(2, KC_LCBR, true);
surround_type(2, KC_SPC, false);
}
if (leader_sequence_two_keys(KC_M, KC_L)) {
pair_surround_type(1, KC_LBRC, false);
SEND_STRING("LINK_NAME");
tap_code(KC_RGHT);
pair_surround_type(1, KC_LPRN, true);
pri_mod_keystroke(KC_V);
}
if (leader_sequence_two_keys(KC_C, KC_C)) {
surround_type(2, KC_GRAVE, false);
}
if (leader_sequence_three_keys(KC_C, KC_C, KC_C)) {
surround_type(6, KC_GRAVE, false);
}
if (leader_sequence_one_key(KC_E)) {
register_unicode(0x00E8); // è
}
if (leader_sequence_two_keys(KC_E, KC_E)) {
register_unicode(0x00E9); // é
}
// end format functions
// start fancy functions
if (leader_sequence_two_keys(KC_V, KC_P)) {
SEND_STRING("ggvG}x:set paste\ni");
pri_mod_keystroke(KC_V);
}
if (leader_sequence_three_keys(KC_C, KC_C, KC_ENT)) {
surround_type(6, KC_GRAVE, false);
pri_mod_keystroke(KC_V);
multi_tap(3, KC_RGHT, false);
tap_code(KC_ENTER);
}
if (leader_sequence_three_keys(KC_T, KC_C, KC_ENT)) {
multi_tap(3, KC_GRAVE, false);
pri_mod_keystroke(KC_V);
multi_tap(2, KC_ENTER, false);
}
// end fancy functions
// start typing functions
if (leader_sequence_two_keys(KC_T, KC_M)) {
register_unicode(0x2122); // ™
}
if (leader_sequence_two_keys(KC_D, KC_D)) {
SEND_STRING(".\\Administrator");
}
if (leader_sequence_three_keys(KC_D, KC_D, KC_D)) {
SEND_STRING(".\\Administrator");
tap_code(KC_TAB);
pri_mod_keystroke(KC_V);
tap_code(KC_ENTER);
}
if (leader_sequence_three_keys(KC_L, KC_O, KC_D)) {
send_unicode_string("ಠ__ಠ");
}
if (leader_sequence_three_keys(KC_M, KC_A, KC_P)) {
SEND_STRING("https://github.com/qmk/qmk_firmware/tree/master/users/arkag");
}
if (leader_sequence_two_keys(KC_F, KC_F)) {
send_unicode_string("(╯‵Д′)╯彡┻━┻");
}
if (leader_sequence_three_keys(KC_F, KC_F, KC_F)) {
send_unicode_string("┬─┬ノ( º _ º )");
}
if (leader_sequence_three_keys(KC_L, KC_O, KC_L)) {
send_unicode_string("( ͡° ͜ʖ ͡°)");
}
if (leader_sequence_three_keys(KC_S, KC_S, KC_S)) {
send_unicode_string("¯\\_(ツ)_/¯");
}
// end typing functions
}
void matrix_init_user(void) {
current_os = eeprom_read_byte(EECONFIG_USERSPACE);
set_os(current_os, false);
}
LEADER_EXTERNS();
void matrix_scan_user(void) {
check_state();
flash_rgb();
fade_rgb();
LEADER_DICTIONARY() {
leading = false;
leader_end();
// begin OS functions
SEQ_TWO_KEYS(KC_P, KC_B) {
if (current_os == OS_WIN) {
long_keystroke(2, (uint16_t[]){KC_LGUI, KC_PAUSE});
} else {
return;
}
}
SEQ_TWO_KEYS(KC_S, KC_S) {
if (current_os == OS_MAC) {
long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4});
} else if (current_os == OS_WIN) {
long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_S});
} else {
return;
}
}
SEQ_THREE_KEYS(KC_C, KC_A, KC_D) {
if (current_os == OS_WIN) {
long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LALT, KC_DEL});
} else {
}
}
SEQ_THREE_KEYS(KC_C, KC_A, KC_E) {
if (current_os == OS_WIN) {
long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LALT, KC_END});
} else {
}
}
// end OS functions
// begin format functions
SEQ_ONE_KEY(KC_B) {
surround_type(2, KC_8, true);
}
SEQ_ONE_KEY(KC_I) {
surround_type(2, KC_MINS, true);
}
SEQ_ONE_KEY(KC_U) {
surround_type(4, KC_MINS, true);
}
SEQ_ONE_KEY(KC_S) {
surround_type(4, KC_GRAVE, true);
}
SEQ_ONE_KEY(KC_C) {
register_unicode(0x00E7); // ç
}
SEQ_TWO_KEYS(KC_A, KC_V) {
surround_type(2, KC_QUOT, true);
pair_surround_type(2, KC_LCBR, true);
surround_type(2, KC_SPC, false);
}
SEQ_TWO_KEYS(KC_M, KC_L) {
pair_surround_type(1, KC_LBRC, false);
SEND_STRING("LINK_NAME");
tap_code(KC_RGHT);
pair_surround_type(1, KC_LPRN, true);
pri_mod_keystroke(KC_V);
}
SEQ_TWO_KEYS(KC_C, KC_C) {
surround_type(2, KC_GRAVE, false);
}
SEQ_THREE_KEYS(KC_C, KC_C, KC_C) {
surround_type(6, KC_GRAVE, false);
}
SEQ_ONE_KEY(KC_E) {
register_unicode(0x00E8); // è
}
SEQ_TWO_KEYS(KC_E, KC_E) {
register_unicode(0x00E9); // é
}
// end format functions
// start fancy functions
SEQ_TWO_KEYS(KC_V, KC_P) {
SEND_STRING("ggvG}x:set paste\ni");
pri_mod_keystroke(KC_V);
}
SEQ_THREE_KEYS(KC_C, KC_C, KC_ENT) {
surround_type(6, KC_GRAVE, false);
pri_mod_keystroke(KC_V);
multi_tap(3, KC_RGHT, false);
tap_code(KC_ENTER);
}
SEQ_THREE_KEYS(KC_T, KC_C, KC_ENT) {
multi_tap(3, KC_GRAVE, false);
pri_mod_keystroke(KC_V);
multi_tap(2, KC_ENTER, false);
}
// end fancy functions
// start typing functions
SEQ_TWO_KEYS(KC_T, KC_M) {
register_unicode(0x2122); // ™
}
SEQ_TWO_KEYS(KC_D, KC_D) {
SEND_STRING(".\\Administrator");
}
SEQ_THREE_KEYS(KC_D, KC_D, KC_D) {
SEND_STRING(".\\Administrator");
tap_code(KC_TAB);
pri_mod_keystroke(KC_V);
tap_code(KC_ENTER);
}
SEQ_THREE_KEYS(KC_L, KC_O, KC_D) {
send_unicode_string("ಠ__ಠ");
}
SEQ_THREE_KEYS(KC_M, KC_A, KC_P) {
SEND_STRING("https://github.com/qmk/qmk_firmware/tree/master/users/arkag");
}
SEQ_TWO_KEYS(KC_F, KC_F) {
send_unicode_string("(╯‵Д′)╯彡┻━┻");
}
SEQ_THREE_KEYS(KC_F, KC_F, KC_F) {
send_unicode_string("┬─┬ノ( º _ º )");
}
SEQ_THREE_KEYS(KC_L, KC_O, KC_L) {
send_unicode_string("( ͡° ͜ʖ ͡°)");
}
SEQ_THREE_KEYS(KC_S, KC_S, KC_S) {
send_unicode_string("¯\\_(ツ)_/¯");
}
// end typing functions
}
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {

View file

@ -1,24 +0,0 @@
#include "curry.h"
#include "leader.h"
LEADER_EXTERNS();
void matrix_scan_user(void) {
static bool has_ran_yet;
if (!has_ran_yet) {
has_ran_yet = true;
startup_user();
}
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
matrix_scan_rgb();
#endif // RGBLIGHT_ENABLE
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_F) { SEND_STRING(SS_LCTL("akf")); } // Select all and format
SEQ_ONE_KEY(KC_P) { SEND_STRING(SS_LCTL(SS_LSFT("4"))); } // Screenshot region
SEQ_TWO_KEYS(KC_D, KC_D) { SEND_STRING(SS_LCTL("ac")); } // Copy all
}
matrix_scan_keymap();
}

31
users/curry/leader_user.c Normal file
View file

@ -0,0 +1,31 @@
#include "curry.h"
#include "leader_user.h"
void leader_end_user(void) {
if (leader_sequence_one_key(KC_F)) {
// Select all and format
SEND_STRING(SS_LCTL("akf"));
}
if (leader_sequence_one_key(KC_P)) {
// Screenshot region
SEND_STRING(SS_LCTL(SS_LSFT("4")));
}
if (leader_sequence_two_keys(KC_D, KC_D)) {
// Copy all
SEND_STRING(SS_LCTL("ac"));
}
}
void matrix_scan_user(void) {
static bool has_ran_yet;
if (!has_ran_yet) {
has_ran_yet = true;
startup_user();
}
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
matrix_scan_rgb();
#endif // RGBLIGHT_ENABLE
matrix_scan_keymap();
}

View file

@ -29,7 +29,7 @@ ifeq ($(strip $(OLED_ENABLE)), yes)
endif
ifeq ($(strip $(LEADER_ENABLE)), yes)
SRC += leader.c
SRC += leader_user.c
endif
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)

View file

@ -4,84 +4,121 @@ bool onMac = true;
//**************** LEADER *********************//
#ifdef LEADER_ENABLE
LEADER_EXTERNS();
void leader_start_user(vodi) {
# ifdef RGBLIGHT_ENABLE
void leader_start_user(void) { rgblight_setrgb_range(5, 100, 199, 10, 15); };
void leader_end_user(void) { rgblight_setrgb_range(200, 200, 255, 10, 15); };
rgblight_setrgb_range(5, 100, 199, 10, 15);
# endif
}
void matrix_scan_user(void) {
if (leading && leader_sequence_size > 0 && timer_elapsed(leader_time) > LEADER_TIMEOUT) {
leading = false;
SEQ_ONE_KEY(KC_T) { SEND_STRING("``" SS_TAP(X_LEFT)); }
// Triple ticks
SEQ_TWO_KEYS(KC_T, KC_T) { SEND_STRING("```" SS_TAP(X_ENTER) SS_TAP(X_ENTER) "```" SS_TAP(X_UP)); }
// ==== International spanish accent vowels ====
SEQ_ONE_KEY(KC_A) { SEND_STRING(SS_LALT("e") "a"); }
SEQ_ONE_KEY(KC_E) { SEND_STRING(SS_LALT("e") "e"); }
SEQ_ONE_KEY(KC_I) { SEND_STRING(SS_LALT("e") "i"); }
SEQ_ONE_KEY(KC_O) { SEND_STRING(SS_LALT("e") "o"); }
SEQ_ONE_KEY(KC_U) { SEND_STRING(SS_LALT("e") "u"); }
SEQ_ONE_KEY(KC_N) { SEND_STRING(SS_LALT("n") "n"); }
// ==== MACROS ===
SEQ_ONE_KEY(KC_G) { SEND_STRING(" | grep "); }
SEQ_ONE_KEY(KC_K) { onMac ? SEND_STRING(SS_LCTL(" ")) : SEND_STRING(SS_LCTL("f")); }
// vim delete all
SEQ_TWO_KEYS(KC_D, KC_G) {
if (onMac) {
SEND_STRING(SS_LGUI("a") SS_TAP(X_D));
} else {
SEND_STRING(SS_LCTL("a") SS_TAP(X_D));
}
}
// tripe delete!
SEQ_ONE_KEY(KC_BACKSPACE) { SEND_STRING(SS_TAP(X_BACKSPACE) SS_TAP(X_BACKSPACE) SS_TAP(X_BACKSPACE)); }
SEQ_TWO_KEYS(KC_P, KC_G) { SEND_STRING("ps -ef | grep "); }
SEQ_TWO_KEYS(KC_J, KC_A) { SEND_STRING("() => {}" SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT)); }
// this is a pain to type
SEQ_TWO_KEYS(KC_S, KC_S) { SEND_STRING("~/.ssh/ "); }
SEQ_TWO_KEYS(KC_F, KC_T) { SEND_STRING("feat():" SS_TAP(X_LEFT) SS_TAP(X_LEFT)); }
// ### LAYER CHANGE
SEQ_ONE_KEY(KC_1) { layer_on(1); }
// control enter, because yes
SEQ_ONE_KEY(KC_H) { SEND_STRING(SS_DOWN(X_LCTL) SS_TAP(X_ENTER) SS_UP(X_LCTL)); }
// paste all
SEQ_ONE_KEY(KC_P) {
if (onMac) {
SEND_STRING(SS_LGUI("a") SS_LGUI("v"));
} else {
SEND_STRING(SS_LCTL("a") SS_LCTL("v"));
}
}
SEQ_THREE_KEYS(KC_M, KC_A, KC_C) {
onMac = true;
# ifdef RGBLIGHT_ENABLE
rgblight_setrgb(255, 255, 255);
# endif
}
SEQ_THREE_KEYS(KC_W, KC_I, KC_N) {
onMac = false;
# ifdef RGBLIGHT_ENABLE
rgblight_setrgb(255, 255, 0);
# endif
}
/* Copy all */
SEQ_ONE_KEY(KC_Y) {
if (onMac) {
SEND_STRING(SS_LGUI("a") SS_LGUI("c"));
} else {
SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
}
}
// emoji bar
SEQ_TWO_KEYS(KC_E, KC_E) { SEND_STRING(SS_DOWN(X_LGUI) SS_LCTL(" ") SS_UP(X_LGUI)); }
SEQ_TWO_KEYS(KC_F, KC_F) { SEND_STRING("ps -ef | grep "); }
SEQ_TWO_KEYS(KC_H, KC_T) { SEND_STRING("https://"); }
leader_end();
void leader_end_user() {
if (leader_sequence_one_key(KC_T)) {
SEND_STRING("``" SS_TAP(X_LEFT));
}
// Triple ticks
if (leader_sequence_two_keys(KC_T, KC_T)) {
SEND_STRING("```" SS_TAP(X_ENTER) SS_TAP(X_ENTER) "```" SS_TAP(X_UP));
}
// ==== International spanish accent vowels ====
if (leader_sequence_one_key(KC_A)) {
SEND_STRING(SS_LALT("e") "a");
}
if (leader_sequence_one_key(KC_E)) {
SEND_STRING(SS_LALT("e") "e");
}
if (leader_sequence_one_key(KC_I)) {
SEND_STRING(SS_LALT("e") "i");
}
if (leader_sequence_one_key(KC_O)) {
SEND_STRING(SS_LALT("e") "o");
}
if (leader_sequence_one_key(KC_U)) {
SEND_STRING(SS_LALT("e") "u");
}
if (leader_sequence_one_key(KC_N)) {
SEND_STRING(SS_LALT("n") "n");
}
// ==== MACROS ===
if (leader_sequence_one_key(KC_G)) {
SEND_STRING(" | grep ");
}
if (leader_sequence_one_key(KC_K)) {
onMac ? SEND_STRING(SS_LCTL(" ")) : SEND_STRING(SS_LCTL("f"));
}
// vim delete all
if (leader_sequence_two_keys(KC_D, KC_G)) {
if (onMac) {
SEND_STRING(SS_LGUI("a") SS_TAP(X_D));
} else {
SEND_STRING(SS_LCTL("a") SS_TAP(X_D));
}
}
// tripe delete!
if (leader_sequence_one_key(KC_BACKSPACE)) {
SEND_STRING(SS_TAP(X_BACKSPACE) SS_TAP(X_BACKSPACE) SS_TAP(X_BACKSPACE));
}
if (leader_sequence_two_keys(KC_P, KC_G)) {
SEND_STRING("ps -ef | grep ");
}
if (leader_sequence_two_keys(KC_J, KC_A)) {
SEND_STRING("() => {}" SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT));
}
// this is a pain to type
if (leader_sequence_two_keys(KC_S, KC_S)) {
SEND_STRING("~/.ssh/ ");
}
if (leader_sequence_two_keys(KC_F, KC_T)) {
SEND_STRING("feat():" SS_TAP(X_LEFT) SS_TAP(X_LEFT));
}
// ### LAYER CHANGE
if (leader_sequence_one_key(KC_1)) {
layer_on(1);
}
// control enter, because yes
if (leader_sequence_one_key(KC_H)) {
SEND_STRING(SS_DOWN(X_LCTL) SS_TAP(X_ENTER) SS_UP(X_LCTL));
}
// paste all
if (leader_sequence_one_key(KC_P)) {
if (onMac) {
SEND_STRING(SS_LGUI("a") SS_LGUI("v"));
} else {
SEND_STRING(SS_LCTL("a") SS_LCTL("v"));
}
}
if (leader_sequence_three_keys(KC_M, KC_A, KC_C)) {
onMac = true;
# ifdef RGBLIGHT_ENABLE
rgblight_setrgb(255, 255, 255);
# endif
}
if (leader_sequence_three_keys(KC_W, KC_I, KC_N)) {
onMac = false;
# ifdef RGBLIGHT_ENABLE
rgblight_setrgb(255, 255, 0);
# endif
}
/* Copy all */
if (leader_sequence_one_key(KC_Y)) {
if (onMac) {
SEND_STRING(SS_LGUI("a") SS_LGUI("c"));
} else {
SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
}
}
// emoji bar
if (leader_sequence_two_keys(KC_E, KC_E)) {
SEND_STRING(SS_DOWN(X_LGUI) SS_LCTL(" ") SS_UP(X_LGUI));
}
if (leader_sequence_two_keys(KC_F, KC_F)) {
SEND_STRING("ps -ef | grep ");
}
if (leader_sequence_two_keys(KC_H, KC_T)) {
SEND_STRING("https://");
}
# ifdef RGBLIGHT_ENABLE
rgblight_setrgb_range(200, 200, 255, 10, 15);
# endif
}
#endif // LEADER

View file

@ -23,41 +23,36 @@ __attribute__((weak)) void matrix_scan_keymap(void) {}
__attribute__((weak)) void leader_scan_secrets(void) {}
#ifdef LEADER_ENABLE
LEADER_EXTERNS();
void matrix_scan_leader(void) {
static uint8_t mods = 0;
mods = get_mods();
LEADER_DICTIONARY() {
leading = false;
leader_end();
clear_mods();
void leader_end_user(void) {
static uint8_t mods = 0;
mods = get_mods();
clear_mods();
// Website Refresh / XCode "Run"
SEQ_ONE_KEY(KC_R) {
SEND_STRING(SS_LGUI("r"));
}
// Website Refresh / XCode "Run"
if (leader_sequence_one_key(KC_R)) {
SEND_STRING(SS_LGUI("r"));
}
SEQ_TWO_KEYS(KC_B, KC_D) {
send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " Built at: " QMK_BUILDDATE), TAP_CODE_DELAY);
}
if (leader_sequence_two_keys(KC_B, KC_D)) {
send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " Built at: " QMK_BUILDDATE), TAP_CODE_DELAY);
}
SEQ_TWO_KEYS(KC_L, KC_C) {
send_string_with_delay("/** */", TAP_CODE_DELAY);
wait_ms(TAPPING_TERM);
tap_code(KC_LEFT);
tap_code(KC_LEFT);
tap_code(KC_LEFT);
if (!(mods & MOD_MASK_SHIFT)) {
tap_code(KC_ENT);
}
}
set_mods(mods);
#ifndef NO_SECRETS
leader_scan_secrets();
#endif // !NO_SECRETS
if (leader_sequence_two_keys(KC_L, KC_C)) {
send_string_with_delay("/** */", TAP_CODE_DELAY);
wait_ms(TAPPING_TERM);
tap_code(KC_LEFT);
tap_code(KC_LEFT);
tap_code(KC_LEFT);
if (!(mods & MOD_MASK_SHIFT)) {
tap_code(KC_ENT);
}
}
set_mods(mods);
#ifndef NO_SECRETS
leader_scan_secrets();
#endif // !NO_SECRETS
}
#endif
static bool is_first_run = true;
@ -66,9 +61,7 @@ void matrix_scan_user(void) {
is_first_run = false;
startup_user();
}
#ifdef LEADER_ENABLE
matrix_scan_leader();
#endif
matrix_scan_keymap();
}

View file

@ -53,81 +53,70 @@ void tmux_pane_zoom(void) {
SEND_STRING("z");
}
LEADER_EXTERNS();
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
void leader_end_user(void) {
// Stop music and lock computer via alfred
if (leader_sequence_one_key(KC_H)) {
SEND_STRING(SS_LGUI(" ") SS_TAP(X_LGUI) "afk" SS_TAP(X_ENTER));
}
// Available seqs
// SEQ_ONE_KEY, SEQ_TWO_KEYS, SEQ_THREE_KEYS
// anything you can do in a macro https://docs.qmk.fm/macros.html
// https://docs.qmk.fm/feature_leader_key.html
// Stop music and lock computer via alfred
if (leader_sequence_two_keys(KC_H, KC_H)) {
SEND_STRING(SS_LGUI(" ") SS_TAP(X_LGUI) "afk" SS_TAP(X_ENTER) SS_TAP(X_MEDIA_PLAY_PAUSE));
}
// Stop music and lock computer via alfred
SEQ_ONE_KEY(KC_H) {
SEND_STRING(SS_LGUI(" ") SS_TAP(X_LGUI) "afk" SS_TAP(X_ENTER));
}
// Whole Screen Shot
if (leader_sequence_one_key(KC_A)) {
SEND_STRING(SS_LGUI(SS_LSFT("3")));
}
// Stop music and lock computer via alfred
SEQ_TWO_KEYS(KC_H, KC_H) {
SEND_STRING(SS_LGUI(" ") SS_TAP(X_LGUI) "afk" SS_TAP(X_ENTER) SS_TAP(X_MEDIA_PLAY_PAUSE));
}
// Selective Screen Shot
if (leader_sequence_one_key(KC_S)) {
SEND_STRING(SS_LGUI(SS_LSFT("4")));
}
// Whole Screen Shot
SEQ_ONE_KEY(KC_A) {
SEND_STRING(SS_LGUI(SS_LSFT("3")));
}
// TMUX - shift to pane 1 and zoom
if (leader_sequence_one_key(KC_J)) {
tmux_prefix();
SEND_STRING("q1");
tmux_pane_zoom();
}
// Selective Screen Shot
SEQ_ONE_KEY(KC_S) {
SEND_STRING(SS_LGUI(SS_LSFT("4")));
}
// TMUX - shift to first window
if (leader_sequence_two_keys(KC_J, KC_J)) {
tmux_prefix();
SEND_STRING("1");
}
// TMUX - shift to pane 1 and zoom
SEQ_ONE_KEY(KC_J) {
tmux_prefix();
SEND_STRING("q1");
tmux_pane_zoom();
}
// TMUX - shift to pane 2 and zoom
if (leader_sequence_one_key(KC_K)) {
tmux_prefix();
SEND_STRING("q2");
tmux_pane_zoom();
}
// TMUX - shift to first window
SEQ_TWO_KEYS(KC_J, KC_J) {
tmux_prefix();
SEND_STRING("1");
}
// TMUX - shift to second window
if (leader_sequence_two_keys(KC_K, KC_K)) {
tmux_prefix();
SEND_STRING("2");
}
// TMUX - shift to pane 2 and zoom
SEQ_ONE_KEY(KC_K) {
tmux_prefix();
SEND_STRING("q2");
tmux_pane_zoom();
}
// TMUX - shift to pane 3 and zoom
if (leader_sequence_one_key(KC_L)) {
tmux_prefix();
SEND_STRING("q3");
tmux_pane_zoom();
}
// TMUX - shift to second window
SEQ_TWO_KEYS(KC_K, KC_K) {
tmux_prefix();
SEND_STRING("2");
}
// TMUX - shift to third window
if (leader_sequence_two_keys(KC_L, KC_L)) {
tmux_prefix();
SEND_STRING("3");
}
// TMUX - shift to pane 3 and zoom
SEQ_ONE_KEY(KC_L) {
tmux_prefix();
SEND_STRING("q3");
tmux_pane_zoom();
}
// TMUX - shift to third window
SEQ_TWO_KEYS(KC_L, KC_L) {
tmux_prefix();
SEND_STRING("3");
}
// TMUX - shift to last pane and zoom
SEQ_ONE_KEY(KC_SEMICOLON) {
tmux_prefix();
SEND_STRING(";");
tmux_pane_zoom();
}
// TMUX - shift to last pane and zoom
if (leader_sequence_one_key(KC_SEMICOLON)) {
tmux_prefix();
SEND_STRING(";");
tmux_pane_zoom();
}
}

View file

@ -1,116 +0,0 @@
#include "leader.h"
#ifdef RGBLIGHT_ENABLE
extern rgblight_config_t rgblight_config;
#endif
bool leader_succeed;
LEADER_EXTERNS();
void matrix_scan_user(void) {
static bool has_ran_yet;
if (!has_ran_yet) {
has_ran_yet = true;
startup_user();
}
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
// run_diablo_macro_check();
#endif
#ifdef RGBLIGHT_ENABLE
matrix_scan_rgb();
#endif
LEADER_DICTIONARY() {
leader_succeed = leading = false;
SEQ_ONE_KEY(KC_W) {
// vim/tmux: Use in command mode in vim: write to file, switch tmux pane in the current session window and repeat the last command
SEND_STRING(":w" SS_TAP(X_ENTER));
tmux_pane_switch_repeat();
leader_succeed = true;
} else
SEQ_ONE_KEY(KC_T) {
// Send the Tmux Prefix
tmux_prefix();
leader_succeed = true;
} else
SEQ_ONE_KEY(KC_A) {
// tmux: Send the prefix and press 'right' arrow
tmux_prefix();
tap_code(KC_RIGHT);
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_T, KC_T) {
// tmux: Send the prefix to a nested session
tmux_prefix();
tmux_prefix();
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_T, KC_R) {
// tmux: Switch pane and repeat last action
tmux_pane_switch_repeat();
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_V, KC_Z){
// vim: Zoom pane
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_BSLS));
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_V, KC_R) {
// vim: Substitute and place cursor
SEND_STRING(":%s///g" SS_TAP(X_LEFT));
tap_code(KC_LEFT);
tap_code(KC_LEFT);
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_V, KC_T) {
// vim: move current pane to new tab
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_T));
leader_succeed = true;
} else
SEQ_ONE_KEY(KC_R){
// Toggle RGB Layer indicator
tap_code16(KC_RGB_T);
leader_succeed = true;
} else
SEQ_ONE_KEY(KC_SPC){
// One Shot Unicode layer
//TODO tap_code16(OS_UNI);
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_SPC, KC_SPC){
// Toggle _MODS
tap_code16(TG_MODS);
leader_succeed = true;
} else
SEQ_THREE_KEYS(KC_BSPC, KC_BSPC, KC_BSPC){
// Reset the keyboard
reset_keyboard();
leader_succeed = true;
}
leader_end();
}
// matrix_scan_keymap();
}
void leader_start_user(void) {
#ifdef RGBLIGHT_ENABLE
rgblight_savebase();
rgblight_mode_noeeprom(1);
rgblight_sethsv_noeeprom(HSV_GOLDENROD);
#endif
}
void leader_end_user(void) {
// pick color depending of success /fail
// fade leader_start from 100 to 0
// fade new color from 0 to 100 to 0
// fade old color from 0 to 100
#ifdef RGBLIGHT_ENABLE
if (leader_succeed) {
fadeflash_leds(HSV_GREEN);
} else {
fadeflash_leds(HSV_RED);
}
#endif
}

View file

@ -0,0 +1,113 @@
#include "leader_user.h"
#ifdef RGBLIGHT_ENABLE
extern rgblight_config_t rgblight_config;
#endif
bool leader_succeed;
void matrix_scan_user(void) {
static bool has_ran_yet;
if (!has_ran_yet) {
has_ran_yet = true;
startup_user();
}
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
// run_diablo_macro_check();
#endif
#ifdef RGBLIGHT_ENABLE
matrix_scan_rgb();
#endif
// matrix_scan_keymap();
}
void leader_start_user(void) {
#ifdef RGBLIGHT_ENABLE
rgblight_savebase();
rgblight_mode_noeeprom(1);
rgblight_sethsv_noeeprom(HSV_GOLDENROD);
#endif
}
void leader_end_user(void) {
leader_succeed = false;
if (leader_sequence_one_key(KC_W)) {
// vim/tmux: Use in command mode in vim: write to file, switch tmux pane in the current session window and repeat the last command
SEND_STRING(":w" SS_TAP(X_ENTER));
tmux_pane_switch_repeat();
leader_succeed = true;
} else
if (leader_sequence_one_key(KC_T)) {
// Send the Tmux Prefix
tmux_prefix();
leader_succeed = true;
} else
if (leader_sequence_one_key(KC_A)) {
// tmux: Send the prefix and press 'right' arrow
tmux_prefix();
tap_code(KC_RIGHT);
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_T, KC_T)) {
// tmux: Send the prefix to a nested session
tmux_prefix();
tmux_prefix();
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_T, KC_R)) {
// tmux: Switch pane and repeat last action
tmux_pane_switch_repeat();
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_V, KC_Z)){
// vim: Zoom pane
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_BSLS));
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_V, KC_R)) {
// vim: Substitute and place cursor
SEND_STRING(":%s///g" SS_TAP(X_LEFT));
tap_code(KC_LEFT);
tap_code(KC_LEFT);
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_V, KC_T)) {
// vim: move current pane to new tab
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_T));
leader_succeed = true;
} else
if (leader_sequence_one_key(KC_R)){
// Toggle RGB Layer indicator
tap_code16(KC_RGB_T);
leader_succeed = true;
} else
if (leader_sequence_one_key(KC_SPC)){
// One Shot Unicode layer
//TODO tap_code16(OS_UNI);
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_SPC, KC_SPC)){
// Toggle _MODS
tap_code16(TG_MODS);
leader_succeed = true;
} else
if (leader_sequence_three_keys(KC_BSPC, KC_BSPC, KC_BSPC)){
// Reset the keyboard
reset_keyboard();
leader_succeed = true;
}
// pick color depending of success /fail
// fade leader_start from 100 to 0
// fade new color from 0 to 100 to 0
// fade old color from 0 to 100
#ifdef RGBLIGHT_ENABLE
if (leader_succeed) {
fadeflash_leds(HSV_GREEN);
} else {
fadeflash_leds(HSV_RED);
}
#endif
}

View file

@ -1,6 +1,6 @@
#pragma once
#include "kuchosauronad0.h"
#include "leader.h"
#include "leader_user.h"
void matrix_scan_user(void);

View file

@ -38,7 +38,7 @@ TODO: Make use of `TD_SPC` and `TD_QT{1..3}`
## [Leader Key](#leader-key)
To enable set `LEADER_ENABLE = yes` in file *rules.mk*
|LEADER_DICTIONARY()|program| description |
|Leader sequence|program| description |
|---|---|---|
| W |vim/tmux| save file, switch pane and repeat last command |
| T |tmux| send default prefix |
@ -50,7 +50,7 @@ To enable set `LEADER_ENABLE = yes` in file *rules.mk*
|V + T|vim | move current split to its own tab|
|3x Backspace|keyboard| Reset Keyboard |
`LEADER_DICTIONARY()` is defined in *leader.c*
Leader sequences are defined in *leader_user.c*
## [Combo Keys](#combo-keys)
To enable set `COMBO_ENABLE = yes` in file *rules.mk*.

View file

@ -145,7 +145,7 @@ void rgblight_fade_helper(bool direction){
void fadeflash_leds(uint8_t hue, uint8_t sat, uint8_t val){
// indicate success / fail of a leader sequence
// fade out, set new hue and saturation, fade in, fade out, set old color, fade in
// this is used in leader.c
// this is used in leader_user.c
// TODO: come up with a better name maybe
rgblight_fade_helper(false);
rgblight_sethsv_noeeprom(hue, sat, 0);

View file

@ -21,7 +21,7 @@ ifeq ($(strip $(COMBO_ENABLE)), yes)
endif
ifeq ($(strip $(LEADER_ENABLE)), yes)
SRC += leader.c
SRC += leader_user.c
endif
ifneq ("$(wildcard $(USER_PATH)/secrets.c)","")

View file

@ -90,26 +90,19 @@ void store_userspace_config(void) {
eeconfig_update_user(stored_userspace_config.raw);
}
LEADER_EXTERNS();
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_TWO_KEYS(KC_F1, KC_L) {
set_os(_OS_LINUX);
}
SEQ_TWO_KEYS(KC_F1, KC_M) {
set_os(_OS_MACOS);
}
SEQ_TWO_KEYS(KC_F1, KC_W) {
set_os(_OS_WINDOWS);
}
SEQ_TWO_KEYS(KC_F1, KC_S) {
stored_userspace_config.raw = runtime_userspace_config.raw;
store_userspace_config();
}
void leader_end_user(void) {
if (leader_sequence_two_keys(KC_F1, KC_L)) {
set_os(_OS_LINUX);
}
if (leader_sequence_two_keys(KC_F1, KC_M)) {
set_os(_OS_MACOS);
}
if (leader_sequence_two_keys(KC_F1, KC_W)) {
set_os(_OS_WINDOWS);
}
if (leader_sequence_two_keys(KC_F1, KC_S)) {
stored_userspace_config.raw = runtime_userspace_config.raw;
store_userspace_config();
}
}

View file

@ -534,43 +534,36 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
#ifdef LEADER_ENABLE
LEADER_EXTERNS();
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
void leader_end_user(void) {
#ifdef UCIS_ENABLE
SEQ_ONE_KEY(KC_U) {
ucis_start();
if (leader_sequence_one_key(KC_U)) {
ucis_start();
}
#endif
SEQ_ONE_KEY(KC_H) {
send_unicode_string("ᕕ( ᐛ )ᕗ"); // happy
if (leader_sequence_one_key(KC_H)) {
send_unicode_string("ᕕ( ᐛ )ᕗ"); // happy
}
SEQ_ONE_KEY(KC_D) {
send_unicode_string("ಠ_ಠ"); // disapproval
if (leader_sequence_one_key(KC_D)) {
send_unicode_string("ಠ_ಠ"); // disapproval
}
SEQ_ONE_KEY(KC_L) {
send_unicode_string("( ͡° ͜ʖ ͡°)"); // lenny
if (leader_sequence_one_key(KC_L)) {
send_unicode_string("( ͡° ͜ʖ ͡°)"); // lenny
}
SEQ_ONE_KEY(KC_S) {
send_unicode_string("¯\\_(ツ)_/¯"); // shrug
if (leader_sequence_one_key(KC_S)) {
send_unicode_string("¯\\_(ツ)_/¯"); // shrug
}
// tableflip (LEADER - TF)
SEQ_TWO_KEYS(KC_T, KC_F) {
//set_unicode_input_mode(UNICODE_MODE_LINUX);
//send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
send_unicode_string("(╯°□°)╯︵ ┻━┻");
if (leader_sequence_two_keys(KC_T, KC_F)) {
//set_unicode_input_mode(UNICODE_MODE_LINUX);
//send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
send_unicode_string("(╯°□°)╯︵ ┻━┻");
}
// untableflip
SEQ_THREE_KEYS(KC_U, KC_T, KC_F) {
//set_unicode_input_mode(UNICODE_MODE_LINUX);
//send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
send_unicode_string("┬─┬ノ( º _ ºノ)");
if (leader_sequence_three_keys(KC_U, KC_T, KC_F)) {
//set_unicode_input_mode(UNICODE_MODE_LINUX);
//send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
send_unicode_string("┬─┬ノ( º _ ºノ)");
}
}
}
#endif

View file

@ -1,46 +0,0 @@
#include "leader.h"
LEADER_EXTERNS();
// Runs constantly in the background, in a loop.
void matrix_scan_user(void){
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
// run_diablo_macro_check();
#endif // TAP_DANCE_ENABLE
#ifdef RGBLIGHT_ENABLE
matrix_scan_rgb();
#endif // RGBLIGHT_ENABLE
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_TWO_KEYS(KC_V, KC_Z){
// vim: Zoom pane
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_BSLS));
}
SEQ_TWO_KEYS(KC_V, KC_R) {
// vim: Substitute and place cursor
SEND_STRING(":%s///g" SS_TAP(X_LEFT));
tap_code(KC_LEFT);
tap_code(KC_LEFT);
}
SEQ_TWO_KEYS(KC_V, KC_T) {
// vim: move current pane to new tab
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_T));
}
SEQ_THREE_KEYS(KC_BSPC, KC_BSPC, KC_BSPC){
// Reset the keyboard
reset_keyboard();
}
}
matrix_scan_keymap();
}

View file

@ -0,0 +1,41 @@
#include "leader_user.h"
void leader_end_user(void) {
if (leader_sequence_two_keys(KC_V, KC_Z)){
// vim: Zoom pane
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_BSLS));
}
if (leader_sequence_two_keys(KC_V, KC_R)) {
// vim: Substitute and place cursor
SEND_STRING(":%s///g" SS_TAP(X_LEFT));
tap_code(KC_LEFT);
tap_code(KC_LEFT);
}
if (leader_sequence_two_keys(KC_V, KC_T)) {
// vim: move current pane to new tab
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_T));
}
if (leader_sequence_three_keys(KC_BSPC, KC_BSPC, KC_BSPC)){
// Reset the keyboard
reset_keyboard();
}
}
// Runs constantly in the background, in a loop.
void matrix_scan_user(void){
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
// run_diablo_macro_check();
#endif // TAP_DANCE_ENABLE
#ifdef RGBLIGHT_ENABLE
matrix_scan_rgb();
#endif // RGBLIGHT_ENABLE
matrix_scan_keymap();
}

View file

@ -1,6 +1,6 @@
#pragma once
#include "yet-another-developer.h"
#include "leader.h"
#include "leader_user.h"
void matrix_scan_user(void);

View file

@ -14,7 +14,7 @@ endif
ifeq ($(strip $(LEADER_ENABLE)), yes)
SRC += leader.c
SRC += leader_user.c
endif