comparison console/libgnt/gntkeys.c @ 14976:1c0772f7260b

[gaim-migrate @ 17755] Decide the values for ctrl-up/down at startup depending on $TERM. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 15 Nov 2006 20:39:32 +0000
parents 2ccce4e114ca
children b28f5caf9445
comparison
equal deleted inserted replaced
14975:2ccce4e114ca 14976:1c0772f7260b
3 #include <stdlib.h> 3 #include <stdlib.h>
4 #include <string.h> 4 #include <string.h>
5 5
6 static const char *term; 6 static const char *term;
7 7
8 void gnt_keys_refine(char *text) 8 void gnt_init_keys()
9 { 9 {
10 if (term == NULL) { 10 if (term == NULL) {
11 term = getenv("TERM"); 11 term = getenv("TERM");
12 if (!term) 12 if (!term)
13 term = ""; /* Just in case */ 13 term = ""; /* Just in case */
14 } 14 }
15 15
16 if (strcmp(term, "xterm") == 0 || strcmp(term, "rxvt") == 0) {
17 gnt_key_cup = "\033" "[1;5A";
18 gnt_key_cdown = "\033" "[1;5B";
19 gnt_key_cright = "\033" "[1;5C";
20 gnt_key_cleft = "\033" "[1;5D";
21 } else if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0) {
22 gnt_key_cup = "\033" "Oa";
23 gnt_key_cdown = "\033" "Ob";
24 gnt_key_cright = "\033" "Oc";
25 gnt_key_cleft = "\033" "Od";
26 }
27 }
28
29 void gnt_keys_refine(char *text)
30 {
16 if (*text == 27 && *(text + 1) == '[' && *(text + 3) == '\0' && 31 if (*text == 27 && *(text + 1) == '[' && *(text + 3) == '\0' &&
17 (*(text + 2) >= 'A' && *(text + 2) <= 'D')) { 32 (*(text + 2) >= 'A' && *(text + 2) <= 'D')) {
18 /* Apparently this is necessary for urxvt and screen and xterm */ 33 /* Apparently this is necessary for urxvt and screen and xterm */
19 if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0 || 34 if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0 ||
20 strcmp(term, "xterm") == 0) 35 strcmp(term, "xterm") == 0)