[Lazarus] IDE package interface question

Martin lazarus at mfriebe.de
Tue Jan 25 01:18:30 CET 2011


On 24/01/2011 23:51, Darius Blaszyk wrote:
> What I would like to do is to update a listview (in my package) after I click on the source editor. So I need to hook into the source editor's OnClick method and get the procedure/function name, line number and the file name. The last two items will probably be more easy, but what about the first? Is there an interface for the code tools that allows this? How about hooking into the OnClick method of the source editor?
>
Well first, you need to be aware, that SourceEditors (SynEdit), and 
SourceNotebook(s) ( the windows in which they are) can come and fo.

Your start-point is TSourceEditorManagerInterface in  
ideintf\srceditorintf.pas

     procedure RegisterChangeEvent(AReason: TsemChangeReason; AHandler: 
TNotifyEvent); virtual; abstract;
     procedure UnRegisterChangeEvent(AReason: TsemChangeReason; 
AHandler: TNotifyEvent); virtual; abstract;

To allow you keep track of them.

Be aware "semEditorStatus" will fire a hell lot. not the best Idea to 
use it. (it will fire on every caret move for example); unfortunately 
not on click (unless the click moves the caret, but that isn't always 
the case. => For status change, it is better to register with synedit 
direct, since you can give synedit a filter, and reduce the amount of 
calls, to what you need.

Since SynEdit's on click will already be hooked, that want be easy.... 
Actually, just seen it isn't; but it could any day.

You could register your own mouse action with SynEdit, but that's rather 
complex too.
It would be enough to register a proc with 
SynEdit.RegisterMouseActionSearchHandler, or 
TSynEditMouseActionExecProc. It would receive the mouse info, but could 
just do nothing (unless you want to abort the current action.
However:
- I am not 100% sure that will stay exactly as it is. e.g in user land 
synedit this may become an optional handler. in the IDE it is 99.99% 
likely to stay as it is.
- There is no grantee on the calling order, other handlers could return 
true first, and yours would not be called

--------------------
At this point I noticed your next post.

RegisterStatusChangedHandler in synedit => see what fpdoc edit does







More information about the Lazarus mailing list