]> git.tuebingen.mpg.de Git - paraslash.git/commit
i9e: Avoid key binding macros.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 3 Oct 2015 17:51:38 +0000 (17:51 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 25 Oct 2015 15:13:43 +0000 (16:13 +0100)
commitc0162946c2124d1afd09bc7fc3b0aa4bb386f9f8
tree22ff538121c955810f0c9ab7ffa4d719c59fb405
parent73f00df1d8dea3793c9f436b9348074bc6f9aaba
i9e: Avoid key binding macros.

The key binding code of interactive.c is quite an ugly hack which is
marked with a FIXME comment since forever. We bind each key sequence
given in the ->bound_keyseqs array of struct i9e_client_info to a
key code which is then mapped to a command handler provoded by the
application. The bindings started at key 64 with an arbitrary limit
of 32 possible mappings.

Besides being ugly, the problem with this mapping scheme is that
upper case keys are also in this range and are hence also mapped to
the specified commands.

This commit takes another approach. We now bind key sequences to a
function instead of a macro, passing ISFUNC as the first parameter to
libreadline's rl_generic_bind(). All key sequences are bound to the
same function, dispatch_key(), which calls the application-defined
key handler.

This is still not optimal because we need to look up the key sequence
again in dispatch_key(). But since this is not a fast path anyway,
it should be OK.
interactive.c