mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-18 05:32:05 +00:00
implement UNICODE_MODE_VIM
This commit is contained in:
parent
820202cd53
commit
6e1756541b
0
data/constants/keycodes/keycodes_0.0.8.hjson
Normal file
0
data/constants/keycodes/keycodes_0.0.8.hjson
Normal file
11
data/constants/keycodes/keycodes_0.0.8_quantum.hjson
Normal file
11
data/constants/keycodes/keycodes_0.0.8_quantum.hjson
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"keycodes": {
|
||||
"0x7C38": {
|
||||
"group": "quantum",
|
||||
"key": "QK_UNICODE_MODE_VIM",
|
||||
"aliases": [
|
||||
"UC_VIM"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -42,6 +42,8 @@ Add the following to your `config.h`:
|
||||
|`UNICODE_SONG_BSD` |*n/a* |The song to play when the BSD input mode is selected |
|
||||
|`UNICODE_SONG_WIN` |*n/a* |The song to play when the Windows input mode is selected |
|
||||
|`UNICODE_SONG_WINC`|*n/a* |The song to play when the WinCompose input mode is selected|
|
||||
|`UNICODE_SONG_EMACS`|*n/a* |The song to play when the Emacs input mode is selected |
|
||||
|`UNICODE_SONG_VIM` |*n/a* |The song to play when the Vim input mode is selected |
|
||||
|
||||
## Input Subsystems {#input-subsystems}
|
||||
|
||||
@ -201,6 +203,12 @@ Emacs supports code point input with the `insert-char` command.
|
||||
|
||||
Not currently implemented. If you're a BSD user and want to contribute support for this input mode, please [feel free](../contributing)!
|
||||
|
||||
==== VIM
|
||||
|
||||
**Mode Name:** `UNICODE_MODE_VIM`
|
||||
|
||||
Vim supports input of unicode characters up to `U+FFFF`. To insert a unicode character, press `ctrl+v u` in insert mode. For more informaton, see `:h utf-8-typing`.
|
||||
|
||||
:::::
|
||||
|
||||
## Keycodes {#keycodes}
|
||||
@ -217,7 +225,8 @@ Not currently implemented. If you're a BSD user and want to contribute support f
|
||||
|`QK_UNICODE_MODE_WINDOWS` |`UC_WIN` |Switch to Windows input |
|
||||
|`QK_UNICODE_MODE_BSD` |`UC_BSD` |Switch to BSD input (not implemented) |
|
||||
|`QK_UNICODE_MODE_WINCOMPOSE`|`UC_WINC`|Switch to Windows input using WinCompose |
|
||||
|`QK_UNICODE_MODE_EMACS` |`UC_EMAC`|Switch to emacs (`C-x-8 RET`) |
|
||||
|`QK_UNICODE_MODE_EMACS` |`UC_EMAC`|Switch to emacs input (`C-x-8 RET`) |
|
||||
|`QK_UNICODE_MODE_VIM` |`UC_VIM`|Switch to vim input (`CTRL-V u`) |
|
||||
|
||||
## API {#api}
|
||||
|
||||
@ -285,6 +294,7 @@ Begin the Unicode input sequence. The exact behavior depends on the currently se
|
||||
- **WinCompose**: Tap `UNICODE_KEY_WINC`, then U
|
||||
- **HexNumpad**: Hold Left Alt, then tap Numpad +
|
||||
- **Emacs**: Tap Ctrl+X, then 8, then Enter
|
||||
- **Vim**: Tap Ctrl+V, then u
|
||||
|
||||
This function is weakly defined, and can be overridden in user code.
|
||||
|
||||
@ -299,6 +309,7 @@ Complete the Unicode input sequence. The exact behavior depends on the currently
|
||||
- **WinCompose**: Tap Enter
|
||||
- **HexNumpad**: Release Left Alt
|
||||
- **Emacs**: Tap Enter
|
||||
- **Vim**: Do nothing
|
||||
|
||||
This function is weakly defined, and can be overridden in user code.
|
||||
|
||||
@ -313,6 +324,7 @@ Cancel the Unicode input sequence. The exact behavior depends on the currently s
|
||||
- **WinCompose**: Tap Escape
|
||||
- **HexNumpad**: Release Left Alt
|
||||
- **Emacs**: Tap Ctrl+G
|
||||
- **Vim**: Do nothing
|
||||
|
||||
This function is weakly defined, and can be overridden in user code.
|
||||
|
||||
|
@ -902,4 +902,5 @@ See also: [Unicode Support](features/unicode)
|
||||
|`QK_UNICODE_MODE_WINDOWS` |`UC_WIN` |Switch to Windows input |
|
||||
|`QK_UNICODE_MODE_BSD` |`UC_BSD` |Switch to BSD input (not implemented) |
|
||||
|`QK_UNICODE_MODE_WINCOMPOSE`|`UC_WINC`|Switch to Windows input using WinCompose |
|
||||
|`QK_UNICODE_MODE_EMACS` |`UC_EMAC`|Switch to emacs (`C-x-8 RET`) |
|
||||
|`QK_UNICODE_MODE_EMACS` |`UC_EMAC`|Switch to Emacs input (`C-x-8 RET`) |
|
||||
|`QK_UNICODE_MODE_VIM` |`UC_VIM` |Switch to Vim input (`i_CTRL-V u`) |
|
||||
|
@ -120,6 +120,9 @@ void user_oled_magic(void) {
|
||||
case UNICODE_MODE_EMACS:
|
||||
oled_write_P(PSTR("emacs"), false);
|
||||
break;
|
||||
case UNICODE_MODE_VIM:
|
||||
oled_write_P(PSTR("vim"), false);
|
||||
break;
|
||||
default:
|
||||
oled_write_ln_P(PSTR("not supported"), false);
|
||||
}
|
||||
|
@ -64,6 +64,9 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) {
|
||||
case QK_UNICODE_MODE_EMACS:
|
||||
set_unicode_input_mode(UNICODE_MODE_EMACS);
|
||||
break;
|
||||
case QK_UNICODE_MODE_VIM:
|
||||
set_unicode_input_mode(UNICODE_MODE_VIM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,9 @@ static float song_winc[][2] = UNICODE_SONG_WINC;
|
||||
# ifdef UNICODE_SONG_EMACS
|
||||
static float song_emacs[][2] = UNICODE_SONG_EMACS;
|
||||
# endif
|
||||
# ifdef UNICODE_SONG_VIM
|
||||
static float song_vim[][2] = UNICODE_SONG_VIM;
|
||||
# endif
|
||||
|
||||
static void unicode_play_song(uint8_t mode) {
|
||||
switch (mode) {
|
||||
@ -129,6 +132,11 @@ static void unicode_play_song(uint8_t mode) {
|
||||
case UNICODE_MODE_EMACS:
|
||||
PLAY_SONG(song_emacs);
|
||||
break;
|
||||
# endif
|
||||
# ifdef UNICODE_SONG_VIM
|
||||
case UNICODE_MODE_VIM:
|
||||
PLAY_SONG(song_vim);
|
||||
break;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
@ -248,6 +256,10 @@ __attribute__((weak)) void unicode_input_start(void) {
|
||||
tap_code16(KC_8);
|
||||
tap_code16(KC_ENTER);
|
||||
break;
|
||||
case UNICODE_MODE_VIM:
|
||||
tap_code16(LCTL(KC_V));
|
||||
tap_code16(KC_U);
|
||||
break;
|
||||
}
|
||||
|
||||
wait_ms(UNICODE_TYPE_DELAY);
|
||||
@ -276,6 +288,9 @@ __attribute__((weak)) void unicode_input_finish(void) {
|
||||
case UNICODE_MODE_EMACS:
|
||||
tap_code16(KC_ENTER);
|
||||
break;
|
||||
case UNICODE_MODE_VIM:
|
||||
// It finishes by itself when 4 hex digits received
|
||||
break;
|
||||
}
|
||||
|
||||
set_mods(unicode_saved_mods); // Reregister previously set mods
|
||||
@ -304,6 +319,9 @@ __attribute__((weak)) void unicode_input_cancel(void) {
|
||||
case UNICODE_MODE_EMACS:
|
||||
tap_code16(LCTL(KC_G)); // C-g cancels
|
||||
break;
|
||||
case UNICODE_MODE_VIM:
|
||||
// It looks like there is no way to cancel
|
||||
break;
|
||||
}
|
||||
|
||||
set_mods(unicode_saved_mods); // Reregister previously set mods
|
||||
|
@ -46,6 +46,7 @@ enum unicode_input_modes {
|
||||
UNICODE_MODE_BSD, // BSD (not implemented)
|
||||
UNICODE_MODE_WINCOMPOSE, // Windows using WinCompose (https://github.com/samhocevar/wincompose)
|
||||
UNICODE_MODE_EMACS, // Emacs is an operating system in search of a good text editor
|
||||
UNICODE_MODE_VIM, // Vim or Neovim
|
||||
|
||||
UNICODE_MODE_COUNT // Number of available input modes (always leave at the end)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user