aboutsummaryrefslogtreecommitdiffstats
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
-rw-r--r--users/talljoe/rules.mk6
-rw-r--r--users/talljoe/talljoe.c66
-rw-r--r--users/talljoe/talljoe.h38
-rw-r--r--users/talljoe/tapdance.c34
-rw-r--r--users/xtonhasvim/readme.md10
-rw-r--r--users/xtonhasvim/rules.mk1
-rw-r--r--users/xtonhasvim/xtonhasvim.c615
-rw-r--r--users/xtonhasvim/xtonhasvim.h66
8 files changed, 813 insertions, 23 deletions
diff --git a/users/talljoe/rules.mk b/users/talljoe/rules.mk
index fa2314960..0f1f6f26a 100644
--- a/users/talljoe/rules.mk
+++ b/users/talljoe/rules.mk
@@ -1,3 +1,7 @@
-SRC += talljoe.c
+SRC += talljoe.c tapdance.c
EXTRAFLAGS+=-flto
+
+TAP_DANCE_ENABLE=yes
+CONSOLE_ENABLE=no
+COMMAND_ENABLE=no
diff --git a/users/talljoe/talljoe.c b/users/talljoe/talljoe.c
index e49a3060d..e9c69b016 100644
--- a/users/talljoe/talljoe.c
+++ b/users/talljoe/talljoe.c
@@ -3,66 +3,67 @@
#include "talljoe.h"
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- [_BASE] = LAYOUT(
- KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINS, KC_EQL , KC_BSLS, KC_ESC,
- KC_TAB , KC_Q, KC_W, KC_E, KC_R, KC_T , KC_Y, KC_U, KC_I, KC_O, KC_P , KC_LBRC, KC_RBRC, KC_BSPC,
- US_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G , KC_H, KC_J, KC_K, KC_L, KC_SCLN, US_QUOT, US_ENT ,
- KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B , KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO_ADJ ,
- KC_LCTL, KC_LGUI, KC_LALT, KC_SPC2, KC_SPC1, KC_SPC3, KC_RALT, KC_APP , KC_RCTL, KC_PTT ),
- [_WORKMAN] = LAYOUT(
+ [_BASE] = TEMPLATE_TKL(
+ KC_ESC, KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_PSCR, KC_SLCK, MO_ADJ ,
+ KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINS, KC_EQL , KC_BSLS, KC_INS , KC_HOME, KC_PGUP,
+ KC_TAB , KC_Q, KC_W, KC_E, KC_R, KC_T , KC_Y, KC_U, KC_I, KC_O, KC_P , KC_LBRC, KC_RBRC, KC_BSPC, KC_DEL , KC_END , KC_PGDN,
+ US_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G , KC_H, KC_J, KC_K, KC_L, US_SCLN, US_QUOT, US_ENT ,
+ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B , KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP ,
+ KC_LCTL, KC_LGUI, KC_LALT, KC_SPC2, KC_SPC1, KC_SPC3, KC_RALT, KC_RGUI, KC_RCTL, KC_PTT , KC_LEFT, KC_DOWN, KC_RGHT),
+ [_WORKMAN] = TEMPLATE(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
- _______, KC_Q , KC_D , KC_R , KC_W , KC_B , KC_J , KC_F , KC_U , KC_P , KC_SCLN, _______, _______, _______,
+ _______, KC_Q , KC_D , KC_R , KC_W , KC_B , KC_J , KC_F , KC_U , KC_P , US_SCLN, _______, _______, _______,
_______, KC_A , KC_S , KC_H , KC_T , KC_G , KC_Y , KC_N , KC_E , KC_O , KC_I , _______, _______,
_______, KC_Z , KC_X , KC_M , KC_C , KC_V , KC_K , KC_L , KC_COMM, KC_DOT , KC_SLSH, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
- [_NORMAN] = LAYOUT(
+ [_NORMAN] = TEMPLATE(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
- _______, KC_Q , KC_W , KC_D , KC_F , KC_K , KC_J , KC_U , KC_R , KC_L , KC_SCLN, _______, _______, _______,
+ _______, KC_Q , KC_W , KC_D , KC_F , KC_K , KC_J , KC_U , KC_R , KC_L , US_SCLN, _______, _______, _______,
_______, KC_A , KC_S , KC_E , KC_T , KC_G , KC_Y , KC_N , KC_I , KC_O , KC_H , _______, _______,
_______, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_P , KC_M , KC_COMM, KC_DOT , KC_SLSH, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
- [_DVORAK] = LAYOUT(
+ [_DVORAK] = TEMPLATE(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC, _______, _______,
_______, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y , KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH, KC_EQL , _______,
_______, KC_A, KC_O, KC_E, KC_U, KC_I , KC_D, KC_H, KC_T, KC_N, KC_S, US_MINS, _______,
- _______, KC_SCLN, KC_Q, KC_J, KC_K, KC_X , KC_B, KC_M, KC_W, KC_V, KC_Z, _______, _______,
+ _______, US_SCLN, KC_Q, KC_J, KC_K, KC_X , KC_B, KC_M, KC_W, KC_V, KC_Z, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
- [_COLMAK] = LAYOUT(
+ [_COLMAK] = TEMPLATE(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
- _______, KC_Q, KC_W, KC_F, KC_P, KC_G , KC_J, KC_L, KC_U, KC_Y, KC_SCLN, _______, _______, _______,
+ _______, KC_Q, KC_W, KC_F, KC_P, KC_G , KC_J, KC_L, KC_U, KC_Y, US_SCLN, _______, _______, _______,
_______, KC_A, KC_R, KC_S, KC_T, KC_D , KC_H, KC_N, KC_E, KC_I, KC_O , _______, _______,
_______, KC_Z, KC_X, KC_C, KC_V, KC_B , KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
#ifdef ENABLE_GAME_LAYER
- [_GAME] = LAYOUT(
+ [_GAME] = TEMPLATE(
KC_ESC , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINS, KC_EQL , KC_BSLS, KC_GRV,
KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_LBRC, KC_RBRC, KC_BSPC,
MO_NAV , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT, KC_ENT ,
KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT, MO_ADJ ,
KC_LCTL, KC_PTT , KC_PGDN, KC_SPC , KC_SPC , KC_SPC , KC_RALT, KC_APP , KC_RCTL, KC_PTT ),
#endif
- [_NAV] = LAYOUT(
+ [_NAV] = TEMPLATE(
KC_GRV , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
KC_TAB , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_VOLU, KC_INS , KC_PGUP, KC_UP , KC_PGDN, KC_BTN1, KC_BTN2, KC_BTN3, KC_DEL ,
US_CAPS, KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_MUTE, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END , KC_RCTL, TG_ADJ ,
- KC_LSFT, KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_VOLD, KC_END , KC_PGDN, KC_WBAK, KC_WFWD, KC_WREF, KC_RSFT, XXXXXXX,
+ KC_LSFT, KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_VOLD, KC_END , KC_PGDN, KC_WBAK, KC_WFWD, KC_WREF, KC_RSFT, KC_APP ,
KC_LCTL, KC_LGUI, KC_LALT, NV_SPC2, NV_SPC1, NV_SPC3, KC_RALT, KC_RGUI, KC_RCTL, KC_PTT ),
- [_NUM] = LAYOUT(
+ [_NUM] = TEMPLATE(
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
KC_GRV , KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, XXXXXXX, KC_DEL ,
US_CAPS, KC_LCBR, KC_RCBR, KC_LPRN, KC_RPRN, KC_LBRC, KC_RBRC, KC_4, KC_5, KC_6, KC_PPLS, KC_PENT, XXXXXXX,
- KC_LSFT, KC_EQL, KC_PLUS, KC_BSLS, KC_PIPE, XXXXXXX, XXXXXXX, KC_1, KC_2, KC_3, KC_PAST, KC_PSLS, XXXXXXX,
+ KC_LSFT, KC_EQL, KC_PLUS, KC_BSLS, KC_PIPE, KC_SCLN, XXXXXXX, KC_1, KC_2, KC_3, KC_PAST, KC_PSLS, XXXXXXX,
KC_LCTL, KC_LGUI, KC_LALT, NM_SPC2, NM_SPC1, NM_SPC3, KC_PDOT, KC_PCMM, KC_RCTL, KC_PTT ),
// Adjust layer is on the split-shift key; or NAV+Enter (for non-split keyboards)
- [_ADJUST] = LAYOUT(
+ [_ADJUST] = TEMPLATE(
MO_RST , FX(1) , FX(2) , FX(3) , FX(4) , FX(5) , FX(6) , FX(7) , FX(8) , FX(9) , FX(10) , BR_DEC , BR_INC , XXXXXXX, MO_RST ,
XXXXXXX, H1_INC , S1_INC , H2_INC , S2_INC , EF_INC , RGB_HUI, RGB_SAI, RGB_MOD, RGB_M_P, DFAULTS, RGB_VAD, RGB_VAI, KC_DEL ,
XXXXXXX, H1_DEC , S1_DEC , H2_DEC , S2_DEC , EF_DEC , RGB_HUD, RGB_SAD, RGB_RMOD,RGB_M_K, RGB_M_B, RGB_M_G, TG_ADJ ,
TG_NKRO, LY_QWER, LY_WORK, LY_NRMN, LY_DVRK, LY_CLMK, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MAKE, KC_CAPS, XXXXXXX,
- MO_RST , AG_NORM, AG_SWAP, XXXXXXX, BL_TOGG, XXXXXXX, RGB_TOG, XXXXXXX, XXXXXXX, TG_GAME),
+ MO_RST , AG_NORM, AG_SWAP, XXXXXXX, BL_STEP, XXXXXXX, RGB_TOG, XXXXXXX, XXXXXXX, TG_GAME),
// To Reset hit FN + ` + Esc
- [_RESET] = LAYOUT(
+ [_RESET] = TEMPLATE(
RESET , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RESET ,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
@@ -98,6 +99,27 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+
+#ifdef RGBLIGHT_ENABLE
+ static uint32_t savedRgbMode;
+ static uint16_t savedHue;
+ static uint8_t savedSat;
+ static uint8_t savedVal;
+
+ if (keycode == KC_ESC) {
+ if (record->event.pressed) {
+ savedRgbMode = rgblight_get_mode();
+ savedHue = rgblight_get_hue();
+ savedSat = rgblight_get_sat();
+ savedVal = rgblight_get_val();
+ rgblight_mode(1);
+ rgblight_setrgb(255, 0, 0);
+ } else {
+ rgblight_mode(savedRgbMode);
+ rgblight_sethsv(savedHue, savedSat, savedVal);
+ }
+ }
+#endif
// If console is enabled, it will print the matrix position and status of each key pressed
#ifdef CONSOLE_ENABLE
xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.row, record->event.key.col, record->event.pressed);
diff --git a/users/talljoe/talljoe.h b/users/talljoe/talljoe.h
index 17e54af69..7c34cd41f 100644
--- a/users/talljoe/talljoe.h
+++ b/users/talljoe/talljoe.h
@@ -28,6 +28,10 @@ enum layers {
_RESET = RESET_LAYER,
};
+enum tap_dancers {
+ TD_SEMICOLON
+};
+
#define _______ KC_TRNS
#define XXXXXXX KC_NO
@@ -53,6 +57,7 @@ enum layers {
#define US_CAPS CTL_T(KC_ESC)
#define US_QUOT RCTL_T(KC_QUOT)
#define US_MINS RCTL_T(KC_QUOT)
+#define US_SCLN TD(TD_SEMICOLON)
#define US_ENT LT(_NUM, KC_ENT)
#ifndef SPACE_COUNT
@@ -105,4 +110,37 @@ enum layers {
#define FN_MO2 KC_NO
#endif
+#ifdef TEMPLATE_TKL
+ #define _X_ KC_NO
+ #define TEMPLATE( \
+ KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, KJ6, \
+ KJ2, KJ5, KI5, KH5, KG5, KG2, KF2, KF5, KE5, KD5, KR5, KR2, KE2, KB3, \
+ KI2, KJ3, KI3, KH3, KG3, KG6, KF6, KF3, KE3, KD3, KR3, KR6, KB1, \
+ KN2, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3, KA5, \
+ KA4, KP2, KC6, KX1, KK6, KX2, KC0, KM3, KD0, KA1 \
+ ) TEMPLATE_TKL ( \
+ KJ6, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, KA5, \
+ KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, _X_, _X_, _X_, \
+ KJ2, KJ5, KI5, KH5, KG5, KG2, KF2, KF5, KE5, KD5, KR5, KR2, KE2, KB3, _X_, _X_, _X_, \
+ KI2, KJ3, KI3, KH3, KG3, KG6, KF6, KF3, KE3, KD3, KR3, KR6, KB1, \
+ KN2, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3, _X_, \
+ KA4, KP2, KC6, KX1, KK6, KX2, KC0, KM3, KD0, KA1, _X_, _X_, _X_ \
+ )
+#else
+ #define TEMPLATE_TKL( \
+ KJ6, KI4, KH4, KH2, KH6, KA7, KE6, KD2, KD4, KB4, KB7, KB6, KB0, KC7, KC5, KA5, \
+ KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, KL4, KO4, KQ4, \
+ KJ2, KJ5, KI5, KH5, KG5, KG2, KF2, KF5, KE5, KD5, KR5, KR2, KE2, KB3, KK4, KO7, KQ7, \
+ KI2, KJ3, KI3, KH3, KG3, KG6, KF6, KF3, KE3, KD3, KR3, KR6, KB1, \
+ KN2, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3, KO6, \
+ KA4, KP2, KC6, KX1, KK6, KX2, KC0, KM3, KD0, KA1, KO0, KK0, KL0 \
+ ) TEMPLATE( \
+ KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, KJ6, \
+ KJ2, KJ5, KI5, KH5, KG5, KG2, KF2, KF5, KE5, KD5, KR5, KR2, KE2, KB3, \
+ KI2, KJ3, KI3, KH3, KG3, KG6, KF6, KF3, KE3, KD3, KR3, KR6, KB1, \
+ KN2, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3, KA5, \
+ KA4, KP2, KC6, KX1, KK6, KX2, KC0, KM3, KD0, KA1 \
+ )
+#endif
+
#endif
diff --git a/users/talljoe/tapdance.c b/users/talljoe/tapdance.c
new file mode 100644
index 000000000..3198fc67f
--- /dev/null
+++ b/users/talljoe/tapdance.c
@@ -0,0 +1,34 @@
+//Tap Dance
+#include "talljoe.h"
+
+// Send semin-colon + enter on two taps
+void tap_dance_semicolon(qk_tap_dance_state_t *state, void *user_data) {
+ switch(state->count) {
+ case 1:
+ register_code(KC_SCLN);
+ unregister_code(KC_SCLN);
+ break;
+ case 2:
+ register_code(KC_SCLN);
+ unregister_code(KC_SCLN);
+
+ uint8_t mods = get_mods();
+ if (mods) {
+ clear_mods();
+ }
+
+ register_code(KC_ENT);
+ unregister_code(KC_ENT);
+
+ if (mods) {
+ set_mods(mods);
+ }
+
+ reset_tap_dance(state);
+ break;
+ }
+}
+
+qk_tap_dance_action_t tap_dance_actions[] = {
+ [TD_SEMICOLON] = ACTION_TAP_DANCE_FN(tap_dance_semicolon),
+};
diff --git a/users/xtonhasvim/readme.md b/users/xtonhasvim/readme.md
new file mode 100644
index 000000000..e08e972f4
--- /dev/null
+++ b/users/xtonhasvim/readme.md
@@ -0,0 +1,10 @@
+
+# Xton has Vim!
+
+Contains common code for Xton's vim emulation (vimulation?) layer.
+
+Inspired/stolen from the `ergodox_ez/vim` keymap. Rewritten to be a more straightforward state machine and support more macros. Vim layers `_CMD` and `_EDIT` are designed to lay on top of an otherwise fully-functional layout. `_CMD` runs the entire vim state machine while `_EDIT` should lay across your base layer and mask off just the escape key.
+
+Works via OSX text editing shortcuts, mainly MOD+arrow combinations. This has some limitations and only works on OSX.
+
+The `_CMD` layer will temporarily disable itself while *CMD* or *ALT* are held down so that typical OSX shortcuts can be used without switching out of vim mode.
diff --git a/users/xtonhasvim/rules.mk b/users/xtonhasvim/rules.mk
new file mode 100644
index 000000000..3777917f8
--- /dev/null
+++ b/users/xtonhasvim/rules.mk
@@ -0,0 +1 @@
+SRC += xtonhasvim.c
diff --git a/users/xtonhasvim/xtonhasvim.c b/users/xtonhasvim/xtonhasvim.c
new file mode 100644
index 000000000..a2ff2fa31
--- /dev/null
+++ b/users/xtonhasvim/xtonhasvim.c
@@ -0,0 +1,615 @@
+ /* Copyright 2015-2017 Christon DeWan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "xtonhasvim.h"
+
+/************************************
+ * helper foo
+ ************************************/
+
+#define PRESS(kc) register_code(kc)
+#define RELEASE(kc) unregister_code(kc)
+
+static void TAP(uint16_t keycode) {
+ PRESS(keycode);
+ RELEASE(keycode);
+}
+
+static void CMD(uint16_t keycode) {
+ PRESS(KC_LGUI);
+ TAP(keycode);
+ RELEASE(KC_LGUI);
+}
+
+static void CTRL(uint16_t keycode) {
+ PRESS(KC_LCTRL);
+ TAP(keycode);
+ RELEASE(KC_LCTRL);
+}
+
+static void SHIFT(uint16_t keycode) {
+ PRESS(KC_LSHIFT);
+ TAP(keycode);
+ RELEASE(KC_LSHIFT);
+}
+
+static void ALT(uint16_t keycode) {
+ PRESS(KC_LALT);
+ TAP(keycode);
+ RELEASE(KC_LALT);
+}
+
+
+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;
+
+static void edit(void) { vstate = VIM_START; layer_on(_EDIT); layer_off(_CMD); }
+#define EDIT edit()
+
+
+static void simple_movement(uint16_t keycode) {
+ switch(keycode) {
+ case VIM_B:
+ PRESS(KC_LALT);
+ SHIFT(KC_LEFT); // select to start of this word
+ RELEASE(KC_LALT);
+ break;
+ case VIM_E:
+ PRESS(KC_LALT);
+ SHIFT(KC_RIGHT); // select to end of this word
+ RELEASE(KC_LALT);
+ break;
+ case VIM_H:
+ SHIFT(KC_LEFT);
+ break;
+ case VIM_J:
+ CMD(KC_LEFT);
+ SHIFT(KC_DOWN);
+ SHIFT(KC_DOWN);
+ break;
+ case VIM_K:
+ CMD(KC_LEFT);
+ TAP(KC_DOWN);
+ SHIFT(KC_UP);
+ SHIFT(KC_UP);
+ break;
+ case VIM_L:
+ SHIFT(KC_RIGHT);
+ break;
+ case VIM_W:
+ PRESS(KC_LALT);
+ SHIFT(KC_RIGHT); // select to end of this word
+ SHIFT(KC_RIGHT); // select to end of next word
+ SHIFT(KC_LEFT); // select to start of next word
+ RELEASE(KC_LALT);
+ break;
+ }
+}
+
+__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 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 PASS_THRU;
+ }
+
+ if (VIM_START <= keycode && keycode <= VIM_ESC) {
+ if(keycode == VIM_SHIFT) {
+ SHIFTED = record->event.pressed;
+ return false;
+ }
+
+ if (record->event.pressed) {
+ if(keycode == VIM_START) {
+ // 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) {
+ case VIM_START:
+ switch(keycode){
+ /*****************************
+ * ground state
+ *****************************/
+ case VIM_A:
+ if(SHIFTED) {
+ // CMD(KC_RIGHT);
+ CTRL(KC_E);
+ } else {
+ TAP(KC_RIGHT);
+ }
+ EDIT;
+ break;
+ case VIM_B:
+ PRESS(KC_LALT);
+ PRESS(KC_LEFT);
+ break;
+ case VIM_C:
+ if(SHIFTED) {
+ PRESS(KC_LSHIFT);
+ CMD(KC_RIGHT);
+ RELEASE(KC_LSHIFT);
+ CMD(KC_X);
+ yank_was_lines = false;
+ EDIT;
+ } else {
+ vstate = VIM_C;
+ }
+ break;
+ case VIM_D:
+ if(SHIFTED) {
+ TAP(KC_K);
+ } else {
+ vstate = VIM_D;
+ }
+ break;
+ case VIM_E:
+ PRESS(KC_LALT);
+ PRESS(KC_RIGHT);
+ break;
+ case VIM_G:
+ if(SHIFTED) {
+ TAP(KC_END);
+ } else {
+ vstate = VIM_G;
+ }
+ break;
+ case VIM_H:
+ PRESS(KC_LEFT);
+ break;
+ case VIM_I:
+ if(SHIFTED){
+ CTRL(KC_A);
+ }
+ EDIT;
+ break;
+ case VIM_J:
+ if(SHIFTED) {
+ CMD(KC_RIGHT);
+ TAP(KC_DEL);
+ } else {
+ PRESS(KC_DOWN);
+ }
+ break;
+ case VIM_K:
+ PRESS(KC_UP);
+ break;
+ case VIM_L:
+ PRESS(KC_RIGHT);
+ break;
+ case VIM_O:
+ if(SHIFTED) {
+ CMD(KC_LEFT);
+ TAP(KC_ENTER);
+ TAP(KC_UP);
+ EDIT;
+ } else {
+ CMD(KC_RIGHT);
+ TAP(KC_ENTER);
+ EDIT;
+ }
+ break;
+ case VIM_P:
+ if(SHIFTED) {
+ CMD(KC_LEFT);
+ CMD(KC_V);
+ } else {
+ if(yank_was_lines) {
+ CMD(KC_RIGHT);
+ TAP(KC_RIGHT);
+ CMD(KC_V);
+ } else {
+ CMD(KC_V);
+ }
+ }
+ break;
+ case VIM_S:
+ // s for substitute?
+ if(SHIFTED) {
+ CMD(KC_LEFT);
+ PRESS(KC_LSHIFT);
+ CMD(KC_RIGHT);
+ RELEASE(KC_LSHIFT);
+ CMD(KC_X);
+ yank_was_lines = false;
+ EDIT;
+ } else {
+ SHIFT(KC_RIGHT);
+ CMD(KC_X);
+ yank_was_lines = false;
+ EDIT;
+ }
+ break;
+ case VIM_U:
+ if(SHIFTED) {
+ PRESS(KC_LSFT);
+ CMD(KC_Z);
+ RELEASE(KC_LSHIFT);
+ } else {
+ CMD(KC_Z);
+ }
+ break;
+ case VIM_V:
+ if(SHIFTED) {
+ CMD(KC_LEFT);
+ SHIFT(KC_DOWN);
+ vstate = VIM_VS;
+ } else {
+ vstate = VIM_V;
+ }
+ break;
+ case VIM_W:
+ PRESS(KC_LALT);
+ TAP(KC_RIGHT);
+ TAP(KC_RIGHT);
+ TAP(KC_LEFT);
+ RELEASE(KC_LALT);
+ break;
+ case VIM_X:
+ // SHIFT(KC_RIGHT);
+ // CMD(KC_X);
+ PRESS(KC_DEL);
+ break;
+ case VIM_Y:
+ if(SHIFTED) {
+ CMD(KC_LEFT);
+ SHIFT(KC_DOWN);
+ CMD(KC_C);
+ TAP(KC_RIGHT);
+ yank_was_lines = true;
+ } else {
+ vstate = VIM_Y;
+ }
+ break;
+ case VIM_COMMA:
+ if(SHIFTED) {
+ // indent
+ CMD(KC_LBRACKET);
+ } else {
+ // toggle comment
+ CMD(KC_SLASH);
+ }
+ break;
+ case VIM_PERIOD:
+ if(SHIFTED) {
+ // outdent
+ CMD(KC_RBRACKET);
+ }
+ break;
+ }
+ break;
+ case VIM_C:
+ /*****************************
+ * c- ...for change. I never use this...
+ *****************************/
+ switch(keycode) {
+ case VIM_B:
+ case VIM_E:
+ case VIM_H:
+ case VIM_J:
+ case VIM_K:
+ case VIM_L:
+ case VIM_W:
+ simple_movement(keycode);
+ CMD(KC_X);
+ yank_was_lines = false;
+ EDIT;
+ break;
+
+ case VIM_C:
+ CMD(KC_LEFT);
+ PRESS(KC_LSHIFT);
+ CMD(KC_RIGHT);
+ RELEASE(KC_LSHIFT);
+ CMD(KC_X);
+ yank_was_lines = false;
+ EDIT;
+ break;
+ case VIM_I:
+ vstate = VIM_CI;
+ break;
+ default:
+ vstate = VIM_START;
+ break;
+ }
+ break;
+ case VIM_CI:
+ /*****************************
+ * ci- ...change inner word
+ *****************************/
+ switch(keycode) {
+ case VIM_W:
+ ALT(KC_LEFT);
+ PRESS(KC_LSHIFT);
+ ALT(KC_RIGHT);
+ RELEASE(KC_LSHIFT);
+ CMD(KC_X);
+ yank_was_lines = false;
+ EDIT;
+ default:
+ vstate = VIM_START;
+ break;
+ }
+ break;
+ case VIM_D:
+ /*****************************
+ * d- ...delete stuff
+ *****************************/
+ switch(keycode) {
+ case VIM_B:
+ case VIM_E:
+ case VIM_H:
+ case VIM_J:
+ case VIM_K:
+ case VIM_L:
+ case VIM_W:
+ simple_movement(keycode);
+ CMD(KC_X);
+ yank_was_lines = false;
+ vstate = VIM_START;
+ break;
+ case VIM_D:
+ CMD(KC_LEFT);
+ SHIFT(KC_DOWN);
+ CMD(KC_X);
+ yank_was_lines = true;
+ vstate = VIM_START;
+ break;
+ case VIM_I:
+ vstate = VIM_DI;
+ break;
+ default:
+ vstate = VIM_START;
+ break;
+ }
+ break;
+ case VIM_DI:
+ /*****************************
+ * ci- ...delete a word... FROM THE INSIDE!
+ *****************************/
+ switch(keycode) {
+ case VIM_W:
+ ALT(KC_LEFT);
+ PRESS(KC_LSHIFT);
+ ALT(KC_RIGHT);
+ RELEASE(KC_LSHIFT);
+ CMD(KC_X);
+ yank_was_lines = false;
+ vstate = VIM_START;
+ default:
+ vstate = VIM_START;
+ break;
+ }
+ break;
+ case VIM_V:
+ /*****************************
+ * visual!
+ *****************************/
+ switch(keycode) {
+ case VIM_D:
+ case VIM_X:
+ CMD(KC_X);
+ yank_was_lines = false;
+ vstate = VIM_START;
+ break;
+ case VIM_B:
+ PRESS(KC_LALT);
+ PRESS(KC_LSHIFT);
+ PRESS(KC_LEFT);
+ // leave open for key repeat
+ break;
+ case VIM_E:
+ PRESS(KC_LALT);
+ PRESS(KC_LSHIFT);
+ PRESS(KC_RIGHT);
+ // leave open for key repeat
+ break;
+ case VIM_H:
+ PRESS(KC_LSHIFT);
+ PRESS(KC_LEFT);
+ break;
+ case VIM_I:
+ vstate = VIM_VI;
+ break;
+ case VIM_J:
+ PRESS(KC_LSHIFT);
+ PRESS(KC_DOWN);
+ break;
+ case VIM_K:
+ PRESS(KC_LSHIFT);
+ PRESS(KC_UP);
+ break;
+ case VIM_L:
+ PRESS(KC_LSHIFT);
+ PRESS(KC_RIGHT);
+ break;
+ case VIM_W:
+ PRESS(KC_LALT);
+ SHIFT(KC_RIGHT); // select to end of this word
+ SHIFT(KC_RIGHT); // select to end of next word
+ SHIFT(KC_LEFT); // select to start of next word
+ RELEASE(KC_LALT);
+ break;
+ case VIM_P:
+ CMD(KC_V);
+ vstate = VIM_START;
+ break;
+ case VIM_Y:
+ CMD(KC_C);
+ TAP(KC_RIGHT);
+ yank_was_lines = false;
+ vstate = VIM_START;
+ break;
+ case VIM_V:
+ case VIM_ESC:
+ TAP(KC_RIGHT);
+ vstate = VIM_START;
+ break;
+ default:
+ // do nothing
+ break;
+ }
+ break;
+ case VIM_VI:
+ /*****************************
+ * vi- ...select a word... FROM THE INSIDE!
+ *****************************/
+ switch(keycode) {
+ case VIM_W:
+ ALT(KC_LEFT);
+ PRESS(KC_LSHIFT);
+ ALT(KC_RIGHT);
+ RELEASE(KC_LSHIFT);
+ vstate = VIM_V;
+ default:
+ // ignore
+ vstate = VIM_V;
+ break;
+ }
+ break;
+ case VIM_VS:
+ /*****************************
+ * visual line
+ *****************************/
+ switch(keycode) {
+ case VIM_D:
+ case VIM_X:
+ CMD(KC_X);
+ yank_was_lines = true;
+ vstate = VIM_START;
+ break;
+ case VIM_J:
+ PRESS(KC_LSHIFT);
+ PRESS(KC_DOWN);
+ break;
+ case VIM_K:
+ PRESS(KC_LSHIFT);
+ PRESS(KC_UP);
+ break;
+ case VIM_Y:
+ CMD(KC_C);
+ yank_was_lines = true;
+ TAP(KC_RIGHT);
+ vstate = VIM_START;
+ break;
+ case VIM_P:
+ CMD(KC_V);
+ vstate = VIM_START;
+ break;
+ case VIM_V:
+ case VIM_ESC:
+ TAP(KC_RIGHT);
+ vstate = VIM_START;
+ break;
+ default:
+ // do nothing
+ break;
+ }
+ break;
+ case VIM_G:
+ /*****************************
+ * gg, and a grab-bag of other macros i find useful
+ *****************************/
+ switch(keycode) {
+ case VIM_G:
+ TAP(KC_HOME);
+ break;
+ // codes b
+ case VIM_H:
+ CTRL(KC_A);
+ break;
+ case VIM_J:
+ PRESS(KC_PGDN);
+ break;
+ case VIM_K:
+ PRESS(KC_PGUP);
+ break;
+ case VIM_L:
+ CTRL(KC_E);
+ break;
+ default:
+ // do nothing
+ break;
+ }
+ vstate = VIM_START;
+ break;
+ case VIM_Y:
+ /*****************************
+ * yoink!
+ *****************************/
+ switch(keycode) {
+ case VIM_B:
+ case VIM_E:
+ case VIM_H:
+ case VIM_J:
+ case VIM_K:
+ case VIM_L:
+ case VIM_W:
+ simple_movement(keycode);
+ CMD(KC_C);
+ TAP(KC_RIGHT);
+ yank_was_lines = false;
+ break;
+ case VIM_Y:
+ CMD(KC_LEFT);
+ SHIFT(KC_DOWN);
+ CMD(KC_C);
+ TAP(KC_RIGHT);
+ yank_was_lines = true;
+ break;
+ default:
+ // NOTHING
+ break;
+ }
+ vstate = VIM_START;
+ break;
+ }
+ } else {
+ /************************
+ * key release events
+ ************************/
+ clear_keyboard();
+ }
+ return false;
+ } else {
+ return PASS_THRU;
+ }
+}
diff --git a/users/xtonhasvim/xtonhasvim.h b/users/xtonhasvim/xtonhasvim.h
new file mode 100644
index 000000000..21b794c03
--- /dev/null
+++ b/users/xtonhasvim/xtonhasvim.h
@@ -0,0 +1,66 @@
+ /* Copyright 2015-2017 Christon DeWan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef USERSPACE
+#define USERSPACE
+
+#include QMK_KEYBOARD_H
+#include "action_layer.h"
+
+#define X_____X KC_NO
+
+bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record);
+
+enum xtonhasvim_keycodes {
+ DUMMY = SAFE_RANGE,
+ VIM_START, // bookend for vim states
+ VIM_A,
+ VIM_B,
+ VIM_C,
+ VIM_CI,
+ VIM_D,
+ VIM_DI,
+ VIM_E,
+ VIM_H,
+ VIM_G,
+ VIM_I,
+ VIM_J,
+ VIM_K,
+ VIM_L,
+ VIM_O,
+ VIM_P,
+ VIM_S,
+ VIM_U,
+ VIM_V,
+ VIM_VS, // visual-line
+ VIM_VI,
+ VIM_W,
+ VIM_X,
+ VIM_Y,
+ VIM_PERIOD, // to support indent/outdent
+ VIM_COMMA, // and toggle comments
+ VIM_SHIFT, // avoid side-effect of supporting real shift.
+ VIM_ESC, // bookend
+ VIM_SAFE_RANGE // start other keycodes here.
+};
+
+enum xtonhasvim_layers {
+ _EDIT = 12,
+ _CMD
+};
+
+
+#endif