[Geany-devel] plugin keybindings

Prim András pa at xxxxx
Sun Aug 17 18:06:45 UTC 2008


Hi all!

I've started to write a plugin that puts configurable text around the 
selection (e.g. <b> ... </b>).
The number of keybindings depends on the configuration file, so I can't use:

<code>
PLUGIN_KEY_GROUP(plugin_name, KB_COUNT)
</code>

since it needs a hardwired KB_COUNT.
Therefore I used:

<code>
static GeanyKeyBinding *plugin_keys = NULL;
GeanyKeyGroup plugin_key_group[1] =
{
    {PLUGIN_NAME, NULL, 0, NULL}
};

void plugin_init(GeanyData *data)
{
...
    /*  read keybinding number from config file  */
    plugin_keys = g_new(GeanyKeyBinding, num_keybindings);
    plugin_key_group->count = num_keybindings;
    plugin_key_group->keys = plugin_keys;
...
}
</code>

It works for me, but I don't know whether it is conceptionally right or 
wrong.

The other thing: is it possible to change the keybinding group when 
edited file changes? (e.g. having 20 keybindings for HTML files, but 
only 2 for C?)

Regards
Andras Prim



More information about the Devel mailing list