With the advent of the plugin system i think it would be very useful if geany had a method of firing events for plugins. Right now I have implemented the sci_ functions in the plugin interface but of course this is one way traffic.
One of the things i was hoping for was to be able to hook in the non-standard haxe code completion via the plugin but this would not be possible as the event needs to be fired from editor_start_auto_complete, i.e. initiated on the geany side rather than the plugin side.
If the plugin interface had a means of registering a callback,
plugin_register(AUTO_COMPLETE,myautocompletfunction) ;
which would add myautocompletefunction to a linked list of functions for this event, then in editor_start_auto_complete it could maybe call
plugin_event(AUTOCOMPLETE, params) ;
or something to this effect would be very useful. Ultimately all the on_ functions should do the same, firing events for any registered plugins.
Anyone been thinking along these lines? Similarly for key events too.
thx
bd
Hang on, being a bit stupid here, I guess I could just hook into the Gtk event system with g_signal_connect, as I think you can have more than one event attached.
Doh!
On Mon, 30 Jul 2007 21:59:06 -0400 blackdog blackdog@ipowerhouse.com wrote:
With the advent of the plugin system i think it would be very useful if geany had a method of firing events for plugins. Right now I have implemented the sci_ functions in the plugin interface but of course this is one way traffic.
One of the things i was hoping for was to be able to hook in the non-standard haxe code completion via the plugin but this would not be possible as the event needs to be fired from editor_start_auto_complete, i.e. initiated on the geany side rather than the plugin side.
If the plugin interface had a means of registering a callback,
plugin_register(AUTO_COMPLETE,myautocompletfunction) ;
which would add myautocompletefunction to a linked list of functions for this event, then in editor_start_auto_complete it could maybe call
plugin_event(AUTOCOMPLETE, params) ;
or something to this effect would be very useful. Ultimately all the on_ functions should do the same, firing events for any registered plugins.
Anyone been thinking along these lines? Similarly for key events too.
thx
bd
On 07/31/2007 03:31:05 AM, blackdog wrote:
Hang on, being a bit stupid here, I guess I could just hook into the Gtk event system with g_signal_connect, as I think you can have more than one event attached.
Sounds good, I haven't needed any callbacks so far, but in your example for autocompletion I guess this could work well.
On Mon, 30 Jul 2007 21:59:06 -0400 blackdog blackdog@ipowerhouse.com wrote:
With the advent of the plugin system i think it would be very
useful
if geany had a method of firing events for plugins. Right now I
have
implemented the sci_ functions in the plugin interface but of
course
this is one way traffic. [...]
Anyone been thinking along these lines? Similarly for key events
too.
No, I haven't started anything.
Regards, Nick
I'd like to run this possible implementation past you, i have a working test, which if it's ok with you I'll fill out with the other events and then submit a patch, so here goes ...
First in document.c the addition of
g_signal_connect((GtkWidget*) doc_list[idx].sci, "sci-notify", G_CALLBACK(on_plugin_notification), GINT_TO_POINTER(idx));
on_plugin_notification is in editor.c and is a copy of on_editor_notifcation except each of the case's delegates to a plugin handler, for example ...
case SCN_CHARADDED: printf("getting notificaiton from sci\n"); plugins_on_char_added(idx, nt->ch); break;
plugins_on_char_added (and the other possible events) are defined in plugins.c like this
void plugins_on_char_added(gint idx,char ch) { GList *item;
ScintillaObject *sci = doc_list[idx].sci;
for (item = plugin_list; item != NULL; item = g_list_next(item)) { Plugin *plugin = item->data;
if (plugin->onCharAdded) { printf("trying to call my plugin \n"); plugin->onCharAdded(sci,ch); } } }
and that's about it, the module the Plugin struct is modified as per other events,
typedef struct Plugin { GModule *module; gchar *filename; // plugin filename (/path/libname.so) PluginFields fields;
PluginInfo* (*info) (); /* Returns plugin name, description */ void (*init) (GeanyData *data); /* Called when the plugin is enabled */ void (*cleanup) (); /* Called when the plugin is disabled or when Geany exits */ void (*onCharAdded)(ScintillaObject *sci,char c); } Plugin;
Is this approach acceptable? It seems to me the cleanest way to do it, and it seems to be working.
cheers
bd
On Tue, 31 Jul 2007 12:04:37 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
On 07/31/2007 03:31:05 AM, blackdog wrote:
Hang on, being a bit stupid here, I guess I could just hook into the Gtk event system with g_signal_connect, as I think you can have more than one event attached.
Sounds good, I haven't needed any callbacks so far, but in your example for autocompletion I guess this could work well.
On Mon, 30 Jul 2007 21:59:06 -0400 blackdog blackdog@ipowerhouse.com wrote:
With the advent of the plugin system i think it would be very
useful
if geany had a method of firing events for plugins. Right now I
have
implemented the sci_ functions in the plugin interface but of
course
this is one way traffic. [...]
Anyone been thinking along these lines? Similarly for key events
too.
No, I haven't started anything.
Regards, Nick
Geany mailing list Geany@uvena.de http://uvena.de/cgi-bin/mailman/listinfo/geany