Recent

Author Topic: Hint and warnings  (Read 386 times)

Okoba

  • Sr. Member
  • ****
  • Posts: 312
Hint and warnings
« on: March 17, 2022, 07:20:43 pm »
Hello,

Can you tell me where exactly, Lazarus sets the style for warnings and hints? I tried to find them in Pascal Highlighter but I couldn't and the warnings became apparent after FPC compiles the code.
I like to try to add custom highlighting eg when hitting a shortcut, but not always.
« Last Edit: March 17, 2022, 07:31:51 pm by Okoba »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8260
  • Debugger - SynEdit - and more
    • wiki
Re: Hint and warnings
« Reply #1 on: March 17, 2022, 08:03:28 pm »
Can you tell me where exactly, Lazarus sets the style for warnings and hints? I tried to find them in Pascal Highlighter but I couldn't
You mean the color of the zigzag underline?

Not sure, but I believe it's hardcoded. Maybe at  ide\etsrceditmarks.pas line 1064 (not tested, but it looks like it could be...>)
Code: Pascal  [Select][+][-]
  1. constructor TETMarks.Create(AOwner: TComponent);
  2. const
  3.   DefMarkColorHint = TColor($00a5ff);
  4.   DefMarkColorError = clRed;

the warnings became apparent after FPC compiles the code.
Indeed. The warnings a generated by the fpc compiler.
You would get the same warnings, if you compiled your code outside of the Lazarus IDE. You would just get them as text.

The IDE only displays them. So you need to compile to get them.

You can go into "Project Options" to disable/enable individual warnings.

I like to try to add custom highlighting eg when hitting a shortcut, but not always.
Not sure what you mean?

But maybe this will help: Tools > Options > Editor > Display > User defined markup
See the attached image.

You can enter text that you want to be colored (including borders, underline, ...).

The example shows a "then" followed by a ";".  If the conditional code would be on the next line, the semicolon would prevent it from being part of the "if".
- It is not a pattern. So I have the "then ;" with no space, 1, 2 or 3 spaces.
- It has no context. So it only works for very basic cases.


"User defined markup" can be toggled by keyboard. (add/remove word/terms/phrashes)

But not on a single word in just one location. => It always highlights *all* matches in the entire editor (or in all editors).
« Last Edit: March 17, 2022, 08:08:08 pm by Martin_fr »

Okoba

  • Sr. Member
  • ****
  • Posts: 312
Re: Hint and warnings
« Reply #2 on: March 17, 2022, 08:12:41 pm »
Thank you Martin!

Yes, I mean those warnings. User defined markup is interesting too.
But I would like to find out how Lazarus add style liek the warnigns, to the SynEdit. So I can add my own custom styling to the IDE by hitting a shortcut, for example, highlighting all the matches of a search, or a spell checker.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8260
  • Debugger - SynEdit - and more
    • wiki
Re: Hint and warnings
« Reply #3 on: March 17, 2022, 08:35:40 pm »
But I would like to find out how Lazarus add style liek the warnigns, to the SynEdit. So I can add my own custom styling to the IDE

TSynEditMarkup

SynEdit has 2 (or 3) ways of highlighting:

1) Highlighter: Anything based on the language.

2) Markup (TSynEditMarkup): Any other colors. https://wiki.lazarus.freepascal.org/SynEdit_Markup

3) Well kind of, as a side-effect: TSynEditStrings / TLazSynDisplayView.GetNextHighlighterToken


Markup is used for the "User defined markup", the "block outline" (vertical lines for begin/end), Markup word under caret, and even painting the selected text in blue.

It can apply any visible attribute (fore/back/frame-color, bold, italics, underline) to any text it chooses. How text is chosen is entirely down to the code in the Markup (so you probably need to write your own, or look through existing ones, if you can re-use).


TSynEditStrings / TLazSynDisplayView.GetNextHighlighterToken

This is more about getting the text that should be painted => like skipping folded lines. Or getting the "[...]" at the end of a "fold begin" line. But it passes through color/markup info. So in theory it can modify it. But for what you describe, this would be the wrong choice.

Okoba

  • Sr. Member
  • ****
  • Posts: 312
Re: Hint and warnings
« Reply #4 on: March 17, 2022, 08:45:55 pm »
Thank you for the clarification.
So I need to upgrade TETMarks, or somehow add another to for example highlight the wrong words I found with the spell checker.

 

TinyPortal © 2005-2018