[Geany-devel] Symbols access from plugins

Enrico Tröger enrico.troeger at xxxxx
Mon Mar 2 19:18:45 UTC 2009


On Sat, 28 Feb 2009 19:21:36 +0100, Colomban wrote:


Hey,

>Sorry for the latency, I was busy these last days.

Similar here :).


>>> Then, I have some questions: * Is it possible to get tags for the
>>> current function, or at least function's start line, from inside
>>> a plugin?
>>
>> Not directly. Without having tested, it should be possible to get
>> the tag list for a document by using the 'tm_file' field of the
>> GeanyDocument structure.
>>
>> GeanyDocument *doc; TMWorkObject *tm_wo = doc->tm_file; GPtrArray
>> *tags = tm_wo->tags_array;
>>
>> This should give you an array of TMTag objects for the current
>> file, then you can search this array for the corresponding TMTag
>> object of the desired line in the document or function name or
>> whatever. The above is untested but should work or at least should
>> suffice as a start to get it working :).
>Perfect, it works well :)
>But I need to update the tag list manually to generate correct
>documentation and insert it a the right place, but even if it can be
>found in the online API doc and in tm_source_file.[ch],
>tm_source_file_buffer_update() seems not usable from plugins (gets me

tm_source_file_buffer_update() is experimental to update the tags array
from the current buffer in Geany, i.e. the displayed text instead of
reading the file contents from a file. But this doesn't work at all yet
and so is disabled. Additionally, this is not part of the plugin API
and so you get an undefined symbol error. Simply ignore it.

Instead use tm_source_file_update() which should work ok but be aware
that it reads the contents from the file on disk, so when the document
in Geany has changes, you should save it first with document_save_file
(). And at this point, tm_source_file_update() is already called after
saving the document, so no need to call it manually.


>> The pointer to the submenu item you want can be retrieved with:
>>
>> ui_lookup_widget(geany->main_widgets->editor_menu, "comments");
>>
>> Don't forget to destroy the create menu item(s) in
>> plugin_cleanup().
>>
>> In case you want show/hide/update the menu item when the editor
>> menu is actually shown, you need to connect to the
>> "update-editor-menu" signal.
>Thanks again, it's exactly what I was searching for.
>But again, a question: how can I know the click position that popuped
>the menu (and perhaps if it was popuped by a click and not a keyboard
>shortcut) to be able to generate the doc for the function below
>pointer and not at current position in the buffer?

The position where the menu was popped up is given in the
"update-editor-menu" handler, check the 'pos' argument.

For key events, sci_get_current_position() should give you the correct
position.


Regards,
Enrico

-- 
Get my GPG key from http://www.uvena.de/pub.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20090302/176d97dc/attachment.pgp>


More information about the Devel mailing list