[Geany-Devel] Plugin development questions

Thomas Martitz thomas.martitz at xxxxx
Mon Oct 7 20:06:45 UTC 2013

Am 07.10.2013 21:53, schrieb Thomas Martitz:
> Am 07.10.2013 12:27, schrieb v01d:
>> Hi,
>> I'm writing a simple plugin for geany (which I will call LiveDiff)
>> which allows for having
>> indicators inside the editor for changed/added/modified lines, which
>> is updated as you type. The base for comparing
>> the buffer can be either the version of the file on disk or (which I
>> will soon attempt to add) the latest version from the git repository,
>> if the file is versioned so.
>> This resembles what netbeans does (one something I really liked). So
>> far it works OK but there are some quirks.
>> I'm doing this out of spare time so dont expect a pretty serious
>> commitement to it. I will however make it available on github.
>> I wanted to ask regarding the ScitillaObject handling. Currently my
>> plugin needs to define RGBA markers (which are used to indicate the
>> diff results per-line).
>> What it is not really clear to me is that there appears to be one
>> ScintillaObject associated with each GeanyDocument. However, some
>> messages sent to the ScintillaObject (like changing the margin or
>> defining markers) appear to be global across all instances (unless I'm
>> mistaken). Is this so? What would be the proper handling? Is it ok to
>> repeat the definition of the markers for each editor?
>> Moreover, I'm not sure how to handle correctly the size of the RGBA
>> markers since it depends on the font size of the editor. I tried to
>> set the marker scale using the text_height to image height ratio, but
>> the marker still appears to be a bit taller than the line and this
>> creates some visual artifacts.
> Hello,
> [1] might be of interest for you. It does something very similar.
> Regarding your other question, are you talking about the 
> "editor-notify" signal? Yes, that's not really per-document, I came 
> across this recently. The solution is to connect to "sci-notify" of 
> ScintillaObject directly, this will give a proper per-document signal 
> (the document-specific ScintillaObject pointer). However you need to 
> get the GeanyDocument pointer elsewhere. See how I did it here[2].
> Some might consider this as a defect in Geany.
> [1]: http://lists.geany.org/pipermail/devel/2010-June/002584.html
> [2]: 
> https://github.com/kugel-/geany-plugins/commit/7f19c3035abf6f8a7fa66c7b4c1efe0851cb2f83

I need to correct myself. "editor-notify" is correctly per-document and 
you can get the GeanyDocument pointer via the GeanyEditor pointer passed 
to it. What I meant to say is that you cannot use "editor-notify" if you 
need to attach user_data on a per-document basis. The user_data pointer 
passed to plugin_signal_connect("editor-notify", ...) will be 
overwritten on each successive all. My suggested workaround works for 
this case. With sci-notify you can attach user_data on a per-document basis.

Best regards.

More information about the Devel mailing list