Ensure we always send at least four characters when sending Unicode sequences to better support MacOS/Windows

This commit is contained in:
Josh Klar 2018-09-30 20:49:40 -07:00
parent 0ccd27703d
commit 96b5c4ee03
No known key found for this signature in database
GPG Key ID: 220F99BD7DB7A99E

View File

@ -9,10 +9,20 @@ IBUS_KEY_COMBO = Modifiers.KC_LCTRL(Modifiers.KC_LSHIFT(Common.KC_U))
def generate_codepoint_keysym_seq(codepoint):
return [
getattr(Common, 'KC_{}'.format(codepoint_fragment.upper()))
for codepoint_fragment in codepoint
]
# To make MacOS and Windows happy, always try to send
# sequences that are of length 4 at a minimum
# On Linux systems, we can happily send longer strings.
# They will almost certainly break on MacOS and Windows,
# but this is a documentation problem more than anything.
# Not sure how to send emojis on Mac/Windows like that,
# though, since (for example) the Canadian flag is assembled
# from two five-character codepoints, 1f1e8 and 1f1e6
seq = [Common.KC_0 for _ in range(max(len(codepoint), 4))]
for idx, codepoint_fragment in enumerate(reversed(codepoint)):
seq[-(idx + 1)] = getattr(Common, 'KC_{}'.format(codepoint_fragment.upper()))
return seq
def unicode_sequence(codepoints):