# HG changeset patch # User Sadrul Habib Chowdhury # Date 1163575096 0 # Node ID 99112cd4a2f4fb8ec75d4c48417633e4d4a11754 # Parent 721465a37d4e33bd86fdfd6ddc003c405e69a404 [gaim-migrate @ 17750] Fix bug #1596631: keybinding not working with xterm committer: Tailor Script diff -r 721465a37d4e -r 99112cd4a2f4 console/libgnt/gntkeys.c --- a/console/libgnt/gntkeys.c Wed Nov 15 06:00:51 2006 +0000 +++ b/console/libgnt/gntkeys.c Wed Nov 15 07:18:16 2006 +0000 @@ -3,17 +3,27 @@ #include #include -const char *term; +static const char *term; void gnt_keys_refine(char *text) { + if (term == NULL) { + term = getenv("TERM"); + if (!term) + term = ""; /* Just in case */ + } + if (*text == 27 && *(text + 1) == '[' && *(text + 3) == '\0' && (*(text + 2) >= 'A' || *(text + 2) <= 'D')) { - if (term == NULL) - term = getenv("TERM"); - /* Apparently this is necessary for urxvt and screen */ - if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0) + /* Apparently this is necessary for urxvt and screen and xterm */ + if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0 || + strcmp(term, "xterm") == 0) *(text + 1) = 'O'; + } else if (*(unsigned char*)text == 195) { + if (*(text + 2) == 0 && strcmp(term, "xterm") == 0) { + *(text) = 27; + *(text + 1) -= 64; /* Say wha? */ + } } }