Support Unicode sequences on Windows through WinCompose ONLY

This commit is contained in:
Josh Klar 2018-09-30 20:35:41 -07:00
parent 137de41743
commit 0ccd27703d
No known key found for this signature in database
GPG Key ID: 220F99BD7DB7A99E
3 changed files with 17 additions and 0 deletions

View File

@ -119,3 +119,4 @@ class UnicodeModes:
NOOP = 0
LINUX = IBUS = 1
MACOS = OSX = RALT = 2
WINC = 3

View File

@ -453,6 +453,7 @@ class KMK(KeycodeCategory):
KC_UC_MODE_MACOS = KC_UC_MODE_OSX = KC_UC_MODE_RALT = UnicodeModeKeycode.from_mode_const(
UnicodeModes.RALT,
)
KC_UC_MODE_WINC = UnicodeModeKeycode.from_mode_const(UnicodeModes.WINC)
class Layers(KeycodeCategory):

View File

@ -21,6 +21,8 @@ def unicode_sequence(codepoints):
yield from _ibus_unicode_sequence(codepoints, state)
elif state.unicode_mode == UnicodeModes.RALT:
yield from _ralt_unicode_sequence(codepoints, state)
elif state.unicode_mode == UnicodeModes.WINC:
yield from _winc_unicode_sequence(codepoints, state)
return KMKMacro(keydown=_unicode_sequence)
@ -43,3 +45,16 @@ def _ibus_unicode_sequence(codepoints, state):
seq.append(Common.KC_ENTER)
yield from simple_key_sequence(seq).keydown(state)
def _winc_unicode_sequence(codepoints, state):
'''
Send unicode sequence using WinCompose:
http://wincompose.info/
https://github.com/SamHocevar/wincompose
'''
for codepoint in codepoints:
yield keycode_down_event(Modifiers.RALT())
yield keycode_down_event(Common.KC_U())
yield from simple_key_sequence(generate_codepoint_keysym_seq(codepoint)).keydown(state)