1
0
Fork 0

[keymap] curly quotes (#9662)

Co-authored-by: Erovia <Erovia@users.noreply.github.com>
This commit is contained in:
Callum Oakley 2020-07-10 02:31:18 +01:00 committed by GitHub
parent 823165b9b7
commit c50009d5d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 94 additions and 67 deletions

View file

@ -49,7 +49,7 @@
#define bspc KC_BSPC
#define caps KC_CAPS
#define comm KC_COMM
#define dash A(KC_MINS)
#define dash A(KC_MINS) // en-dash (); or with shift: em-dash (—)
#define scln KC_SCLN
#define slsh KC_SLSH
#define spc KC_SPC
@ -60,7 +60,6 @@
#define mins KC_MINS
#define quot KC_QUOT
#define esc KC_ESC
#define gbp A(KC_3)
#define down KC_DOWN
#define home G(KC_LEFT)
@ -75,8 +74,8 @@
#define tabr G(S(KC_RBRC))
#define fwd G(KC_RBRC)
#define back G(KC_LBRC)
#define slup S(A(KC_UP))
#define sldn S(A(KC_DOWN))
#define slup S(A(KC_UP)) // Previous unread in Slack
#define sldn S(A(KC_DOWN)) // Next unread in Slack
#define ctl1 C(KC_1)
#define ctl2 C(KC_2)
@ -137,6 +136,7 @@ enum planck_layers {
};
enum planck_keycodes {
// ASCII
ampr = SAFE_RANGE,
astr,
at,
@ -158,6 +158,11 @@ enum planck_keycodes {
rprn,
tild,
// Curly quotes
lcqt,
rcqt,
// "Smart" mods
cmd,
};
@ -171,7 +176,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[SYMB] = LAYOUT_planck_grid(
esc, n7, n5, n3, n1, n9, n8, n0, n2, n4, n6, dash,
del, at, dlr, eql, lprn, lbrc, rbrc, rprn, astr, hash, plus, gbp,
lcqt, at, dlr, eql, lprn, lbrc, rbrc, rprn, astr, hash, plus, rcqt,
____, grv, pipe, bsls, lcbr, tild, circ, rcbr, ampr, exlm, perc, ____,
____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____
),
@ -191,62 +196,31 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
};
bool send_string_if_keydown(keyrecord_t *record, const char *s) {
bool send_string_if_keydown(
keyrecord_t *record,
const char *unshifted,
const char *shifted) {
if (record->event.pressed) {
send_string(s);
if (shifted) {
uint8_t shifts = get_mods() & MOD_MASK_SHIFT;
if (shifts) {
del_mods(shifts);
SEND_STRING(shifted);
add_mods(shifts);
} else {
SEND_STRING(unshifted);
}
} else {
SEND_STRING(unshifted);
}
}
return true;
}
int cmd_keys_down = 0;
// Holding both cmd keys will instead register as cmd + ctl
bool smart_cmd(keyrecord_t *record) {
static int cmd_keys_down = 0;
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
// Override the defualt auto shifted symbols to use SEND_STRING See
// https://github.com/qmk/qmk_firmware/issues/4072
case ampr:
return send_string_if_keydown(record, "&");
case astr:
return send_string_if_keydown(record, "*");
case at:
return send_string_if_keydown(record, "@");
case bsls:
return send_string_if_keydown(record, "\\");
case circ:
return send_string_if_keydown(record, "^");
case dlr:
return send_string_if_keydown(record, "$");
case eql:
return send_string_if_keydown(record, "=");
case exlm:
return send_string_if_keydown(record, "!");
case grv:
return send_string_if_keydown(record, "`");
case hash:
return send_string_if_keydown(record, "#");
case lbrc:
return send_string_if_keydown(record, "[");
case lcbr:
return send_string_if_keydown(record, "{");
case lprn:
return send_string_if_keydown(record, "(");
case perc:
return send_string_if_keydown(record, "%");
case pipe:
return send_string_if_keydown(record, "|");
case plus:
return send_string_if_keydown(record, "+");
case rbrc:
return send_string_if_keydown(record, "]");
case rcbr:
return send_string_if_keydown(record, "}");
case rprn:
return send_string_if_keydown(record, ")");
case tild:
return send_string_if_keydown(record, "~");
// cmd + cmd -> cmd + ctl
case cmd:
if (record->event.pressed) {
if (cmd_keys_down == 0) {
register_code(KC_LCMD);
@ -263,6 +237,71 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
cmd_keys_down--;
}
return true;
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
// Override the defualt auto shifted symbols to use SEND_STRING See
// https://github.com/qmk/qmk_firmware/issues/4072
case ampr:
return send_string_if_keydown(record, "&", NULL);
case astr:
return send_string_if_keydown(record, "*", NULL);
case at:
return send_string_if_keydown(record, "@", NULL);
case bsls:
return send_string_if_keydown(record, "\\", NULL);
case circ:
return send_string_if_keydown(record, "^", NULL);
case dlr:
return send_string_if_keydown(record, "$", NULL);
case eql:
return send_string_if_keydown(record, "=", NULL);
case exlm:
return send_string_if_keydown(record, "!", NULL);
case grv:
return send_string_if_keydown(record, "`", NULL);
case hash:
return send_string_if_keydown(record, "#", NULL);
case lbrc:
return send_string_if_keydown(record, "[", NULL);
case lcbr:
return send_string_if_keydown(record, "{", NULL);
case lprn:
return send_string_if_keydown(record, "(", NULL);
case perc:
return send_string_if_keydown(record, "%", NULL);
case pipe:
return send_string_if_keydown(record, "|", NULL);
case plus:
return send_string_if_keydown(record, "+", NULL);
case rbrc:
return send_string_if_keydown(record, "]", NULL);
case rcbr:
return send_string_if_keydown(record, "}", NULL);
case rprn:
return send_string_if_keydown(record, ")", NULL);
case tild:
return send_string_if_keydown(record, "~", NULL);
// The macOS shortcuts for curly quotes are horrible, so this rebinds
// them so that shift toggles singledouble instead of leftright, and
// then both varieties of left quote can share one key, and both
// varieties of right quote share another.
case lcqt:
return send_string_if_keydown(
record,
SS_LALT("]"), // left single quote ()
SS_LALT("[")); // left double quote (“)
case rcqt:
return send_string_if_keydown(
record,
SS_LALT(SS_LSFT("]")), // right single quote ()
SS_LALT(SS_LSFT("["))); // right double quote (”)
// cmd + cmd -> cmd + ctl
case cmd:
return smart_cmd(record);
}
return true;
}

View file

@ -1,4 +1,4 @@
# callum's planck layout
# callums planck layout
This is a layout for the grid planck, built with a few ideals in mind:
@ -23,8 +23,8 @@ This is a layout for the grid planck, built with a few ideals in mind:
- Symbols should be arranged so that the most frequently used are easiest to
reach. This includes numbers, and lower numbers are more commonly used than
higher ones. (number arrangement borrowed from [dustypomeleau's minidox
layout][].
higher ones. (number arrangement borrowed from [dustypomeleaus minidox
layout][]).
[dustypomeleau's minidox layout]: https://github.com/qmk/qmk_firmware/tree/master/keyboards/minidox/keymaps/dustypomerleau
[dustypomeleaus minidox layout]: https://github.com/qmk/qmk_firmware/tree/master/keyboards/minidox/keymaps/dustypomerleau
[keymap.c]: keymap.c

View file

@ -1,19 +1,7 @@
# Build Options
# change to "no" to disable the options, or define them in the Makefile in
# the appropriate keymap folder that will get included automatically
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI controls
AUDIO_ENABLE = yes # Audio output on port C6
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
BOOTMAGIC_ENABLE = no
MOUSEKEY_ENABLE = no
CONSOLE_ENABLE = no
COMMAND_ENABLE = yes
MIDI_ENABLE = no
AUDIO_ENABLE = yes
RGBLIGHT_ENABLE = no