annotate console/libgnt/gntkeys.c @ 15781:567097a973c6

Do some funky stuff with the escape key.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 09 Mar 2007 01:44:18 +0000
parents 20e934a1a47e
children 465a58f2c711
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
14876
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
13
14977
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
14 void gnt_init_keys()
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 {
14972
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
16 if (term == NULL) {
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
17 term = getenv("TERM");
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
18 if (!term)
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
19 term = ""; /* Just in case */
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
20 }
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
21
14977
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
22 if (strcmp(term, "xterm") == 0 || strcmp(term, "rxvt") == 0) {
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
23 gnt_key_cup = "\033" "[1;5A";
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
24 gnt_key_cdown = "\033" "[1;5B";
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
25 gnt_key_cright = "\033" "[1;5C";
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
26 gnt_key_cleft = "\033" "[1;5D";
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
27 } else if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0) {
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
28 gnt_key_cup = "\033" "Oa";
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
29 gnt_key_cdown = "\033" "Ob";
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
30 gnt_key_cright = "\033" "Oc";
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
31 gnt_key_cleft = "\033" "Od";
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
32 }
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
33 }
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
34
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
35 void gnt_keys_refine(char *text)
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14976
diff changeset
36 {
15781
567097a973c6 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15779
diff changeset
37 if (*text == 27 && *(text + 1) == '[' &&
14976
2ccce4e114ca [gaim-migrate @ 17754]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14972
diff changeset
38 (*(text + 2) >= 'A' && *(text + 2) <= 'D')) {
14972
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
39 /* Apparently this is necessary for urxvt and screen and xterm */
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
40 if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0 ||
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
41 strcmp(term, "xterm") == 0)
14876
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
42 *(text + 1) = 'O';
14972
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
43 } else if (*(unsigned char*)text == 195) {
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
44 if (*(text + 2) == 0 && strcmp(term, "xterm") == 0) {
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
45 *(text) = 27;
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
46 *(text + 1) -= 64; /* Say wha? */
99112cd4a2f4 [gaim-migrate @ 17750]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14877
diff changeset
47 }
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 }
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 }
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50
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
51 /**
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
52 * 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
53 * 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
54 * 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
55 * 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
56 * 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
57 * 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
58 */
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
59 #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
60
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
61 #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
62 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
63 {
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
64 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
65 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
66 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
67 };
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
68
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
69 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
70
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
71 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
72 {
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
73 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
74 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
75 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
76 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
77 }
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
78 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
79 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
80 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
81 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
82 }
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
83 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
84 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
85 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
86 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
87 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
88 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
89 }
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
90
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
91 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
92 {
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
93 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
94 }
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
95
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
96 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
97 {
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
98 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
99
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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110 }
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
111 }
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
112
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
113 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
114 {
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
115 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
116 }
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
117
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
118 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
119 {
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
120 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
121 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
122
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
123 while (*path && n->next[*path] && !(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
124 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
125 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
126 }
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
127
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
128 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
129 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
130 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
131 }
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
132
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
133 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
134 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
135 {
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
136 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
137 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
138 if (node->next[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
139 g_printerr("%*c (%d:%d)\n", depth, i, node->next[i]->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
140 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
141 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
142 }
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
143 }
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
144 }
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 /* this is purely for debugging purposes. */
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 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
148 {
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 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
150 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
151 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
152 }
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