=== modified file 'termkey.c' --- termkey.c 2008-02-10 17:46:48 +0000 +++ termkey.c 2008-02-10 17:41:13 +0000 @@ -18,9 +18,6 @@ int nkeynames; const char **keynames; - // There are 32 C0 codes - termkey_keysym c0[32]; - // There are 64 codes 0x40 - 0x7F termkey_keysym csi_ss3s[64]; termkey_keysym ss3s[64]; @@ -70,11 +67,6 @@ tk->is_closed = 0; int i; - - for(i = 0; i < 32; i++) { - tk->c0[i] = TERMKEY_SYM_UNKNOWN; - } - for(i = 0; i < 64; i++) { tk->csi_ss3s[i] = TERMKEY_SYM_UNKNOWN; tk->ss3s[i] = TERMKEY_SYM_UNKNOWN; @@ -97,10 +89,11 @@ // Special built-in names termkey_register_keyname(tk, TERMKEY_SYM_NONE, "NONE"); - termkey_register_c0(tk, TERMKEY_SYM_BACKSPACE, 0x08, "Backspace"); - termkey_register_c0(tk, TERMKEY_SYM_TAB, 0x09, "Tab"); - termkey_register_c0(tk, TERMKEY_SYM_ENTER, 0x0a, "Enter"); - termkey_register_c0(tk, TERMKEY_SYM_ESCAPE, 0x1b, "Escape"); + // C0 + termkey_register_keyname(tk, TERMKEY_SYM_BACKSPACE, "Backspace"); + termkey_register_keyname(tk, TERMKEY_SYM_TAB, "Tab"); + termkey_register_keyname(tk, TERMKEY_SYM_ENTER, "Enter"); + termkey_register_keyname(tk, TERMKEY_SYM_ESCAPE, "Escape"); // G1 termkey_register_keyname(tk, TERMKEY_SYM_SPACE, "Space"); @@ -365,8 +358,14 @@ key->code = 0; - if(!(tk->flags & TERMKEY_FLAG_NOINTERPRET) && tk->c0[b0] != TERMKEY_SYM_UNKNOWN) - key->code = tk->c0[b0]; + if(!(tk->flags & TERMKEY_FLAG_NOINTERPRET)) { + // Try to interpret C0 codes that have nice names + switch(b0) { + case 0x08: key->code = TERMKEY_SYM_BACKSPACE; break; + case 0x09: key->code = TERMKEY_SYM_TAB; break; + case 0x0a: key->code = TERMKEY_SYM_ENTER; break; + } + } if(!key->code) { key->code = b0 + 0x40; @@ -614,21 +613,6 @@ return code; } -termkey_keysym termkey_register_c0(termkey_t *tk, termkey_keysym code, unsigned char ctrl, const char *name) -{ - if(ctrl >= 0x20) { - fprintf(stderr, "Cannot register C0 key at ctrl 0x%02x - out of bounds\n", ctrl); - return -1; - } - - if(name) - code = termkey_register_keyname(tk, code, name); - - tk->c0[ctrl] = code; - - return code; -} - termkey_keysym termkey_register_csi_ss3(termkey_t *tk, termkey_keysym code, unsigned char cmd, const char *name) { if(cmd < 0x40 || cmd >= 0x80) { === modified file 'termkey.h' --- termkey.h 2008-02-10 17:46:48 +0000 +++ termkey.h 2008-02-10 17:41:13 +0000 @@ -119,7 +119,6 @@ // Registration of keys and names termkey_keysym termkey_register_keyname(termkey_t *tk, termkey_keysym code, const char *name); -termkey_keysym termkey_register_c0(termkey_t *tk, termkey_keysym code, unsigned char ctrl, const char *name); termkey_keysym termkey_register_csi_ss3(termkey_t *tk, termkey_keysym code, unsigned char cmd, const char *name); termkey_keysym termkey_register_ss3kpalt(termkey_t *tk, termkey_keysym code, unsigned char cmd, const char *name, char kpalt); termkey_keysym termkey_register_csifunc(termkey_t *tk, termkey_keysym code, int number, const char *name);