-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 148422f765830cd600393063cca3f47690ab14fd: path_to: revision_to:
commit 148422f765830cd600393063cca3f47690ab14fd Author: Emanuele Giaquinta <emanuele.giaquinta@gmail.com> Date: Thu Jan 15 14:30:05 2015 +0000 Before registering a binding for a key, unregister the current binding for it, if any. diff --git a/src/keyboard.C b/src/keyboard.C
--- a/src/keyboard.C +++ b/src/keyboard.C @@ -90,6 +90,24 @@ keyboard_manager::~keyboard_manager () } } +void +keyboard_manager::unregister_action (KeySym keysym, unsigned int state) +{ + for (unsigned int i = 0; i < keymap.size (); ++i) + if (keymap [i]->keysym == keysym + && keymap [i]->state == state) + { + free (keymap [i]->str); + delete keymap [i]; + + if (i < keymap.size () - 1) + keymap [i] = keymap [keymap.size () - 1]; + keymap.pop_back (); + + break; + } +} + void keyboard_manager::register_action (KeySym keysym, unsigned int state, const wchar_t *ws) { @@ -107,6 +125,8 @@ keyboard_manager::register_action (KeySym keysym, unsigned int state, const wcha else if (strncmp (action, "builtin-string:", 15) == 0) key->type = keysym_t::BUILTIN_STRING; + unregister_action (keysym, state); + if (keymap.size () == keymap.capacity ()) keymap.reserve (keymap.size () * 2); diff --git a/src/keyboard.h b/src/keyboard.h
--- a/src/keyboard.h +++ b/src/keyboard.h @@ -68,6 +68,7 @@ public: keyboard_manager (); ~keyboard_manager (); + void unregister_action (KeySym keysym, unsigned int state); void register_action (KeySym keysym, unsigned int state, const wchar_t *ws); void register_done (); // call this to make newly registered key bindings take effect bool dispatch (rxvt_term *term, KeySym keysym, unsigned int state, const char *kbuf, int len);
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 12:07:31 2024