=== modified file 'driver-ti.c' --- driver-ti.c 2019-02-17 16:11:51 +0000 +++ driver-ti.c 2019-02-14 21:03:14 +0000 @@ -30,6 +30,7 @@ typedef enum { TYPE_KEY, TYPE_ARR, + TYPE_MOUSE, } trie_nodetype; struct trie_node { @@ -101,6 +102,7 @@ { switch(n->type) { case TYPE_KEY: + case TYPE_MOUSE: fprintf(stderr, "ABORT: lookup_next within a TYPE_KEY node\n"); abort(); case TYPE_ARR: @@ -119,6 +121,7 @@ { switch(n->type) { case TYPE_KEY: + case TYPE_MOUSE: break; case TYPE_ARR: { @@ -141,6 +144,7 @@ switch(n->type) { case TYPE_KEY: + case TYPE_MOUSE: return n; case TYPE_ARR: { @@ -220,7 +224,11 @@ struct trie_node *node = NULL; if(strcmp(name + 4, "mouse") == 0) { - node = new_node_key(TERMKEY_TYPE_MOUSE, 0, 0, 0); + node = malloc(sizeof(*node)); + if(!node) + return 0; + + node->type = TYPE_MOUSE; } else { TermKeyType type; @@ -428,11 +436,15 @@ pos++; - if(p->type != TYPE_KEY) - continue; - - struct trie_node_key *nk = (struct trie_node_key*)p; - if(nk->key.type == TERMKEY_TYPE_MOUSE) { + if(p->type == TYPE_KEY) { + struct trie_node_key *nk = (struct trie_node_key*)p; + key->type = nk->key.type; + key->code.sym = nk->key.sym; + key->modifiers = nk->key.modifier_set; + *nbytep = pos; + return TERMKEY_RES_KEY; + } + else if(p->type == TYPE_MOUSE) { tk->buffstart += pos; tk->buffcount -= pos; @@ -446,12 +458,6 @@ return mouse_result; } - - key->type = nk->key.type; - key->code.sym = nk->key.sym; - key->modifiers = nk->key.modifier_set; - *nbytep = pos; - return TERMKEY_RES_KEY; } // If p is not NULL then we hadn't walked off the end yet, so we have a @@ -491,6 +497,7 @@ { "left", TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_LEFT, 0 }, { "mark", TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_MARK, 0 }, { "message", TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_MESSAGE, 0 }, + { "mouse", TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_NONE, 0 }, { "move", TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_MOVE, 0 }, { "next", TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_PAGEDOWN, 0 }, // Not quite, but it's the best we can do { "npage", TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_PAGEDOWN, 0 }, @@ -603,6 +610,7 @@ break; } case TYPE_KEY: + case TYPE_MOUSE: fprintf(stderr, "ASSERT FAIL: Tried to insert child node in TYPE_KEY\n"); abort(); }