changeset 14971:99112cd4a2f4

[gaim-migrate @ 17750] Fix bug #1596631: keybinding not working with xterm committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 15 Nov 2006 07:18:16 +0000
parents 721465a37d4e
children cfb736e4a2c4
files console/libgnt/gntkeys.c
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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 <stdlib.h>
 #include <string.h>
 
-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? */
+		}
 	}
 }