Mercurial > pidgin.yaz
annotate console/libgnt/gntkeys.c @ 15559:dad51c0e3bc6
context menu cleanup
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 05 Feb 2007 10:04:31 +0000 |
parents | b28f5caf9445 |
children | c2c2a854f5b3 |
rev | line source |
---|---|
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gntkeys.h" |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 |
14877
c01f62c83647
[gaim-migrate @ 17646]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
3 #include <stdlib.h> |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 #include <string.h> |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 |
15034
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
6 char *gnt_key_cup; |
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
7 char *gnt_key_cdown; |
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
8 char *gnt_key_cleft; |
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
9 char *gnt_key_cright; |
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
10 |
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
11 |
14972
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
12 static const char *term; |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
13 |
14977
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
14 void gnt_init_keys() |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 { |
14972
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
16 if (term == NULL) { |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
17 term = getenv("TERM"); |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
18 if (!term) |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
19 term = ""; /* Just in case */ |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
20 } |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
21 |
14977
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
22 if (strcmp(term, "xterm") == 0 || strcmp(term, "rxvt") == 0) { |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
23 gnt_key_cup = "\033" "[1;5A"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
24 gnt_key_cdown = "\033" "[1;5B"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
25 gnt_key_cright = "\033" "[1;5C"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
26 gnt_key_cleft = "\033" "[1;5D"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
27 } else if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0) { |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
28 gnt_key_cup = "\033" "Oa"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
29 gnt_key_cdown = "\033" "Ob"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
30 gnt_key_cright = "\033" "Oc"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
31 gnt_key_cleft = "\033" "Od"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
32 } |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
33 } |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
34 |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
35 void gnt_keys_refine(char *text) |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
36 { |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
37 if (*text == 27 && *(text + 1) == '[' && *(text + 3) == '\0' && |
14976
2ccce4e114ca
[gaim-migrate @ 17754]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14972
diff
changeset
|
38 (*(text + 2) >= 'A' && *(text + 2) <= 'D')) { |
14972
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
39 /* Apparently this is necessary for urxvt and screen and xterm */ |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
40 if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0 || |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
41 strcmp(term, "xterm") == 0) |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
42 *(text + 1) = 'O'; |
14972
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
43 } else if (*(unsigned char*)text == 195) { |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
44 if (*(text + 2) == 0 && strcmp(term, "xterm") == 0) { |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
45 *(text) = 27; |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
46 *(text + 1) -= 64; /* Say wha? */ |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
47 } |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 |