Sign in Join

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

Mailing lists / lazarus / 2010-07

Code Explorer synchronized with caret position

11 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

theo

Wouldn't it be useful, if the code explorer had a mode to highlight/expand the node which corresponds the current caret-position in the source editor? At least in mode "Refresh on Idle" / "Source View". Or is there such an option and I just could not find it?

For me, this would be more useful than code-folding.
- You would know where you are. ;-)
- You could see neighbour methods, which are probably related with the current method.
- You could see parameters (even if header not visible due to scrolling).
- You could see var sections (even if var section not visible due to scrolling).

Has this been discussed before? Was it rejected for a reason? Am I right, that the prerequisites for this feature are already there?

Thank you
Best regards
Theo

Reply by email

Mattias Gaertner
to theo
Wouldn't it be useful, if the code explorer had a mode to highlight/expand the node which corresponds the current caret-position in the source editor? At least in mode "Refresh on Idle" / "Source View". Or is there such an option and I just could not find it?

There is no such option.

Show quoted text 10 lines
For me, this would be more useful than code-folding. - You would know where you are. ;-) - You could see neighbour methods, which are probably related with the current method. - You could see parameters (even if header not visible due to scrolling). - You could see var sections (even if var section not visible due to scrolling). Has this been discussed before?

Yes.

Was it rejected for a reason?

No.

Am I right, that the prerequisites for this feature are already there?

Yes.

Mattias

Reply by email

theo
to Mattias Gaertner

Thanks Mattias

>/ Am I right, that the prerequisites for this feature are already there?

/

Yes.

Hmm, I thought it would be relatively easy.
I don't know anything about code explorer, but tried this:

In CodeExplorer.pas:

To get some event, I started here:
procedure TCodeExplorerView.Refresh(OnlyVisible: boolean);

There I'm calling "SelectSourceEditorNode" which looks as if it would do what I intend.
Btw. This method is never called throughout the Project afaics.

This one is calling "SelectCodePosition" which is calling "FindCodeTVNodeAtCleanPos"

It passes all checks, but in the last method, this code:
  AVLNode:=fCodeSortedForStartPos.FindLeftMostKey(@KeyPos,
TListSortCompare(@CompareStartPosWithViewNodeData));

returns always nil for AVLNode.

Thank you for any comment.

Best regards
Theo

Reply by email

Hans-Peter Diettrich
to theo: Wouldn't it be useful, if the code explorer had a mode to highlight/expand the node which…
Wouldn't it be useful, if the code explorer had a mode to highlight/expand the node which corresponds the current caret-position in the source editor? At least in mode "Refresh on Idle" / "Source View".

IMO the code explorer should work (primarily) in the opposite direction, as a map from which one can go to the according item in the unit.

Or is there such an option and I just could not find it?

I'd like an extension to the editor statusbar, where the full unit filename is shown - why not append the current procedure or type name there?

Show quoted text 7 lines
For me, this would be more useful than code-folding. - You would know where you are. ;-) - You could see neighbour methods, which are probably related with the current method. - You could see parameters (even if header not visible due to scrolling). - You could see var sections (even if var section not visible due to scrolling).

IMO such features can become add-ons, which the user can show and dock into his preferred position.

Has this been discussed before? Was it rejected for a reason?

There exist wishes for an splitted editor view, with the declaration (or interface) part in one pane, and the implementation in another one. I liked that splitted view in VB3 much, 15 years ago, but nowadays I'm not so sure.

Am I right, that the prerequisites for this feature are already there?

Not really, I fear, but it should be possible to add the required methods or notifications to the tool interface. The most important extension already is in the IDE - multiple independent views of the same unit. What's missing is a relationship between editors and other windows (Code Explorer...), so that *every* editor window can have its own set of such related (docked) windows (as in older Delphi versions). It would solve a problem in the current docked layouts, where the visibility (top) and focus of e.g. the Messages window and the related editor file causes some headaches.

DoDi

Reply by email

theo
to Hans-Peter Diettrich

@Dodi: Not sure if we're talking about the same thing.

I wanted a relatively non-intrusive feature, which is selecting the item in code explorer which corresponds to the current caret-position-context in the source editor.
Nothing more.
I was, and still am, under the impression, that method "SelectSourceEditorNode" is doing just this (probably not expanding). Somebody please tell me if this is a wrong assumption.

Thank you.
Theo

Reply by email

Martin
to theo: Thanks Mattias / Hmm, I thought it would be relatively easy. I don't know anything about…
theo wrote
There I'm calling "SelectSourceEditorNode" which looks as if it would do what I intend. Btw. This method is never called throughout the Project afaics.

I don't know about that.

But in order to hook the changes to the caret etc => gets a notification via sourceEditorIntf. In this notification you must be very very fast (so you can not use codetool to look up the current procedure => you can merely use it to set a flag, and then act OnIdle

Reply by email

theo
to Martin

Thank you Martin.

But I think this is not the problem. The invervals I get in procedure TCodeExplorerView.Refresh(OnlyVisible: boolean); seem just right.

Mattias answered yes, when I asked him if //the prerequisites for this feature are already there.
I hope he did not mean that we have a turing-complete system ;-)

I understood his answer as: Yes, the methods are there, just combine them to do something useful.
That's why I am waiting for an answer from Mattias, to understand how deep I have to dig.

Best regards
Theo

//

Reply by email

Mattias Gaertner
to theo
Show quoted text 14 lines
Thank you Martin. But I think this is not the problem. The invervals I get in procedure TCodeExplorerView.Refresh(OnlyVisible: boolean); seem just right. Mattias answered yes, when I asked him if //the prerequisites for this feature are already there. I hope he did not mean that we have a turing-complete system ;-) I understood his answer as: Yes, the methods are there, just combine them to do something useful. That's why I am waiting for an answer from Mattias, to understand how deep I have to dig.

I will take a look.

Mattias

Reply by email

Mattias Gaertner
to theo: Thank you Martin. But I think this is not the problem. The invervals I get in procedure…
Show quoted text 14 lines
Thank you Martin. But I think this is not the problem. The invervals I get in procedure TCodeExplorerView.Refresh(OnlyVisible: boolean); seem just right. Mattias answered yes, when I asked him if //the prerequisites for this feature are already there. I hope he did not mean that we have a turing-complete system ;-) I understood his answer as: Yes, the methods are there, just combine them to do something useful. That's why I am waiting for an answer from Mattias, to understand how deep I have to dig.

I implemented a simple follow cursor.

Keep in mind, that the tree does not contain all nodes, especially not duplicates.

To turn it off:
see 'Follow Cursor' option in code explorer.

Mattias

Reply by email