Recent

Author Topic: Can the caret color be changed in the text editor ?  (Read 5838 times)

440bx

  • Hero Member
  • *****
  • Posts: 3946
Can the caret color be changed in the text editor ?
« on: July 28, 2018, 05:24:37 am »
Hello,

After customizing the colors in the editor, the caret has a tendency to "blend in" making it easy to get lost.

I'd like to set the caret to bright red.  Is it possible to change the caret's color (currently white I guess) to a different color ?

Thank you for your help.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Can the caret color be changed in the text editor ?
« Reply #1 on: July 28, 2018, 11:05:03 am »
There currently is no option.

There is a hack... http://forum.lazarus-ide.org/index.php/topic,38755.0.html
But that only works in 1.8.x.
That will NOT work in 1.10 or up

In 1.10 it is more work, you need to go through synedit and change the caret class.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: Can the caret color be changed in the text editor ?
« Reply #2 on: July 28, 2018, 04:49:38 pm »
Thank you Martin,  I like the precision in your answers :)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Can the caret color be changed in the text editor ?
« Reply #3 on: July 28, 2018, 08:07:22 pm »
I added an option in svn.

However it may slightly differ from what you expect. The Caret is drawn by Xor (actually NotXor). That means the caret color depends on the background color.
A caret at a selection for example will be half in front of the selection, and half on unselected text. Thus it will have 2 colors.

This behaviour is kept. (you also may need that, if you are on a breakpoint line, that has a different background color.)

You can now set the color for the primary caret, and the color for any 2ndary caret (multi caret mode). If you choose red (rgb #ff0000) then the current background will be bitwise xored with this, and then negated (bitwise not).

So on a white background you will get the color. On a black background you need to set #00ffff to get red.

The background is not necessarily the global background color of the editor, it may be the background color of the current line, the selection, or any other highlight that happens to be there.

-------------------
Note: As soon as you use colors (as well as when multicaret is active) the editor draws its own caret, rather than letting the system do this.
This means there may be differences in how the caret displays.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: Can the caret color be changed in the text editor ?
« Reply #4 on: July 28, 2018, 08:16:04 pm »
That is excellent.  Thank you Martin.  I will make it a point to try it as soon as I can.

I'm still learning the "personalities" of FPC and Lazarus.  Once I get my knowledge of them to a reasonable level, I'll go into compiling and using the trunk versions.  I'm looking forward to getting there.

Who knows, someday I might be able to make a contribution...  :D
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018