[Geany-devel] keybinding order issues

Enrico Tröger enrico.troeger at xxxxx
Sun Jul 6 18:18:25 UTC 2008


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

> 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.

My first thought was the search algorithm wouldn't matter at all as we
don't have that many keybindings. But indeed, we have 110 (!)
keybindings.
Anyway, 100 integer comparisons aren't that expensive and should be ok
at least for now. As you said, it could be improved later.

Regards,
Enrico

-- 
Get my GPG key from http://www.uvena.de/pub.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20080706/a279d41b/attachment.pgp>


More information about the Devel mailing list