Recent

Author Topic: SynEdit Go to function  (Read 1299 times)

BIT

  • Full Member
  • ***
  • Posts: 158
SynEdit Go to function
« on: September 21, 2021, 06:53:21 pm »
Hello!
Please tell me the implementation of such a function as in Lazarus Ctrl + Click and go to the function (in SynEdit).

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit Go to function
« Reply #1 on: September 21, 2021, 07:43:39 pm »
Look at the package "codetools".
It parses all the Pascal sources, and finds the location of the function under the cursor.

SynEdit only provides the WordAtCaret.

Either the unit ide/SourceEditor.pp or ide/main.pp  have code to get link it all together. I.e. getting the current word from SynEdit, calling codetools to get the x/y pos, and then setting SynEdit to that x/y.

Search in SynEdit for "emcMouseLink", then search the code that hooks the events that are triggered (in main or sourceediter)

« Last Edit: September 21, 2021, 07:53:15 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit Go to function
« Reply #2 on: September 21, 2021, 07:47:18 pm »
If you just want to do your own jump, and want to know how to get SynEdit to underline keywords under the mouse when ctrl is hold down.

This is done by unit SynEditMarkupCtrlMouseLink

The instance of TSynEditMarkupCtrlMouseLink can be accessed using
Code: Pascal  [Select][+][-]
  1. TSynEditMarkupCtrlMouseLink(SynEdit.MarkupByClass[TSynEditMarkupCtrlMouseLink])

Search for fMarkupCtrlMouse, emShowCtrlMouseLinks in SynEdit.

This only does the underline. To capture the click, you can hook OnMouse events, or add "MouseActions"


In any case this leaves it entirely to you, to decide where to jump to. (or whatever else to do)
« Last Edit: September 21, 2021, 07:51:19 pm by Martin_fr »

BIT

  • Full Member
  • ***
  • Posts: 158
Re: SynEdit Go to function
« Reply #3 on: September 21, 2021, 08:06:28 pm »
If you just want to do your own jump, and want to know how to get SynEdit to underline keywords under the mouse when ctrl is hold down.

This is done by unit SynEditMarkupCtrlMouseLink

The instance of TSynEditMarkupCtrlMouseLink can be accessed using
Code: Pascal  [Select][+][-]
  1. TSynEditMarkupCtrlMouseLink(SynEdit.MarkupByClass[TSynEditMarkupCtrlMouseLink])

Search for fMarkupCtrlMouse, emShowCtrlMouseLinks in SynEdit.

This only does the underline. To capture the click, you can hook OnMouse events, or add "MouseActions"


In any case this leaves it entirely to you, to decide where to jump to. (or whatever else to do)

Thanks for the answer!
I did the interception of clicking on the link.
I'm more interested in how to implement a function search in other modules.
My assumptions are that lazarus stores references separately to functions, since it calls them instantly.

codetools doesn't fit i am writing editor for c ++
« Last Edit: September 21, 2021, 08:10:30 pm by BIT »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit Go to function
« Reply #4 on: September 21, 2021, 08:19:04 pm »
The searching is done in codetools.

I don't know that package in depth myself.
Afaik it is a mix of scanning on demand, and accessing stored info from previous scans.

BIT

  • Full Member
  • ***
  • Posts: 158
Re: SynEdit Go to function
« Reply #5 on: September 21, 2021, 08:22:21 pm »
The searching is done in codetools.

I don't know that package in depth myself.
Afaik it is a mix of scanning on demand, and accessing stored info from previous scans.
Well, maybe someone came across this, I'll wait for an answer

 

TinyPortal © 2005-2018