Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2024-08

Getting notified when active editor changes

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hi,

I'm trying to improve the "file browser" plugin.

I would like to keep it in sync with the currently active editor: In the file/directory tree, always select the directory/file of the currently active editor. (if it is in the tree, of course)

For this to work I need to be notified when the uses starts editing another file - i.e. changes to another source editor.

I have found in LazaIDEintf lots of event handlers, but it seems there is no event for when the user switches source editors.

I could work with a timer and examine the currently active editor, but that seems a bit hackish.

Did I miss such an event handler ?
If no such event exists, could it be added ?

Michael.

Reply by email

Martin Frb
to Michael Van Canneyt
Michael Van Canneyt wrote 9 lines
Hi, I'm trying to improve the "file browser" plugin. I would like to keep it in sync with the currently active editor: In the file/directory tree, always select the directory/file of the currently active editor. (if it is in the tree, of course)
unit SrcEditorIntf;

? TSemChangeReason = (
??? semEditorActivate,? // Editor is ActiveEditor

not sure you may additionally need to watch for new created....

Reply by email

Michael Van Canneyt
to Martin Frb
Martin Frb wrote 15 lines
On 03/08/2024 10:41, Michael Van Canneyt via lazarus wrote: > > Hi, > > I'm trying to improve the "file browser" plugin. > > I would like to keep it in sync with the currently active editor: > In the file/directory tree, always select the directory/file of the > currently > active editor. (if it is in the tree, of course) unit SrcEditorIntf; ? TSemChangeReason = ( ??? semEditorActivate,? // Editor is ActiveEditor

Thanks, that is just what I needed.

not sure you may additionally need to watch for new created....

Better not, since it does not yet have a filename, so nothing to show yet.

I implemented an initial version of this new feature, I pushed it to the git repo.

Thanks for the tip...

Michael.

Reply by email

Ondrej Pokorny
to Michael Van Canneyt
Michael Van Canneyt wrote
I implemented an initial version of this new feature, I pushed it to the git repo.

I always wanted to do this for the project inspector. So I used your approach as an inspiration :)

I also found out that LazarusIDE.RemoveAllHandlersOfObject doesn't remove the SourceEditorManagerIntf events. I fixed that in your code.

Ondrej

Reply by email

Michael Van Canneyt
to Ondrej Pokorny
Ondrej Pokorny wrote 6 lines
On 03.08.2024 15:11, Michael Van Canneyt via lazarus wrote: > I implemented an initial version of this new feature, I pushed it to the > git repo. I always wanted to do this for the project inspector. So I used your approach as an inspiration :)

I updated my lazarus, works well! :-)

I also found out that LazarusIDE.RemoveAllHandlersOfObject doesn't remove the SourceEditorManagerIntf events. I fixed that in your code.

Ah, good to know. Thanks for fixing it !

Michael.

Reply by email