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.51 by sf-exg, Thu Dec 1 11:27:34 2011 UTC vs.
Revision 1.54 by sf-exg, Sat Dec 3 11:31:56 2011 UTC

105 free (keymap [i]->str); 105 free (keymap [i]->str);
106 delete keymap [i]; 106 delete keymap [i];
107 } 107 }
108} 108}
109 109
110// a wrapper for register_translation that converts the input string
111// to utf-8 and expands 'list' syntax.
112void 110void
113keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const char *trans) 111keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const wchar_t *ws)
114{ 112{
115 wchar_t *ws = rxvt_mbstowcs (trans);
116 char *translation = rxvt_wcstoutf8 (ws); 113 char *translation = rxvt_wcstoutf8 (ws);
117 free (ws);
118 114
119 if (strncmp (translation, "list", 4) == 0 && translation [4]
120 && strlen (translation) < STRING_MAX)
121 {
122 char *prefix = translation + 4;
123 char *middle = strchr (prefix + 1, translation [4]);
124 char *suffix = strrchr (prefix + 1, translation [4]);
125
126 if (suffix && middle && suffix > middle + 1)
127 {
128 int range = suffix - middle - 1;
129 int prefix_len = middle - prefix - 1;
130 char buf[STRING_MAX];
131
132 memcpy (buf, prefix + 1, prefix_len);
133 strcpy (buf + prefix_len + 1, suffix + 1);
134
135 for (int i = 0; i < range; i++)
136 {
137 buf [prefix_len] = middle [i + 1];
138 register_translation (keysym + i, state, strdup (buf));
139 }
140
141 free (translation);
142 return;
143 }
144 else
145 rxvt_warn ("unable to parse list-type keysym '%s', processing as normal keysym.\n", translation);
146 }
147
148 register_translation (keysym, state, translation);
149}
150
151void
152keyboard_manager::register_translation (KeySym keysym, unsigned int state, char *translation)
153{
154 keysym_t *key = new keysym_t; 115 keysym_t *key = new keysym_t;
155 116
156 if (key && translation) 117 if (key && translation)
157 { 118 {
158 key->keysym = keysym; 119 key->keysym = keysym;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines