[Geany] Plugin Events Patch
Nick Treleaven
nick.treleaven at xxxxx
Wed Aug 1 16:37:19 UTC 2007
On 08/01/2007 05:18:22 PM, blackdog wrote:
>
> Hi Nick
>
> Houw about this called from editor.c as per your last email? Haven't
> compiled it. So all the other events get their own if statement in
> there or somesuch.
>
No, I mean to save maintenance and a lot of possible symbols to lookup
each time a plugin is loaded, just have one symbol, on_sci_notify(). It
is passed the SCNotification argument whenever on_editor_notification()
receives a notification in editor.c, so it can determine which messages
it wants to respond to. This would save a lot of extra code in the
plugin API.
---
> // callback func called by all editors when a signal arises
> void on_plugin_notification(GtkWidget *editor, gint scn,struct
> SCNotification *nt, gint idx) {
> GList *item;
>
> ScintillaObject *sci = doc_list[idx].sci;
> int event = nt->nmhdr.code;
> for (item = plugin_list; item != NULL; item =
> g_list_next(item))
> {
> Plugin *plugin = item->data;
>
> if (plugin->on_char_added && event == SCN_CHARADDED) {
> plugin->on_char_added(sci,ch);
> }
> }
> }
>
>
> bd
>
> On Wed, 01 Aug 2007 16:28:39 +0100
> Nick Treleaven <nick.treleaven at btinternet.com> wrote:
>
> > On 08/01/2007 02:38:53 PM, blackdog wrote:
> > >
> > > Hi there
> > >
> > > So here's a patch tested against r 1767 which adds a single
> > > onCharAdded
> > > event for plugins that implement onCharAdded().
> > >
> > > This is experimental and is really for you to comment on, if it's
> ok
> > > by
> > > you I'll add the other events.
> > >
> > Thanks, but IMO it could be done a bit differently. (I didn't have
> > time to reply to your previous message about this, sorry).
> >
> > I would prefer it to be done in a way that had less changes to the
> > core
> > - really I think the plugin API should be kept quite lean. Because
> I
>
> > think you might want other callbacks besides onCharAdded, perhaps
> it
>
> > would be best to have a single on_sci_notify() plugin callback (we
> > don't really use CamelCase for function names, only typenames ;-)).
> >
> > Then something like:
> >
> > // callback func called by all editors when a signal arises
> > void on_editor_notification(GtkWidget *editor, gint scn, gpointer
> > lscn, gpointer user_data)
> > {
> > SCNotification *nt;
> > ScintillaObject *sci;
> > gint idx;
> >
> > idx = GPOINTER_TO_INT(user_data);
> > sci = doc_list[idx].sci;
> >
> > nt = lscn;
> >
> > plugins_sci_notify(editor, scn, nt, idx);
> >
> > Where plugins_sci_notify() calls any plugin that has an
> on_sci_notify
> > symbol.
> >
> > Also, I'm assuming that this notification doesn't slow down Geany
> (I
>
> > guess it shouldn't though). I'm also wondering about replacing
> > plugin_list GList with a GPtrArray, which could speed up things if
> > necessary.
> >
Regards,
Nick
More information about the Users
mailing list