Make ASCII NUL imply Ctrl-Space instead of C-@
Seems mostly arbitrary.
This commit is contained in:
parent
9b7c801c37
commit
9ec09b90c9
10
termo.c
10
termo.c
|
@ -778,7 +778,15 @@ parse_multibyte (termo_t *tk, const unsigned char *bytes, size_t len,
|
||||||
static void
|
static void
|
||||||
emit_codepoint (termo_t *tk, uint32_t codepoint, termo_key_t *key)
|
emit_codepoint (termo_t *tk, uint32_t codepoint, termo_key_t *key)
|
||||||
{
|
{
|
||||||
if (codepoint < 0x20)
|
if (codepoint == 0)
|
||||||
|
{
|
||||||
|
// ASCII NUL = Ctrl-Space as well as Ctrl-@ but let's prefer
|
||||||
|
// the former to follow the behaviour of libtermkey
|
||||||
|
key->type = TERMO_TYPE_KEYSYM;
|
||||||
|
key->code.sym = TERMO_SYM_SPACE;
|
||||||
|
key->modifiers = TERMO_KEYMOD_CTRL;
|
||||||
|
}
|
||||||
|
else if (codepoint < 0x20)
|
||||||
{
|
{
|
||||||
// C0 range
|
// C0 range
|
||||||
key->code.codepoint = 0;
|
key->code.codepoint = 0;
|
||||||
|
|
|
@ -7,7 +7,7 @@ main (int argc, char *argv[])
|
||||||
termo_t *tk;
|
termo_t *tk;
|
||||||
termo_key_t key;
|
termo_key_t key;
|
||||||
|
|
||||||
plan_tests (38);
|
plan_tests (42);
|
||||||
|
|
||||||
tk = termo_new_abstract ("vt100", NULL, 0);
|
tk = termo_new_abstract ("vt100", NULL, 0);
|
||||||
|
|
||||||
|
@ -86,6 +86,15 @@ main (int argc, char *argv[])
|
||||||
is_int (key.modifiers, TERMO_KEYMOD_CTRL,
|
is_int (key.modifiers, TERMO_KEYMOD_CTRL,
|
||||||
"key.modifiers after Ctrl-Escape");
|
"key.modifiers after Ctrl-Escape");
|
||||||
|
|
||||||
|
termo_push_bytes (tk, "\0", 1);
|
||||||
|
|
||||||
|
is_int (termo_getkey (tk, &key), TERMO_RES_KEY,
|
||||||
|
"getkey yields RES_KEY after Ctrl-Space");
|
||||||
|
|
||||||
|
is_int (key.type, TERMO_TYPE_KEY, "key.type after Ctrl-Space");
|
||||||
|
is_int (key.code.codepoint, ' ', "key.code.codepoint after Ctrl-Space");
|
||||||
|
is_int (key.modifiers, TERMO_KEYMOD_CTRL, "key.modifiers after Ctrl-Space");
|
||||||
|
|
||||||
// Escape key in various amounts
|
// Escape key in various amounts
|
||||||
|
|
||||||
termo_push_bytes (tk, "\x1b\x1b", 2);
|
termo_push_bytes (tk, "\x1b\x1b", 2);
|
||||||
|
|
Loading…
Reference in New Issue