refactor: trim popup and XIM helpers

This commit is contained in:
2026-08-12 17:33:14 +09:00
parent 8d68e00f2b
commit de536da0bb
6 changed files with 12 additions and 27 deletions

View File

@@ -8,7 +8,6 @@
uint32_t keymaplookup(const uint32_t*, int, uint16_t);
char *ximcompound(const char*, size_t, size_t*);
char *ximutf8compound(const char*, size_t, size_t*);
enum
{
@@ -35,22 +34,17 @@ checktext(const char *s)
}
static void
checkfallback(void)
checkutf8run(void)
{
static const char s[] = "😀";
static const char want[] = "\033%G😀\033%@";
char *ct, *utf8;
size_t clen, ulen;
char *ct;
size_t n;
ct = ximutf8compound(s, sizeof s - 1, &clen);
ct = ximcompound(s, sizeof s - 1, &n);
assert(ct != NULL);
assert(clen == sizeof want - 1);
assert(memcmp(ct, want, clen) == 0);
utf8 = xcb_compound_text_to_utf8(ct, clen, &ulen);
assert(utf8 != NULL);
assert(ulen == sizeof s - 1);
assert(memcmp(utf8, s, ulen) == 0);
free(utf8);
assert(n >= 6);
assert(memcmp(ct, "\033%G", 3) == 0);
assert(memcmp(ct+n-3, "\033%@", 3) == 0);
free(ct);
}
@@ -83,6 +77,6 @@ main(void)
checktext("😀");
checktext("❤️");
checktext("A😀한");
checkfallback();
checkutf8run();
return 0;
}