#include "dat.h" #include "fn.h" #include "test.h" #include /* * A sequence swallows its keys and hands its text back at the end, and * belongs to the one context, in the one frontend, that started it. */ void compose_sequences(struct ct *t) { static int a, b; /* two input contexts, told apart by address */ static const struct { int who; void *owner; u32int sym; int composing; char *text; } keys[] = { { Composexim, &a, XKB_KEY_a, 0, "" }, { Composexim, &a, XKB_KEY_dead_acute, 1, "" }, { Composexim, &a, XKB_KEY_e, 0, "é" }, { Composexim, &a, XKB_KEY_Multi_key, 1, "" }, { Composexim, &a, XKB_KEY_o, 1, "" }, { Composexim, &a, XKB_KEY_c, 0, "©" }, { Composexim, &a, XKB_KEY_dead_acute, 1, "" }, { Composexim, &a, XKB_KEY_Escape, 1, "" }, { Composexim, &a, XKB_KEY_a, 0, "" }, /* another context of the same frontend starts over */ { Composexim, &a, XKB_KEY_dead_acute, 1, "" }, { Composexim, &b, XKB_KEY_e, 0, "" }, /* another frontend does not touch this one's sequence */ { Composexim, &a, XKB_KEY_dead_acute, 1, "" }, { Composewl, &a, XKB_KEY_o, 0, "" }, { Composexim, &a, XKB_KEY_e, 0, "é" }, }; char buf[Maxutf]; int i; if(!CT_CHECK(t, setenv("XCOMPOSEFILE", "data/compose", 1) == 0)) return; composeinit(); for(i = 0; i < nelem(keys); i++){ CT_EQ_INT(t, keys[i].composing, composekey(keys[i].who, keys[i].owner, keys[i].sym, buf, sizeof buf)); CT_EQ_STR(t, keys[i].text, buf); } /* a context that goes takes its half-typed sequence with it */ CT_EQ_INT(t, 1, composekey(Composewl, &a, XKB_KEY_dead_acute, buf, sizeof buf)); composedrop(Composewl, &a); CT_EQ_INT(t, 0, composekey(Composewl, &a, XKB_KEY_e, buf, sizeof buf)); CT_EQ_STR(t, "", buf); unsetenv("XCOMPOSEFILE"); }