ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/keyboard.C
(Generate patch)

Comparing rxvt-unicode/src/keyboard.C (file contents):
Revision 1.14 by root, Sat Mar 12 23:35:14 2005 UTC vs.
Revision 1.18 by root, Mon Jan 2 21:17:01 2006 UTC

3 3
4#ifdef KEYSYM_RESOURCE 4#ifdef KEYSYM_RESOURCE
5 5
6#include <cstring> 6#include <cstring>
7 7
8#include "rxvtperl.h"
8#include "keyboard.h" 9#include "keyboard.h"
9#include "command.h" 10#include "command.h"
10 11
11/* an intro to the data structure: 12/* an intro to the data structure:
12 * 13 *
72static void 73static void
73output_string (rxvt_term *rt, const char *str) 74output_string (rxvt_term *rt, const char *str)
74{ 75{
75 if (strncmp (str, "command:", 8) == 0) 76 if (strncmp (str, "command:", 8) == 0)
76 rt->cmd_write ((unsigned char *)str + 8, strlen (str) - 8); 77 rt->cmd_write ((unsigned char *)str + 8, strlen (str) - 8);
78 else if (strncmp (str, "perl:", 5) == 0)
79 PERL_INVOKE((rt, HOOK_KEYBOARD_COMMAND, DT_STRING, str + 5, DT_END));
77 else 80 else
78 rt->tt_write ((unsigned char *)str, strlen (str)); 81 rt->tt_write ((unsigned char *)str, strlen (str));
79} 82}
80 83
81static void 84static void
115} 118}
116 119
117//////////////////////////////////////////////////////////////////////////////// 120////////////////////////////////////////////////////////////////////////////////
118// return: #bits of '1' 121// return: #bits of '1'
119#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) 122#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
120# define bitcount(n) (__extension__ ({ uint32_t n__ = (n); __builtin_popcount (n); })) 123# define bitcount(n) (__extension__ ({ uint32_t n__ = (n); __builtin_popcount (n__); }))
121#else 124#else
122static int 125static int
123bitcount (uint16_t n) 126bitcount (uint16_t n)
124{ 127{
125 int i; 128 int i;
215 strcpy (translation, translation + 4); 218 strcpy (translation, translation + 4);
216 } 219 }
217 else 220 else
218 rxvt_warn ("cannot parse list-type keysym '%s', treating as normal keysym.\n", translation); 221 rxvt_warn ("cannot parse list-type keysym '%s', treating as normal keysym.\n", translation);
219 } 222 }
223 else if (strncmp (translation, "builtin:", 8) == 0)
224 key->type = keysym_t::BUILTIN;
220 225
221 user_keymap.push_back (key); 226 user_keymap.push_back (key);
222 user_translations.push_back (translation); 227 user_translations.push_back (translation);
223 register_keymap (key); 228 register_keymap (key);
224 } 229 }
275 280
276 if (index >= 0) 281 if (index >= 0)
277 { 282 {
278 const keysym_t &key = *keymap [index]; 283 const keysym_t &key = *keymap [index];
279 284
285 if (key.type != keysym_t::BUILTIN)
286 {
280 int keysym_offset = keysym - key.keysym; 287 int keysym_offset = keysym - key.keysym;
281 288
282 wchar_t *wc = rxvt_utf8towcs (key.str); 289 wchar_t *wc = rxvt_utf8towcs (key.str);
283 char *str = rxvt_wcstombs (wc); 290 char *str = rxvt_wcstombs (wc);
284 // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.) 291 // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.)
285 free (wc); 292 free (wc);
286 293
287 switch (key.type) 294 switch (key.type)
288 {
289 case keysym_t::NORMAL:
290 output_string (term, str);
291 break;
292
293 case keysym_t::RANGE:
294 { 295 {
296 case keysym_t::NORMAL:
297 output_string (term, str);
298 break;
299
300 case keysym_t::RANGE:
301 {
295 char buf[STRING_MAX]; 302 char buf[STRING_MAX];
296 303
297 if (format_keyrange_string (str, keysym_offset, buf, sizeof (buf)) > 0) 304 if (format_keyrange_string (str, keysym_offset, buf, sizeof (buf)) > 0)
305 output_string (term, buf);
306 }
307 break;
308
309 case keysym_t::RANGE_META8:
310 {
311 int len;
312 char buf[STRING_MAX];
313
314 len = format_keyrange_string (str, keysym_offset, buf, sizeof (buf));
315 if (len > 0)
316 output_string_meta8 (term, state, buf, len);
317 }
318 break;
319
320 case keysym_t::LIST:
321 {
322 char buf[STRING_MAX];
323
324 char *prefix, *middle, *suffix;
325
326 prefix = str;
327 middle = strchr (prefix + 1, *prefix);
328 suffix = strrchr (middle + 1, *prefix);
329
330 memcpy (buf, prefix + 1, middle - prefix - 1);
331 buf [middle - prefix - 1] = middle [keysym_offset + 1];
332 strcpy (buf + (middle - prefix), suffix + 1);
333
298 output_string (term, buf); 334 output_string (term, buf);
335 }
336 break;
299 } 337 }
300 break;
301 338
302 case keysym_t::RANGE_META8:
303 {
304 int len;
305 char buf[STRING_MAX];
306
307 len = format_keyrange_string (str, keysym_offset, buf, sizeof (buf));
308 if (len > 0)
309 output_string_meta8 (term, state, buf, len);
310 }
311 break;
312
313 case keysym_t::LIST:
314 {
315 char buf[STRING_MAX];
316
317 char *prefix, *middle, *suffix;
318
319 prefix = str;
320 middle = strchr (prefix + 1, *prefix);
321 suffix = strrchr (middle + 1, *prefix);
322
323 memcpy (buf, prefix + 1, middle - prefix - 1);
324 buf [middle - prefix - 1] = middle [keysym_offset + 1];
325 strcpy (buf + (middle - prefix), suffix + 1);
326
327 output_string (term, buf);
328 }
329 break;
330 }
331
332 free (str); 339 free (str);
333 340
334 return true; 341 return true;
342 }
335 } 343 }
336 else 344
337 return false; 345 return false;
338} 346}
339 347
340// purge duplicate keymap entries 348// purge duplicate keymap entries
341void keyboard_manager::purge_duplicate_keymap () 349void keyboard_manager::purge_duplicate_keymap ()
342{ 350{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines