Le 29/08/2016 à 02:47, Matthew Brush a écrit :
[…]
To give an idea, the registration function called by plugins might look something like this:
gboolean ftplugin_register_provider(GeanyPlugin*, GeanyFiletypeID, GeanyFiletypeFeature, GCallback, gpointer);
Maybe we could simply use GSignals? Something like
geany_object_signals[GCB_EDITOR_AUTOCOMPLETE] = g_signal_new ( "autocomplete", G_OBJECT_CLASS_TYPE (g_object_class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION | G_SIGNAL_DETAILED /* filetype */, 0, boolean_handled_accumulator, NULL, NULL, G_TYPE_BOOLEAN, 3, GEANY_TYPE_EDITOR, G_TYPE_INT /* position */, G_TYPE_STRING /* stem */);
Plugins wanting to provide completion connect to it:
plugin_signal_connect(plugin, NULL, "autocomplete::C++", handler, ...)
and return TRUE if they handled it, FALSE otherwise.
In the handler, they would call something like:
void editor_show_autocomplete(GeanyEditor *editor, gint pos, GPtrArray/*<TMTag>*/ items);
Additionally, an API like `editor_emit_autocomplete(GeanyEditor, gint pos)` might be useful so a plugin can trigger autocompletion in more situations.
Just a though, and seeing some of the questions raised further down might suggest it's not flexible enough, but using the GSignal mechanism we already have at hand seemed like at least a good idea to consider.
Colomban