… | |
… | |
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 | * |
… | |
… | |
71 | |
72 | |
72 | static void |
73 | static void |
73 | output_string (rxvt_term *rt, const char *str) |
74 | output_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 (str + 8, strlen (str) - 8); |
|
|
78 | else if (strncmp (str, "perl:", 5) == 0) |
|
|
79 | HOOK_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 (str, strlen (str)); |
79 | } |
82 | } |
80 | |
83 | |
81 | static void |
84 | static void |
82 | output_string_meta8 (rxvt_term *rt, unsigned int state, char *buf, int buflen) |
85 | output_string_meta8 (rxvt_term *rt, unsigned int state, char *buf, int buflen) |
83 | { |
86 | { |
… | |
… | |
90 | *ch |= 0x80; |
93 | *ch |= 0x80; |
91 | } |
94 | } |
92 | else if (rt->meta_char == C0_ESC) /* escape prefix */ |
95 | else if (rt->meta_char == C0_ESC) /* escape prefix */ |
93 | #endif |
96 | #endif |
94 | { |
97 | { |
95 | const unsigned char ch = C0_ESC; |
98 | const char ch = C0_ESC; |
96 | rt->tt_write (&ch, 1); |
99 | rt->tt_write (&ch, 1); |
97 | } |
100 | } |
98 | } |
101 | } |
99 | |
102 | |
100 | rt->tt_write ((unsigned char *) buf, buflen); |
103 | rt->tt_write (buf, buflen); |
101 | } |
104 | } |
102 | |
105 | |
103 | static int |
106 | static int |
104 | format_keyrange_string (const char *str, int keysym_offset, char *buf, int bufsize) |
107 | format_keyrange_string (const char *str, int keysym_offset, char *buf, int bufsize) |
105 | { |
108 | { |
… | |
… | |
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 |
122 | static int |
125 | static int |
123 | bitcount (uint16_t n) |
126 | bitcount (uint16_t n) |
124 | { |
127 | { |
125 | int i; |
128 | int i; |
… | |
… | |
189 | void |
192 | void |
190 | keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const char *trans) |
193 | keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const char *trans) |
191 | { |
194 | { |
192 | keysym_t *key = new keysym_t; |
195 | keysym_t *key = new keysym_t; |
193 | wchar_t *wc = rxvt_mbstowcs (trans); |
196 | wchar_t *wc = rxvt_mbstowcs (trans); |
194 | const char *translation = rxvt_wcstoutf8 (wc); |
197 | char *translation = rxvt_wcstoutf8 (wc); |
195 | free (wc); |
198 | free (wc); |
196 | |
199 | |
197 | if (key && translation) |
200 | if (key && translation) |
198 | { |
201 | { |
199 | key->keysym = keysym; |
202 | key->keysym = keysym; |