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.53 by sf-exg, Fri Dec 2 09:13:50 2011 UTC vs.
Revision 1.56 by sf-exg, Mon Dec 5 12:22:50 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 wchar_t *ws) 111keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const wchar_t *ws)
114{ 112{
115 char *translation = rxvt_wcstoutf8 (ws); 113 char *translation = rxvt_wcstoutf8 (ws);
116 114
117 register_translation (keysym, state, translation);
118}
119
120void
121keyboard_manager::register_translation (KeySym keysym, unsigned int state, char *translation)
122{
123 keysym_t *key = new keysym_t; 115 keysym_t *key = new keysym_t;
124 116
125 if (key && translation)
126 {
127 key->keysym = keysym; 117 key->keysym = keysym;
128 key->state = state; 118 key->state = state;
129 key->str = translation; 119 key->str = translation;
130 key->type = keysym_t::STRING; 120 key->type = keysym_t::STRING;
131 121
132 if (strncmp (translation, "builtin:", 8) == 0) 122 if (strncmp (translation, "builtin:", 8) == 0)
133 key->type = keysym_t::BUILTIN; 123 key->type = keysym_t::BUILTIN;
134 124
135 if (keymap.size () == keymap.capacity ()) 125 if (keymap.size () == keymap.capacity ())
136 keymap.reserve (keymap.size () * 2); 126 keymap.reserve (keymap.size () * 2);
137 127
138 keymap.push_back (key); 128 keymap.push_back (key);
139 hash[0] = 3; 129 hash[0] = 3;
140 }
141 else
142 {
143 delete key;
144 free (translation);
145 rxvt_fatal ("memory allocation failure. aborting.\n");
146 }
147} 130}
148 131
149bool 132bool
150keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state) 133keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state)
151{ 134{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines