finch/libgnt/gntkeys.c

Fri, 27 Apr 2007 12:56:59 +0000

author
Richard Nelson <wabz@pidgin.im>
date
Fri, 27 Apr 2007 12:56:59 +0000
branch
finch.workspaces
changeset 16520
18efc8fca905
parent 16105
df52ecd7f260
child 17192
5cc374345f6f
child 17875
ad1536695bff
child 18068
b6554e3c8224
permissions
-rw-r--r--

Forgot these...

14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
1 #include "gntkeys.h"
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
2
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
3 #include <glib.h>
14939
7ec81b1b7bba [gaim-migrate @ 17646]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
4 #include <stdlib.h>
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
5 #include <string.h>
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
6
15095
f7c98ecaa92b [gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents: 15038
diff changeset
7 char *gnt_key_cup;
f7c98ecaa92b [gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents: 15038
diff changeset
8 char *gnt_key_cdown;
f7c98ecaa92b [gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents: 15038
diff changeset
9 char *gnt_key_cleft;
f7c98ecaa92b [gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents: 15038
diff changeset
10 char *gnt_key_cright;
f7c98ecaa92b [gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents: 15038
diff changeset
11
15033
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
12 static const char *term;
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
13 static GHashTable *specials;
14938
ee27e45919ef [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14153
diff changeset
14
15038
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
15 void gnt_init_keys()
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
16 {
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
17 const char *controls[] = {"", "c-", "ctrl-", "ctr-", "ctl-", NULL};
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
18 const char *alts[] = {"", "alt-", "a-", "m-", "meta-", NULL};
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
19 int c, a, ch;
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
20 char key[32];
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
21
15033
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
22 if (term == NULL) {
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
23 term = getenv("TERM");
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
24 if (!term)
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
25 term = ""; /* Just in case */
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
26 }
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
27
15038
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
28 if (strcmp(term, "xterm") == 0 || strcmp(term, "rxvt") == 0) {
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
29 gnt_key_cup = "\033" "[1;5A";
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
30 gnt_key_cdown = "\033" "[1;5B";
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
31 gnt_key_cright = "\033" "[1;5C";
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
32 gnt_key_cleft = "\033" "[1;5D";
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
33 } else if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0) {
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
34 gnt_key_cup = "\033" "Oa";
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
35 gnt_key_cdown = "\033" "Ob";
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
36 gnt_key_cright = "\033" "Oc";
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
37 gnt_key_cleft = "\033" "Od";
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
38 }
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
39
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
40 specials = g_hash_table_new(g_str_hash, g_str_equal);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
41
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
42 #define INSERT_KEY(k, code) do { \
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
43 g_hash_table_insert(specials, g_strdup(k), g_strdup(code)); \
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
44 gnt_keys_add_combination(code); \
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
45 } while (0)
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
46
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
47 INSERT_KEY("home", GNT_KEY_HOME);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
48 INSERT_KEY("end", GNT_KEY_END);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
49 INSERT_KEY("pageup", GNT_KEY_PGUP);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
50 INSERT_KEY("pagedown", GNT_KEY_PGDOWN);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
51 INSERT_KEY("insert", GNT_KEY_INS);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
52 INSERT_KEY("delete", GNT_KEY_DEL);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
53
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
54 INSERT_KEY("left", GNT_KEY_LEFT);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
55 INSERT_KEY("right", GNT_KEY_RIGHT);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
56 INSERT_KEY("up", GNT_KEY_UP);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
57 INSERT_KEY("down", GNT_KEY_DOWN);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
58
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
59 INSERT_KEY("tab", "\t");
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
60 INSERT_KEY("menu", GNT_KEY_POPUP);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
61
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
62 INSERT_KEY("f1", GNT_KEY_F1);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
63 INSERT_KEY("f2", GNT_KEY_F2);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
64 INSERT_KEY("f3", GNT_KEY_F3);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
65 INSERT_KEY("f4", GNT_KEY_F4);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
66 INSERT_KEY("f5", GNT_KEY_F5);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
67 INSERT_KEY("f6", GNT_KEY_F6);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
68 INSERT_KEY("f7", GNT_KEY_F7);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
69 INSERT_KEY("f8", GNT_KEY_F8);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
70 INSERT_KEY("f9", GNT_KEY_F9);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
71 INSERT_KEY("f10", GNT_KEY_F10);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
72 INSERT_KEY("f11", GNT_KEY_F11);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
73 INSERT_KEY("f12", GNT_KEY_F12);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
74
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
75 #define REM_LENGTH (sizeof(key) - (cur - key))
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
76 #define INSERT_COMB(k, code) do { \
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
77 snprintf(key, sizeof(key), "%s%s%s", controls[c], alts[a], k); \
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
78 INSERT_KEY(key, code); \
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
79 } while (0);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
80
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
81 /* Lower-case alphabets */
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
82 for (a = 0, c = 0; controls[c]; c++, a = 0) {
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
83 if (c) {
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
84 INSERT_COMB("up", gnt_key_cup);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
85 INSERT_COMB("down", gnt_key_cdown);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
86 INSERT_COMB("left", gnt_key_cleft);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
87 INSERT_COMB("right", gnt_key_cright);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
88 }
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
89
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
90 for (a = 0; alts[a]; a++) {
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
91 for (ch = 0; ch < 26; ch++) {
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
92 char str[2] = {'a' + ch, 0}, code[4] = "\0\0\0\0";
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
93 int ind = 0;
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
94 if (a)
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
95 code[ind++] = '\033';
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
96 code[ind] = (c ? 1 : 'a') + ch;
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
97 INSERT_COMB(str, code);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
98 }
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
99 }
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
100 }
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
101 c = 0;
15877
ca1fabffc300 Allow non-alt non-ctrl bindings. I broke this with me last few changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15874
diff changeset
102 for (a = 0; alts[a]; a++) {
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
103 /* Upper-case alphabets */
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
104 for (ch = 0; ch < 26; ch++) {
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
105 char str[2] = {'A' + ch, 0}, code[] = {'\033', 'A' + ch, 0};
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
106 INSERT_COMB(str, code);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
107 }
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
108 /* Digits */
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
109 for (ch = 0; ch < 10; ch++) {
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
110 char str[2] = {'0' + ch, 0}, code[] = {'\033', '0' + ch, 0};
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
111 INSERT_COMB(str, code);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
112 }
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
113 }
15038
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
114 }
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
115
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
116 void gnt_keys_refine(char *text)
e57ca0ff0489 [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15037
diff changeset
117 {
15842
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15840
diff changeset
118 if (*text == 27 && *(text + 1) == '[' &&
15037
5a60f16a26b9 [gaim-migrate @ 17754]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15033
diff changeset
119 (*(text + 2) >= 'A' && *(text + 2) <= 'D')) {
15033
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
120 /* Apparently this is necessary for urxvt and screen and xterm */
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
121 if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0 ||
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
122 strcmp(term, "xterm") == 0)
14938
ee27e45919ef [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14153
diff changeset
123 *(text + 1) = 'O';
15033
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
124 } else if (*(unsigned char*)text == 195) {
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
125 if (*(text + 2) == 0 && strcmp(term, "xterm") == 0) {
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
126 *(text) = 27;
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
127 *(text + 1) -= 64; /* Say wha? */
9413ff0ec346 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14939
diff changeset
128 }
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
129 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
130 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
131
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
132 const char *gnt_key_translate(const char *name)
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
133 {
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
134 return g_hash_table_lookup(specials, name);
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
135 }
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
136
16047
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
137 typedef struct {
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
138 const char *name;
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
139 const char *key;
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
140 } gntkey;
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
141
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
142 static void
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
143 get_key_name(gpointer key, gpointer value, gpointer data)
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
144 {
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
145 gntkey *k = data;
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
146 if (k->name)
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
147 return;
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
148 if (g_utf8_collate(value, k->key) == 0)
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
149 k->name = key;
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
150 }
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
151
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
152 const char *gnt_key_lookup(const char *key)
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
153 {
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
154 gntkey k = {NULL, key};
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
155 g_hash_table_foreach(specials, get_key_name, &k);
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
156 return k.name;
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
157 }
03880dc14852 Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
158
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
159 /**
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
160 * The key-bindings will be saved in a tree. When a keystroke happens, GNT will
15840
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
161 * find the sequence that matches a binding and return the length.
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
162 * A sequence should not be a prefix of another sequence. If it is, then only
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
163 * the shortest one will be processed. If we want to change that, we will need
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
164 * to allow getting the k-th prefix that matches the input, and pay attention
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
165 * to the return value of gnt_wm_process_input in gntmain.c.
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
166 */
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
167 #define SIZE 256
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
168
15840
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
169 #define IS_END 1 << 0
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
170 struct _node
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
171 {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
172 struct _node *next[SIZE];
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
173 int ref;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
174 int flags;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
175 };
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
176
15840
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
177 static struct _node root = {.ref = 1, .flags = 0};
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
178
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
179 static void add_path(struct _node *node, const char *path)
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
180 {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
181 struct _node *n = NULL;
15840
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
182 if (!path || !*path) {
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
183 node->flags |= IS_END;
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
184 return;
15840
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
185 }
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
186 while (*path && node->next[*path]) {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
187 node = node->next[*path];
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
188 node->ref++;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
189 path++;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
190 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
191 if (!*path)
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
192 return;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
193 n = g_new0(struct _node, 1);
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
194 n->ref = 1;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
195 node->next[*path++] = n;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
196 add_path(n, path);
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
197 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
198
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
199 void gnt_keys_add_combination(const char *path)
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
200 {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
201 add_path(&root, path);
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
202 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
203
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
204 static void del_path(struct _node *node, const char *path)
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
205 {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
206 struct _node *next = NULL;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
207
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
208 if (!*path)
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
209 return;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
210 next = node->next[*path];
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
211 if (!next)
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
212 return;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
213 del_path(next, path + 1);
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
214 next->ref--;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
215 if (next->ref == 0) {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
216 node->next[*path] = NULL;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
217 g_free(next);
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
218 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
219 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
220
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
221 void gnt_keys_del_combination(const char *path)
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
222 {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
223 del_path(&root, path);
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
224 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
225
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
226 int gnt_keys_find_combination(const char *path)
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
227 {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
228 int depth = 0;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
229 struct _node *n = &root;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
230
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
231 root.flags &= ~IS_END;
15840
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
232 while (*path && n->next[*path] && !(n->flags & IS_END)) {
16105
df52ecd7f260 Only ascii keys can be bound, fixes a crash when inputting non-ascii chars
Richard Nelson <wabz@pidgin.im>
parents: 16047
diff changeset
233 if (!g_ascii_isspace(*path) &&
df52ecd7f260 Only ascii keys can be bound, fixes a crash when inputting non-ascii chars
Richard Nelson <wabz@pidgin.im>
parents: 16047
diff changeset
234 !g_ascii_iscntrl(*path) &&
df52ecd7f260 Only ascii keys can be bound, fixes a crash when inputting non-ascii chars
Richard Nelson <wabz@pidgin.im>
parents: 16047
diff changeset
235 !g_ascii_isgraph(*path))
15852
99c67d0a7eed fix extraneous char being added when gntentry's buffer grows
Richard Nelson <wabz@pidgin.im>
parents: 15842
diff changeset
236 return 0;
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
237 n = n->next[*path++];
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
238 depth++;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
239 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
240
15840
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
241 if (!(n->flags & IS_END))
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
242 depth = 0;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
243 return depth;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
244 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
245
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
246 static void
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
247 print_path(struct _node *node, int depth)
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
248 {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
249 int i;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
250 for (i = 0; i < SIZE; i++) {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
251 if (node->next[i]) {
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15852
diff changeset
252 g_printerr("%*c (%d:%d)\n", depth * 4, i, node->next[i]->ref,
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
253 node->next[i]->flags);
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
254 print_path(node->next[i], depth + 1);
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
255 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
256 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
257 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
258
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
259 /* this is purely for debugging purposes. */
15874
46df7421a1b5 Enable DEBUG_CFLAGS in libgnt and fix up a number of compile warnings and
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15862
diff changeset
260 void gnt_keys_print_combinations(void);
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
261 void gnt_keys_print_combinations()
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
262 {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
263 g_printerr("--------\n");
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
264 print_path(&root, 1);
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
265 g_printerr("--------\n");
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
266 }
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15095
diff changeset
267

mercurial