From 7b3dc4be71e9c611bc4a6b191264f99eb642d44c Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evans Date: Fri, 30 Nov 2012 14:35:23 +0000 Subject: Return a real key type for unrecognised CSI sequences; allow accessing them by termkey_interpret_csi() --- driver-csi.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'driver-csi.c') diff --git a/driver-csi.c b/driver-csi.c index 80f7eaa..bb699bd 100644 --- a/driver-csi.c +++ b/driver-csi.c @@ -419,7 +419,7 @@ static TermKeyResult peekkey_csi(TermKey *tk, TermKeyCsi *csi, size_t introlen, if(csi_handlers[(cmd & 0xff) - 0x40]) result = (*csi_handlers[(cmd & 0xff) - 0x40])(tk, key, cmd, arg, args); - if(key->code.sym == TERMKEY_SYM_UNKNOWN) { + if(result == TERMKEY_RES_NONE) { #ifdef DEBUG switch(args) { case 1: @@ -436,7 +436,12 @@ static TermKeyResult peekkey_csi(TermKey *tk, TermKeyCsi *csi, size_t introlen, break; } #endif - return TERMKEY_RES_NONE; + key->type = TERMKEY_TYPE_UNKNOWN_CSI; + key->code.number = cmd; + + tk->hightide = csi_len - introlen; + *nbytep = introlen; // Do not yet eat the data bytes + return TERMKEY_RES_KEY; } *nbytep = csi_len; @@ -518,6 +523,19 @@ static TermKeyResult peekkey(TermKey *tk, void *info, TermKeyKey *key, int force return TERMKEY_RES_NONE; } +/* non-static */ +TermKeyResult termkey_interpret_csi(TermKey *tk, const TermKeyKey *key, long args[], size_t *nargs, unsigned long *cmd) +{ + size_t dummy; + + if(tk->hightide == 0) + return TERMKEY_RES_NONE; + if(key->type != TERMKEY_TYPE_UNKNOWN_CSI) + return TERMKEY_RES_NONE; + + return parse_csi(tk, 0, &dummy, args, nargs, cmd); +} + struct TermKeyDriver termkey_driver_csi = { .name = "CSI", -- cgit v1.2.3