Geany dev
Data Structures | Functions
pluginextension.h File Reference

This file defines an interface allowing plugins to take over some of the core functionality provided by Geany: autocompletion, calltips, symbol goto, and types highlighting inside document. More...

Data Structures

struct  PluginExtension
 Structure serving as an interface between plugins and Geany allowing plugins to inform Geany about what features they provide and allowing Geany to delegate its functionality to the plugins. More...
 

Functions

gboolean plugin_extension_autocomplete_provided (GeanyDocument *doc, PluginExtension *ext)
 Plugins can call this function to check whether, based on the extensions registered and the provided extension priorities, the extension passed in the ext parameter is used for autocompletion. More...
 
gboolean plugin_extension_calltips_provided (GeanyDocument *doc, PluginExtension *ext)
 Checks whether the provided extension is used for showing calltips. More...
 
gboolean plugin_extension_goto_provided (GeanyDocument *doc, PluginExtension *ext)
 Checks whether the provided extension is used for going to symbol definition/declaration. More...
 
void plugin_extension_register (PluginExtension *extension, const gchar *ext_name, gint priority, gpointer data)
 Registers the provided extension in Geany. More...
 
gboolean plugin_extension_symbol_highlight_provided (GeanyDocument *doc, PluginExtension *ext)
 Checks whether the provided extension is used for highlighting symbols in the document. More...
 
void plugin_extension_unregister (PluginExtension *extension)
 Plugins are responsible for calling this function when they no longer provide the extension, at the latest in the plugin's cleanup() function. More...
 

Detailed Description

This file defines an interface allowing plugins to take over some of the core functionality provided by Geany: autocompletion, calltips, symbol goto, and types highlighting inside document.

Function Documentation

◆ plugin_extension_autocomplete_provided()

gboolean plugin_extension_autocomplete_provided ( GeanyDocument doc,
PluginExtension ext 
)

Plugins can call this function to check whether, based on the extensions registered and the provided extension priorities, the extension passed in the ext parameter is used for autocompletion.

Plugins will typically call this function with their own PluginExtension to check, if they get (or got) executed for autocompletion of the provided document. This is useful for various auxiliary functions such as cleanups after the function assigned to autocomplete_perform is completed so plugins know they executed this function and do not have to store this information by some other means.

Parameters
docDocument for which the check is performed.
extThe extension for which the check is performed.
Returns
Returns TRUE if autocompletion provided by the passed extension is used, FALSE otherwise.
Since
2.1

◆ plugin_extension_calltips_provided()

gboolean plugin_extension_calltips_provided ( GeanyDocument doc,
PluginExtension ext 
)

Checks whether the provided extension is used for showing calltips.

See also
plugin_extension_autocomplete_provided()
Since
2.1

◆ plugin_extension_goto_provided()

gboolean plugin_extension_goto_provided ( GeanyDocument doc,
PluginExtension ext 
)

Checks whether the provided extension is used for going to symbol definition/declaration.

See also
plugin_extension_autocomplete_provided()
Since
2.1

◆ plugin_extension_register()

void plugin_extension_register ( PluginExtension extension,
const gchar *  ext_name,
gint  priority,
gpointer  data 
)

Registers the provided extension in Geany.

There can be multiple extensions registered in Geany - these are sorted by the priority parameter. When executing functions assigned to the PluginExtension members ending with _perform, Geany goes through the registered extensions and executes the _perform() function of the first extension for which the function assigned to the corresponding _provided member returns TRUE.

This function is typically called in the plugin's init() function.

Plugins wishing to re-register themselves, e.g. with a different priority, should first unregister themselves using plugin_extension_unregister() and call plugin_extension_register() afterwards.

Parameters
extensionA pointer to the PluginExtension structure to register. This pointer and the PluginExtension it points to have to remain valid until the extension is unregistered. All fields of the PluginExtension structure have to be fully initialized either to the NULL pointer or to a proper implementation. Usually, this structure is statically allocated which automatically zero-initializes uninitialized members as appropriate.
ext_nameHuman-readable name of the extension that can appear in the user interface. The string should be reasonably unique so extensions can be distinguished from each other.
priorityExtension priority. The recommended values are:
  • if the extension is the only thing the plugin provides, and if it targets a single filetype, use 400 <= priority < 500.
  • if the extension is the only thing the plugin provides, but it targets several filetypes, use 300 <= priority < 400.
  • if the plugin provides other features than the extension, but it only targets a single filetype, use 200 <= priority < 300.
  • if the plugin provides other features than the extension, and targets several filetypes, use 100 <= priority < 200.
  • a priority of 0 or less is reserved, and using it has unspecified behavior.
dataUser data passed to the functions from the PluginExtension struct.
Warning
Plugins are responsible for calling plugin_extension_unregister() when they no longer provide the extension and when the plugin is unloaded.
See also
plugin_extension_unregister().
Since
2.1

◆ plugin_extension_symbol_highlight_provided()

gboolean plugin_extension_symbol_highlight_provided ( GeanyDocument doc,
PluginExtension ext 
)

Checks whether the provided extension is used for highlighting symbols in the document.

See also
plugin_extension_autocomplete_provided()
Since
2.1

◆ plugin_extension_unregister()

void plugin_extension_unregister ( PluginExtension extension)

Plugins are responsible for calling this function when they no longer provide the extension, at the latest in the plugin's cleanup() function.

Parameters
extensionThe PluginExtension structure pointer to unregister, as previously registered with plugin_extension_register().
See also
plugin_extension_register().
Since
2.1