Recent

Author Topic: [SOLVED] Highlighting of custom words  (Read 6201 times)

Hi im Pascal

  • Jr. Member
  • **
  • Posts: 53
[SOLVED] Highlighting of custom words
« on: May 28, 2021, 11:55:08 pm »
Hi all,

1. Do you also consider it a bug that certain reserved words and pre-defined identifiers are not highlighted as reserved (e.g., true, false, integer, break, ...)?
--> I think I could fix that via code contribution to Lazarus IDE, is it feasible for someone good at programming, but maybe not familiar with the project?

2. Do you also consider it a bug that user defined markup is highlighted within comments as well? E.g., if I add "break" to highlight and type "break" inside a source code comment, it will still be highlighted.
--> I think I could also fix that bug via code contribution to Lazarus IDE, see question 1.

Thanks.
« Last Edit: May 29, 2021, 02:28:44 pm by Hi im Pascal »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Highlighting of custom words
« Reply #1 on: May 29, 2021, 12:46:27 am »
1. Do you also consider it a bug that certain reserved words and pre-defined identifiers are not highlighted as reserved (e.g., true, false, integer, break, ...)?
It's not exactly a bug since those are not reserved; whether predefined or not, they are "normal" identifiers. You can even do:
Code: Pascal  [Select][+][-]
  1. var
  2.   break: Integer = 123;
  3.   Integer: String = 'Wow!';
  4.   True, False: LongInt;
and the compiler will happily accept it.

Quote
2. Do you also consider it a bug that user defined markup is highlighted within comments as well?
Not really either: the IDE has no way to know when and where should or shouldn't highlight it, but since you did tell it to highlight ... ;)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Hi im Pascal

  • Jr. Member
  • **
  • Posts: 53
Re: Highlighting of custom words
« Reply #2 on: May 29, 2021, 01:32:34 am »
But then why does
Code: [Select]
// procedure
not highlight "procedure", it seems inconsistent.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Highlighting of custom words
« Reply #3 on: May 29, 2021, 03:07:06 am »
But then why does
Code: [Select]
// procedure
not highlight "procedure", it seems inconsistent.

No, because "procedure" is a special, reserved word, so the IDE knows it shouldn't be highlighted if inside a comment.

It's really a question of highlighting priorities, kind of, where the "comment" attributes supercede those of most other kind except user-defined ones and, IIRC, some other. I think there is some way to change that but I don't remember ATM how or, TBH, if it can be done.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10549
  • Debugger - SynEdit - and more
    • wiki
Re: Highlighting of custom words
« Reply #4 on: May 29, 2021, 12:17:40 pm »
Quote
2. Do you also consider it a bug that user defined markup is highlighted within comments as well?
Not really either: the IDE has no way to know when and where should or shouldn't highlight it, but since you did tell it to highlight ... ;)

And that is were highlight priorities come in. It does not solve everything but makes thinks a lot better...
I assume your user defined color for true/false is foreground color only. Otherwise below applies to any other setting too (background/frame/style)

In your normal color setting edit comments and strings.
- Make sore they have a color set (foreground will be/ but if you need others / see above)
- Edit the priority for the foreground, so it is above zero (maybe to 50)

Then go to user defined
- Edit the priority for the foreground to 1.

Now the foreground color of the comment will hide your user defined color.


-------------
If you use "frames" you must set up a frame with the background color in the normal colors. No frame has no priority....

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10549
  • Debugger - SynEdit - and more
    • wiki
Re: Highlighting of custom words
« Reply #5 on: May 29, 2021, 12:21:01 pm »
But then why does
Code: [Select]
// procedure
not highlight "procedure", it seems inconsistent.

procedure is a keyword. The highlighter knows that. The highlighter also knows what a comment is.

User defined colors, are not keywords. They can be anything.
I could add my name into user defined colors, so I will spot if it appears anywhere in the source (comment, string, anywhere)...

I have user defined colors with a key to toggle them to any word. I use that to highlight variable names (when I refactor, so I can spot them).
If those appear in comment, I want to see them there too.

Hi im Pascal

  • Jr. Member
  • **
  • Posts: 53
Re: Highlighting of custom words
« Reply #6 on: May 29, 2021, 02:28:34 pm »
O.k. thanks all for explaining it, I understand the philosophy behind it, and that it's not a bug but intended behavior.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10549
  • Debugger - SynEdit - and more
    • wiki
Re: Highlighting of custom words
« Reply #7 on: May 29, 2021, 02:50:26 pm »
O.k. thanks all for explaining it, I understand the philosophy behind it, and that it's not a bug but intended behavior.
You can still get what you want, by using priorities. You did see that?

Hi im Pascal

  • Jr. Member
  • **
  • Posts: 53
Re: Highlighting of custom words
« Reply #8 on: June 03, 2021, 08:54:28 pm »
O.k. thanks all for explaining it, I understand the philosophy behind it, and that it's not a bug but intended behavior.
You can still get what you want, by using priorities. You did see that?

To be frank I wasn't quite adept enough to specifically figure out how to set the Foreground priority for "ObjectPascal::Comment" item (even though it probably was said somewhere in this thread, I couldn't decode the explicit steps to perform)^^

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10549
  • Debugger - SynEdit - and more
    • wiki
Re: Highlighting of custom words
« Reply #9 on: June 03, 2021, 09:07:04 pm »
To be frank I wasn't quite adept enough to specifically figure out how to set the Foreground priority for "ObjectPascal::Comment" item (even though it probably was said somewhere in this thread, I couldn't decode the explicit steps to perform)^^

Ok.
Menu > Tools > Options
Page > Editor > Display > Colors

At the bottom of the page  (below the section "element attributes" is a toolbar. It has 3 buttons:
"Colors", "Priorities", "reset"

Click "Priorities".

In the treeview (left to the preview) where all colors are listed, select "comment"
=> that will also select "comment" in the "priority" listings.

Now for the foreground priority, you can change the value to:  2

-----
There is no entry in "background priority". This only appears if you set a background color.
But if your user-defined color does not have background, then you do not need that here either.

------------
Don't forget to go to your user defined color, and set its prior down to   1

----
repeat for: string color




Hi im Pascal

  • Jr. Member
  • **
  • Posts: 53
Re: [SOLVED] Highlighting of custom words
« Reply #10 on: March 30, 2024, 11:39:10 pm »
Sorry for no / late response, but I'm able to reproduce this, thank you!

 

TinyPortal © 2005-2018