fix: preserve emoji commits through XIM
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <xcb-imdkit/encoding.h>
|
||||
#include <xkbcommon/xkbcommon-keysyms.h>
|
||||
#include "../xim/keymap.h"
|
||||
#include "../xim/ximtext.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -11,6 +15,23 @@ enum
|
||||
Group1 = 1<<13,
|
||||
};
|
||||
|
||||
static void
|
||||
checktext(const char *s)
|
||||
{
|
||||
char *ct, *utf8;
|
||||
size_t clen, len, ulen;
|
||||
|
||||
len = strlen(s);
|
||||
ct = ximcompound(s, len, &clen);
|
||||
assert(ct != NULL);
|
||||
utf8 = xcb_compound_text_to_utf8(ct, clen, &ulen);
|
||||
assert(utf8 != NULL);
|
||||
assert(ulen == len);
|
||||
assert(memcmp(utf8, s, len) == 0);
|
||||
free(utf8);
|
||||
free(ct);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@@ -23,6 +44,8 @@ main(void)
|
||||
XKB_KEY_a, XKB_KEY_A, XKB_KEY_NoSymbol, XKB_KEY_NoSymbol,
|
||||
};
|
||||
|
||||
xcb_compound_text_init();
|
||||
|
||||
assert(keymaplookup(letters, 4, 0) == XKB_KEY_a);
|
||||
assert(keymaplookup(letters, 4, ShiftMask) == XKB_KEY_A);
|
||||
assert(keymaplookup(letters, 4, LockMask) == XKB_KEY_A);
|
||||
@@ -34,5 +57,9 @@ main(void)
|
||||
assert(keymaplookup(punctuation, 2, LockMask|ShiftMask) == XKB_KEY_exclam);
|
||||
assert(keymaplookup(missing, 4, Group1) == XKB_KEY_a);
|
||||
assert(keymaplookup(NULL, 0, 0) == XKB_KEY_NoSymbol);
|
||||
checktext("한글");
|
||||
checktext("😀");
|
||||
checktext("❤️");
|
||||
checktext("A😀한");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user