comparison finch/libgnt/gntkeys.c @ 24281:23687caad265

Allow binding meta-arrow keys for actions. Requested by essobi in #pidgin
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 30 Oct 2008 17:54:26 +0000
parents dc8fac020fad
children e2e57d3c0578
comparison
equal deleted inserted replaced
24280:c06b85e1d020 24281:23687caad265
100 100
101 #define REM_LENGTH (sizeof(key) - (cur - key)) 101 #define REM_LENGTH (sizeof(key) - (cur - key))
102 #define INSERT_COMB(k, code) do { \ 102 #define INSERT_COMB(k, code) do { \
103 snprintf(key, sizeof(key), "%s%s%s", controls[c], alts[a], k); \ 103 snprintf(key, sizeof(key), "%s%s%s", controls[c], alts[a], k); \
104 INSERT_KEY(key, code); \ 104 INSERT_KEY(key, code); \
105 } while (0); 105 } while (0)
106 #define INSERT_COMB_CODE(k, c1, c2) do { \
107 char __[32]; \
108 snprintf(__, sizeof(__), "%s%s", c1, c2); \
109 INSERT_COMB(k, __); \
110 } while (0)
106 111
107 /* Lower-case alphabets */ 112 /* Lower-case alphabets */
108 for (a = 0, c = 0; controls[c]; c++, a = 0) { 113 for (a = 0, c = 0; controls[c]; c++, a = 0) {
109 if (c) { 114 if (c) {
110 INSERT_COMB("up", gnt_key_cup); 115 INSERT_COMB("up", gnt_key_cup);
122 code[ind] = (c ? 1 : 'a') + ch; 127 code[ind] = (c ? 1 : 'a') + ch;
123 INSERT_COMB(str, code); 128 INSERT_COMB(str, code);
124 } 129 }
125 if (c == 0) { 130 if (c == 0) {
126 INSERT_COMB("tab", "\033\t"); 131 INSERT_COMB("tab", "\033\t");
132 INSERT_COMB_CODE("up", "\033", GNT_KEY_UP);
133 INSERT_COMB_CODE("down", "\033", GNT_KEY_DOWN);
134 INSERT_COMB_CODE("left", "\033", GNT_KEY_LEFT);
135 INSERT_COMB_CODE("right", "\033", GNT_KEY_RIGHT);
127 } 136 }
128 } 137 }
129 } 138 }
130 c = 0; 139 c = 0;
131 for (a = 0; alts[a]; a++) { 140 for (a = 0; alts[a]; a++) {
142 } 151 }
143 } 152 }
144 153
145 void gnt_keys_refine(char *text) 154 void gnt_keys_refine(char *text)
146 { 155 {
156 while (*text == 27 && *(text + 1) == 27)
157 text++;
147 if (*text == 27 && *(text + 1) == '[' && 158 if (*text == 27 && *(text + 1) == '[' &&
148 (*(text + 2) >= 'A' && *(text + 2) <= 'D')) { 159 (*(text + 2) >= 'A' && *(text + 2) <= 'D')) {
149 /* Apparently this is necessary for urxvt and screen and xterm */ 160 /* Apparently this is necessary for urxvt and screen and xterm */
150 if (strstr(term, "screen") == term || strcmp(term, "rxvt-unicode") == 0 || 161 if (strstr(term, "screen") == term || strcmp(term, "rxvt-unicode") == 0 ||
151 strstr(term, "xterm") == term) 162 strstr(term, "xterm") == term)