2020-02-05 01:17:10 +06:00
|
|
|
#include "ridingqwerty.h"
|
|
|
|
#include "tapdances.h"
|
|
|
|
|
2022-12-15 02:40:25 +06:00
|
|
|
void braces_finished (tap_dance_state_t *state, void *user_data) {
|
2020-02-05 01:17:10 +06:00
|
|
|
if ((state->count == 1) || (state->count == 3)) {
|
|
|
|
register_code(KC_LSFT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-15 02:40:25 +06:00
|
|
|
void braces_reset (tap_dance_state_t *state, void *user_data) {
|
2020-02-05 01:17:10 +06:00
|
|
|
// two or three taps for "[]"/"{}"
|
|
|
|
if ((state->count == 2) || (state->count == 3)) {
|
|
|
|
tap_code(KC_LBRC);
|
|
|
|
tap_code(KC_RBRC);
|
|
|
|
}
|
|
|
|
// one tap for "()"
|
|
|
|
else if (state->count == 1) {
|
|
|
|
tap_code(KC_9);
|
|
|
|
tap_code(KC_0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// unregister the shift unconditionally
|
|
|
|
unregister_code(KC_LSFT);
|
|
|
|
|
|
|
|
// move back one space, inside the braces
|
|
|
|
if (state->count <= 3) {
|
|
|
|
tap_code(KC_LEFT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-15 02:40:25 +06:00
|
|
|
tap_dance_action_t tap_dance_actions[] = {
|
2020-02-05 01:17:10 +06:00
|
|
|
[TD_BRACES] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, braces_finished, braces_reset)
|
|
|
|
};
|