[Geany-devel] keybinding order issues

Nick Treleaven nick.treleaven at xxxxx
Fri Jul 4 14:26:28 UTC 2008


On Fri, 4 Jul 2008 15:08:27 +0100
Nick Treleaven <nick.treleaven at btinternet.com> wrote:

...
> To solve this, we could have the GEANY_KEYS_ commands share a single
> enum, but unsorted so we can append items as needed. All the group
> enums could be moved into keybindings.c, renaming them so all the
> existing code works without changes. The only function that would need
> updating would be keybindings_send_command(), plus storing the
> GEANY_KEYS_ enum value in each keybinding struct, so that function can
> find the callback.

To be clearer, user code would change, but not much of keybindings.c
would require changes. As an example:

keybindings.h:
enum CommonKeyIds {..., GEANY_KEYS_SOME_COMMAND, ...}

keybindings.c:
enum KeyGroups {..., KEY_GROUP_SOME, ...}
enum SomeGroupOrder {..., KEYS_SOME_COMMAND, ...}

keygroups[KEY_GROUP_SOME]->keys[KEYS_SOME_COMMAND]->id =
GEANY_KEYS_SOME_COMMAND;

Then keybindings_send_command() would search for that id in
keygroups[x]->keys[y]. Although that's a relatively slow search
algorithm, it probably wouldn't matter here. If necessary it could
be optimized to use a hash/lookup table.

Regards,
Nick



More information about the Devel mailing list