Recent

Author Topic: bug of SourceEditorManagerIntf.GetHighlighterSettings  (Read 1511 times)

Guva

  • Jr. Member
  • **
  • Posts: 82
bug of SourceEditorManagerIntf.GetHighlighterSettings
« on: January 27, 2021, 06:04:24 pm »
Hello everyone. faced syntax highlighting problem when using TsynPasSyn component.

For example, if you use:
SourceEditorManagerIntf.GetEditorControlSettings (FCodeText);
SourceEditorManagerIntf.GetHighlighterSettings (SynCPP);
then everything works as it should.
But if you use TsynPasSyn then neither GetEditorControlSettings nor GetHighlighterSettings work.
Can anyone come across this and is there a solution?

reproducing the error
https://youtu.be/VeqASvj6IzE

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9795
  • Debugger - SynEdit - and more
    • wiki
Re: bug of SourceEditorManagerIntf.GetHighlighterSettings
« Reply #1 on: January 27, 2021, 07:33:00 pm »
How/where is the variable "SynPas" created?


Is the code you use public? Where can it be downloaded?

Or do you have a complete example, that can reproduce the issue?

Guva

  • Jr. Member
  • **
  • Posts: 82
Re: bug of SourceEditorManagerIntf.GetHighlighterSettings
« Reply #2 on: January 27, 2021, 07:40:33 pm »
How/where is the variable "SynPas" created?


Is the code you use public? Where can it be downloaded?

Or do you have a complete example, that can reproduce the issue?
https://github.com/GuvaCode/Code-Librarian

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9795
  • Debugger - SynEdit - and more
    • wiki
Re: bug of SourceEditorManagerIntf.GetHighlighterSettings
« Reply #3 on: January 27, 2021, 09:02:21 pm »
I found the problem. But I do not yet have a solution.

GetHighlighterSettings expects a highlighter of the following class for Pascal:
TIDESynFreePasSyn
TIDESynPasSyn

But both of those classes are defined in the IDE code. So your code cannot access them. (Defining your own will not work, it is not the name. It is the exact type).

Not sure yet how much work it will be to fix that. More later.....


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9795
  • Debugger - SynEdit - and more
    • wiki
Re: bug of SourceEditorManagerIntf.GetHighlighterSettings
« Reply #4 on: January 27, 2021, 09:23:42 pm »
Btw, if I select "code librarian" from menu, the window is created partly out of the screen.

This seems to be caused by poMainFormCenter

The main form is the IDE-main-bar (with the menu, and component palette). I don't use anchordocking, and my ide-main-bar is on the top of the screen. Since your form's height is bigger that that of the IDE-main-bar, the code move the new top of your form to be higher than that of the ide-main-bar => and that new top is outside the screen.

---
I have no idea if the current LCL behaviour is any good as it is (or if it should be improved). => new different topic. 

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9795
  • Debugger - SynEdit - and more
    • wiki
Re: bug of SourceEditorManagerIntf.GetHighlighterSettings
« Reply #5 on: January 27, 2021, 10:08:02 pm »
OK, I committed a "fix"....

https://github.com/User4martin/lazarus/commit/6ea4b2d11331b0b96e1abb99bebaf33ea1cfde9e
https://github.com/User4martin/lazarus/commit/6ea4b2d11331b0b96e1abb99bebaf33ea1cfde9e.diff

Code: Pascal  [Select][+][-]
  1. uses IDEOptEditorIntf, EditorSyntaxHighlighterDef;
  2. ...
  3. var SynPas: TSynCustomHighlighter;
  4. begin
  5.   SynPas := TSynCustomHighlighter(IDEEditorOptions.CreateSynHighlighter(lshFreePascal));

That means you cannot create the highlighter as component on the form. You have to create it in your code.

Currently lshFreePascal returns a sub-class of TSynPasSyn.
However, that is not guaranteed. All you can trust is that it is a TSynCustomHighlighter.

CreateSynHighlighter will also apply the current settings.

CreateSynHighlighter returns TObject. But that is only because I did not want IdeIntf to depend on SynEdit.


 

TinyPortal © 2005-2018