=== modified file 'driver-ti.c' --- driver-ti.c 2009-11-24 01:31:35 +0000 +++ driver-ti.c 2009-07-15 19:40:44 +0000 @@ -7,9 +7,6 @@ #include #include -/* curses.h has just poluted our namespace. We want this back */ -#undef buttons - #include #include #include @@ -23,8 +20,7 @@ typedef enum { TYPE_KEY, - TYPE_ARR, - TYPE_MOUSE, + TYPE_ARR } trie_nodetype; struct trie_node { @@ -52,7 +48,7 @@ } TermKeyTI; static int funcname2keysym(const char *funcname, TermKeyType *typep, TermKeySym *symp, int *modmask, int *modsetp); -static int insert_seq(TermKeyTI *ti, const char *seq, struct trie_node *node); +static int register_seq(TermKeyTI *ti, const char *seq, TermKeyType type, TermKeySym sym, int modmask, int modset); static struct trie_node *new_node_key(TermKeyType type, TermKeySym sym, int modmask, int modset) { @@ -90,7 +86,6 @@ { switch(n->type) { case TYPE_KEY: - case TYPE_MOUSE: fprintf(stderr, "ABORT: lookup_next within a TYPE_KEY node\n"); abort(); case TYPE_ARR: @@ -109,7 +104,6 @@ { switch(n->type) { case TYPE_KEY: - case TYPE_MOUSE: break; case TYPE_ARR: { @@ -132,7 +126,6 @@ switch(n->type) { case TYPE_KEY: - case TYPE_MOUSE: return n; case TYPE_ARR: { @@ -187,35 +180,17 @@ if(!value || value == (char*)-1) continue; - struct trie_node *node = NULL; - - if(strcmp(strfnames[i] + 4, "mouse") == 0) { - node = malloc(sizeof(*node)); - if(!node) - goto abort_free_trie; - - node->type = TYPE_MOUSE; - } - else { - TermKeyType type; - TermKeySym sym; - int mask = 0; - int set = 0; - - if(!funcname2keysym(strfnames[i] + 4, &type, &sym, &mask, &set)) - continue; - - if(sym == TERMKEY_SYM_NONE) - continue; - - node = new_node_key(type, sym, mask, set); - } - - if(node) - if(!insert_seq(ti, value, node)) { - free(node); - goto abort_free_trie; - } + TermKeyType type; + TermKeySym sym; + int mask = 0; + int set = 0; + + if(!funcname2keysym(strfnames[i] + 4, &type, &sym, &mask, &set)) + continue; + + if(sym != TERMKEY_SYM_NONE) + if(!register_seq(ti, value, type, sym, mask, set)) + goto abort_free_trie; } ti->root = compress_trie(ti->root); @@ -310,17 +285,6 @@ *nbytep = pos; return TERMKEY_RES_KEY; } - else if(p->type == TYPE_MOUSE) { - if(tk->buffcount - pos < 3) - return TERMKEY_RES_AGAIN; - - key->type = TERMKEY_TYPE_MOUSE; - key->code.mouse.buttons = CHARAT(pos+0) - 0x20; - key->code.mouse.col = CHARAT(pos+1) - 0x20; - key->code.mouse.line = CHARAT(pos+2) - 0x20; - *nbytep = pos+3; - return TERMKEY_RES_KEY; - } } // If p is not NULL then we hadn't walked off the end yet, so we have a @@ -431,7 +395,7 @@ return 0; } -static int insert_seq(TermKeyTI *ti, const char *seq, struct trie_node *node) +static int register_seq(TermKeyTI *ti, const char *seq, TermKeyType type, TermKeySym sym, int modmask, int modset) { int pos = 0; struct trie_node *p = ti->root; @@ -454,7 +418,7 @@ next = new_node_arr(0, 0xff); else // Final key node - next = node; + next = new_node_key(type, sym, modmask, modset); if(!next) return 0; @@ -473,7 +437,6 @@ break; } case TYPE_KEY: - case TYPE_MOUSE: fprintf(stderr, "ASSERT FAIL: Tried to insert child node in TYPE_KEY\n"); abort(); }