Mercurial > pidgin.yaz
annotate console/libgnt/gntkeys.c @ 15815:1c8f1dc50685
Enable DEBUG_CFLAGS in libgnt and fix up a number of compile warnings and
errors this showed up
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sun, 18 Mar 2007 17:28:21 +0000 |
parents | 682022b8a129 |
children | 317e7613e581 |
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 |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
3 #include <glib.h> |
14877
c01f62c83647
[gaim-migrate @ 17646]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
4 #include <stdlib.h> |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 #include <string.h> |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 |
15034
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
7 char *gnt_key_cup; |
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
8 char *gnt_key_cdown; |
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
9 char *gnt_key_cleft; |
b28f5caf9445
[gaim-migrate @ 17816]
Christopher O'Brien <siege@pidgin.im>
parents:
14977
diff
changeset
|
10 char *gnt_key_cright; |
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; |
15801
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
13 static GHashTable *specials; |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
14 |
14977
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
15 void gnt_init_keys() |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 { |
15801
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
17 const char *controls[] = {"", "c-", "ctrl-", "ctr-", "ctl-", NULL}; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
18 const char *alts[] = {"", "alt-", "a-", "m-", "meta-", NULL}; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
19 int c, a, ch; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
20 char key[32]; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
21 |
14972
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
22 if (term == NULL) { |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
23 term = getenv("TERM"); |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
24 if (!term) |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
25 term = ""; /* Just in case */ |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
26 } |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
27 |
14977
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
28 if (strcmp(term, "xterm") == 0 || strcmp(term, "rxvt") == 0) { |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
29 gnt_key_cup = "\033" "[1;5A"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
30 gnt_key_cdown = "\033" "[1;5B"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
31 gnt_key_cright = "\033" "[1;5C"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
32 gnt_key_cleft = "\033" "[1;5D"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
33 } 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
|
34 gnt_key_cup = "\033" "Oa"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
35 gnt_key_cdown = "\033" "Ob"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
36 gnt_key_cright = "\033" "Oc"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
37 gnt_key_cleft = "\033" "Od"; |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
38 } |
15801
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
39 |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
40 specials = g_hash_table_new(g_str_hash, g_str_equal); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
41 |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
42 #define INSERT_KEY(k, code) do { \ |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
43 g_hash_table_insert(specials, g_strdup(k), g_strdup(code)); \ |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
44 gnt_keys_add_combination(code); \ |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
45 } while (0) |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
46 |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
47 INSERT_KEY("home", GNT_KEY_HOME); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
48 INSERT_KEY("end", GNT_KEY_END); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
49 INSERT_KEY("pageup", GNT_KEY_PGUP); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
50 INSERT_KEY("pagedown", GNT_KEY_PGDOWN); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
51 INSERT_KEY("insert", GNT_KEY_INS); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
52 INSERT_KEY("delete", GNT_KEY_DEL); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
53 |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
54 INSERT_KEY("left", GNT_KEY_LEFT); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
55 INSERT_KEY("right", GNT_KEY_RIGHT); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
56 INSERT_KEY("up", GNT_KEY_UP); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
57 INSERT_KEY("down", GNT_KEY_DOWN); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
58 |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
59 INSERT_KEY("tab", "\t"); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
60 INSERT_KEY("menu", GNT_KEY_POPUP); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
61 |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
62 INSERT_KEY("f1", GNT_KEY_F1); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
63 INSERT_KEY("f2", GNT_KEY_F2); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
64 INSERT_KEY("f3", GNT_KEY_F3); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
65 INSERT_KEY("f4", GNT_KEY_F4); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
66 INSERT_KEY("f5", GNT_KEY_F5); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
67 INSERT_KEY("f6", GNT_KEY_F6); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
68 INSERT_KEY("f7", GNT_KEY_F7); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
69 INSERT_KEY("f8", GNT_KEY_F8); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
70 INSERT_KEY("f9", GNT_KEY_F9); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
71 INSERT_KEY("f10", GNT_KEY_F10); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
72 INSERT_KEY("f11", GNT_KEY_F11); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
73 INSERT_KEY("f12", GNT_KEY_F12); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
74 |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
75 #define REM_LENGTH (sizeof(key) - (cur - key)) |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
76 #define INSERT_COMB(k, code) do { \ |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
77 snprintf(key, sizeof(key), "%s%s%s", controls[c], alts[a], k); \ |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
78 INSERT_KEY(key, code); \ |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
79 } while (0); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
80 |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
81 /* Lower-case alphabets */ |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
82 for (a = 0, c = 0; controls[c]; c++, a = 0) { |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
83 if (c) { |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
84 INSERT_COMB("up", gnt_key_cup); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
85 INSERT_COMB("down", gnt_key_cdown); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
86 INSERT_COMB("left", gnt_key_cleft); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
87 INSERT_COMB("right", gnt_key_cright); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
88 } |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
89 |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
90 for (a = 0; alts[a]; a++) { |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
91 if (a == 0 && c == 0) continue; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
92 for (ch = 0; ch < 26; ch++) { |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
93 char str[2] = {'a' + ch, 0}, code[4] = "\0\0\0\0"; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
94 int ind = 0; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
95 if (a) |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
96 code[ind++] = '\033'; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
97 code[ind] = (c ? 1 : 'a') + ch; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
98 INSERT_COMB(str, code); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
99 } |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
100 } |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
101 } |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
102 c = 0; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
103 for (a = 1; alts[a]; a++) { |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
104 /* Upper-case alphabets */ |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
105 for (ch = 0; ch < 26; ch++) { |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
106 char str[2] = {'A' + ch, 0}, code[] = {'\033', 'A' + ch, 0}; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
107 INSERT_COMB(str, code); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
108 } |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
109 /* Digits */ |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
110 for (ch = 0; ch < 10; ch++) { |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
111 char str[2] = {'0' + ch, 0}, code[] = {'\033', '0' + ch, 0}; |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
112 INSERT_COMB(str, code); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
113 } |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
114 } |
14977
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
115 } |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
116 |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
117 void gnt_keys_refine(char *text) |
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
118 { |
15781
567097a973c6
Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15779
diff
changeset
|
119 if (*text == 27 && *(text + 1) == '[' && |
14976
2ccce4e114ca
[gaim-migrate @ 17754]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14972
diff
changeset
|
120 (*(text + 2) >= 'A' && *(text + 2) <= 'D')) { |
14972
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
121 /* Apparently this is necessary for urxvt and screen and xterm */ |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
122 if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0 || |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
123 strcmp(term, "xterm") == 0) |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
124 *(text + 1) = 'O'; |
14972
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
125 } else if (*(unsigned char*)text == 195) { |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
126 if (*(text + 2) == 0 && strcmp(term, "xterm") == 0) { |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
127 *(text) = 27; |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
128 *(text + 1) -= 64; /* Say wha? */ |
99112cd4a2f4
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14877
diff
changeset
|
129 } |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 |
15801
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
133 const char *gnt_key_translate(const char *name) |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
134 { |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
135 return g_hash_table_lookup(specials, name); |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
136 } |
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
137 |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
138 /** |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
139 * The key-bindings will be saved in a tree. When a keystroke happens, GNT will |
15779
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
140 * find the sequence that matches a binding and return the length. |
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
141 * A sequence should not be a prefix of another sequence. If it is, then only |
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
142 * the shortest one will be processed. If we want to change that, we will need |
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
143 * to allow getting the k-th prefix that matches the input, and pay attention |
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
144 * to the return value of gnt_wm_process_input in gntmain.c. |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
145 */ |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
146 #define SIZE 256 |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
147 |
15779
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
148 #define IS_END 1 << 0 |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
149 struct _node |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
150 { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
151 struct _node *next[SIZE]; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
152 int ref; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
153 int flags; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
154 }; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
155 |
15779
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
156 static struct _node root = {.ref = 1, .flags = 0}; |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
157 |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
158 static void add_path(struct _node *node, const char *path) |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
159 { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
160 struct _node *n = NULL; |
15779
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
161 if (!path || !*path) { |
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
162 node->flags |= IS_END; |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
163 return; |
15779
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
164 } |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
165 while (*path && node->next[*path]) { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
166 node = node->next[*path]; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
167 node->ref++; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
168 path++; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
169 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
170 if (!*path) |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
171 return; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
172 n = g_new0(struct _node, 1); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
173 n->ref = 1; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
174 node->next[*path++] = n; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
175 add_path(n, path); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
176 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
177 |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
178 void gnt_keys_add_combination(const char *path) |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
179 { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
180 add_path(&root, path); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
181 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
182 |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
183 static void del_path(struct _node *node, const char *path) |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
184 { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
185 struct _node *next = NULL; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
186 |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
187 if (!*path) |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
188 return; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
189 next = node->next[*path]; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
190 if (!next) |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
191 return; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
192 del_path(next, path + 1); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
193 next->ref--; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
194 if (next->ref == 0) { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
195 node->next[*path] = NULL; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
196 g_free(next); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
197 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
198 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
199 |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
200 void gnt_keys_del_combination(const char *path) |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
201 { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
202 del_path(&root, path); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
203 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
204 |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
205 int gnt_keys_find_combination(const char *path) |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
206 { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
207 int depth = 0; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
208 struct _node *n = &root; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
209 |
15801
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
210 root.flags &= ~IS_END; |
15779
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
211 while (*path && n->next[*path] && !(n->flags & IS_END)) { |
15791
465a58f2c711
fix extraneous char being added when gntentry's buffer grows
Richard Nelson <wabz@pidgin.im>
parents:
15781
diff
changeset
|
212 if (g_utf8_find_next_char(path, NULL) - path > 1) |
465a58f2c711
fix extraneous char being added when gntentry's buffer grows
Richard Nelson <wabz@pidgin.im>
parents:
15781
diff
changeset
|
213 return 0; |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
214 n = n->next[*path++]; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
215 depth++; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
216 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
217 |
15779
20e934a1a47e
Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15778
diff
changeset
|
218 if (!(n->flags & IS_END)) |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
219 depth = 0; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
220 return depth; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
221 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
222 |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
223 static void |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
224 print_path(struct _node *node, int depth) |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
225 { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
226 int i; |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
227 for (i = 0; i < SIZE; i++) { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
228 if (node->next[i]) { |
15801
682022b8a129
Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15791
diff
changeset
|
229 g_printerr("%*c (%d:%d)\n", depth * 4, i, node->next[i]->ref, |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
230 node->next[i]->flags); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
231 print_path(node->next[i], depth + 1); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
232 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
233 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
234 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
235 |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
236 /* this is purely for debugging purposes. */ |
15815
1c8f1dc50685
Enable DEBUG_CFLAGS in libgnt and fix up a number of compile warnings and
Stu Tomlinson <stu@nosnilmot.com>
parents:
15801
diff
changeset
|
237 void gnt_keys_print_combinations(void); |
15778
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
238 void gnt_keys_print_combinations() |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
239 { |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
240 g_printerr("--------\n"); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
241 print_path(&root, 1); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
242 g_printerr("--------\n"); |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
243 } |
c2c2a854f5b3
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 <imadil@gmail.com>
parents:
15034
diff
changeset
|
244 |