Wed, 14 Mar 2007 07:56:48 +0000
fix extraneous char being added when gntentry's buffer grows
fix crash when entering wide chars
|
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; |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
13 | |
|
15038
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
14 | void gnt_init_keys() |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
15 | { |
|
15033
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
16 | if (term == NULL) { |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
17 | term = getenv("TERM"); |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
18 | if (!term) |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
19 | term = ""; /* Just in case */ |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
20 | } |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
21 | |
|
15038
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
22 | if (strcmp(term, "xterm") == 0 || strcmp(term, "rxvt") == 0) { |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
23 | gnt_key_cup = "\033" "[1;5A"; |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
24 | gnt_key_cdown = "\033" "[1;5B"; |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
25 | gnt_key_cright = "\033" "[1;5C"; |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
26 | gnt_key_cleft = "\033" "[1;5D"; |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
27 | } 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
|
28 | gnt_key_cup = "\033" "Oa"; |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
29 | gnt_key_cdown = "\033" "Ob"; |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
30 | gnt_key_cright = "\033" "Oc"; |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
31 | gnt_key_cleft = "\033" "Od"; |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
32 | } |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
33 | } |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
34 | |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
35 | void gnt_keys_refine(char *text) |
|
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15037
diff
changeset
|
36 | { |
|
15842
0b00e18a33f2
Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15840
diff
changeset
|
37 | if (*text == 27 && *(text + 1) == '[' && |
|
15037
5a60f16a26b9
[gaim-migrate @ 17754]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15033
diff
changeset
|
38 | (*(text + 2) >= 'A' && *(text + 2) <= 'D')) { |
|
15033
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
39 | /* Apparently this is necessary for urxvt and screen and xterm */ |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
40 | if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0 || |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
41 | strcmp(term, "xterm") == 0) |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
42 | *(text + 1) = 'O'; |
|
15033
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
43 | } else if (*(unsigned char*)text == 195) { |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
44 | if (*(text + 2) == 0 && strcmp(term, "xterm") == 0) { |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
45 | *(text) = 27; |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
46 | *(text + 1) -= 64; /* Say wha? */ |
|
9413ff0ec346
[gaim-migrate @ 17750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14939
diff
changeset
|
47 | } |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
48 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
49 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
50 | |
|
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
|
51 | /** |
|
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
|
52 | * 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
|
53 | * 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
|
54 | * 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
|
55 | * 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
|
56 | * 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
|
57 | * 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
|
58 | */ |
|
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
|
59 | #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
|
60 | |
|
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
|
61 | #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
|
62 | 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
|
63 | { |
|
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
|
64 | 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
|
65 | 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
|
66 | 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
|
67 | }; |
|
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
|
68 | |
|
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
|
69 | 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
|
70 | |
|
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
|
71 | 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
|
72 | { |
|
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
|
73 | 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
|
74 | 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
|
75 | 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
|
76 | 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
|
77 | } |
|
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
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | 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
|
82 | } |
|
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
|
83 | 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
|
84 | 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
|
85 | 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
|
86 | 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
|
87 | 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
|
88 | 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
|
89 | } |
|
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
|
90 | |
|
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
|
91 | 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
|
92 | { |
|
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
|
93 | 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
|
94 | } |
|
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
|
95 | |
|
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
|
96 | 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
|
97 | { |
|
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
|
98 | 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
|
99 | |
|
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
|
100 | 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
|
101 | 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
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | 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
|
110 | } |
|
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
|
111 | } |
|
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
|
112 | |
|
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
|
113 | 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
|
114 | { |
|
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
|
115 | 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
|
116 | } |
|
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
|
117 | |
|
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
|
118 | 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
|
119 | { |
|
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
|
120 | 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
|
121 | 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
|
122 | |
|
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
|
123 | while (*path && n->next[*path] && !(n->flags & IS_END)) { |
|
15852
99c67d0a7eed
fix extraneous char being added when gntentry's buffer grows
Richard Nelson <wabz@pidgin.im>
parents:
15842
diff
changeset
|
124 | if (g_utf8_find_next_char(path, NULL) - path > 1) |
|
99c67d0a7eed
fix extraneous char being added when gntentry's buffer grows
Richard Nelson <wabz@pidgin.im>
parents:
15842
diff
changeset
|
125 | 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
|
126 | 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
|
127 | 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
|
128 | } |
|
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
|
129 | |
|
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
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | } |
|
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
|
134 | |
|
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
|
135 | 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
|
136 | 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
|
137 | { |
|
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
|
138 | 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
|
139 | 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
|
140 | if (node->next[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
|
141 | g_printerr("%*c (%d:%d)\n", depth, i, node->next[i]->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
|
142 | 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
|
143 | 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
|
144 | } |
|
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
|
145 | } |
|
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
|
146 | } |
|
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
|
147 | |
|
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
|
148 | /* this is purely for debugging purposes. */ |
|
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
|
149 | 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
|
150 | { |
|
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
|
151 | 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
|
152 | 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
|
153 | 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
|
154 | } |
|
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
|
155 |