Author Topic: sLineBreak / chr(13) + chr(10) / markup  (Read 2099 times)


  • Sr. Member
  • ****
  • Posts: 282
sLineBreak / chr(13) + chr(10) / markup
« on: July 18, 2022, 06:30:15 am »
Paint every 'foo' that has sLineBreak in front of it or behind.

At least yellow and gray should be painted at same spots as underline. A bug ?

Logically nothing should be painted except for 'foo' (having sLineBreak glued next to it, sLineBreak  excluded ).

Is that intended to work ?

Code: Pascal  [Select][+][-]
  2. var
  3.   YourMarkup:TSynEditMarkupHighlightAll;
  4.   YourMarkup1:TSynEditMarkupHighlightAll;
  5. begin
  6.   while synedit1.MarkupManager.Count > 0  do
  7.   begin
  8.     synedit1.MarkupManager.RemoveMarkUp( synedit1.MarkupManager.Markup[0]);
  9.   end;
  11.     YourMarkup := TSynEditMarkupHighlightAll.create(synedit1);
  12.     synedit1.MarkupManager.AddMarkUp(YourMarkup);
  14.     YourMarkup.MarkupInfo.Background := clYellow;
  15.     YourMarkup.MarkupInfo.Foreground := clBlack;
  16.     YourMarkup.MarkupInfo.Style := [fsUnderline];
  18.     YourMarkup.SearchString := ('foo' + chr(13) + chr(10));
  21.     YourMarkup1 := TSynEditMarkupHighlightAll.create(synedit1);
  22.     synedit1.MarkupManager.AddMarkUp(YourMarkup1);
  24.     YourMarkup1.MarkupInfo.Background := clLtGray;
  25.     YourMarkup1.MarkupInfo.Foreground := clBlack;
  26.     YourMarkup1.MarkupInfo.Style := [fsUnderline];
  28.     YourMarkup1.SearchString := (chr(13) + chr(10) + 'foo');    
lazarus 3.2-fpc-3.2.2-win32/win64


  • Administrator
  • Hero Member
  • *
  • Posts: 10072
  • Debugger - SynEdit - and more
    • wiki
Re: sLineBreak / chr(13) + chr(10) / markup
« Reply #1 on: July 18, 2022, 11:59:35 am »
Logically nothing should be painted except for 'foo' (having sLineBreak glued next to it, sLineBreak  excluded ).

Code: Pascal  [Select][+][-]
  1.     YourMarkup.SearchString := ('foo' + chr(13) + chr(10));
Then don't include the line break in the search.

I remember from one of your previous posts, that multiline-regex don't work (that is a  bug / but currently low priority). Have you tried single line regex?

If not, you should be able to subclass the markup and do your own search.

At least yellow and gray should be painted at same spots as underline. A bug ?

Even though the linebreak is not a visible char, and SynEdit does not (yet) have an option to "show" them (like it has for spaces), the linebreak exists. => E.g. it can be copy and pasted.
And it can be highlighted.

You get the same if you change the "selection markup" to have underlines.

It's a mixture of 2 features:
1) char/font based marks (bold/underline/italic) => they are applied to all chars, including none-printed (space/line-break).
  Though only underline is visible, unless spaces are printed as dot.
2) Color based (including frame) => They also apply to the area past the end-of-line.
  This is to avoid a so called "ragged" selection (I.e. if you select multiply lines, the empty space on the right after eol is shown in selection color).

I wouldn't change that as default.
Though individual highlights/markups may be able to decide for themself, if this should happen.

Again not tested, but...
1) As I said, if the line-break is excluded it should not happen at all.
2) If the line-break is included, then you may need to override
    function  GetMarkupAttributeAtRowCol(const aRow: Integer;
    procedure GetNextMarkupColAfterRowCol(const aRow: Integer;
  And have them stop the color, after the line-break.

I am not adverse to a build in option. But that will be quite some work. It won't be just a boolean flag. It needs to consider other factors too (like line-wrapping). And it needs very careful consideration where the code goes. So it doesn't need to be replicated in tons of places.

Note, there a quite a few todo around line breaks.... Like an option to keep/preserve cr/lf as found in the file.


  • Sr. Member
  • ****
  • Posts: 282
Re: sLineBreak / chr(13) + chr(10) / markup
« Reply #2 on: September 06, 2022, 11:09:26 am »
a note to myself:
FMatches.StartPoint := Point(MatchBegin-FFindLineText+1, FFindLineY);
FMatches.EndPoint   := Point(MatchBegin-FFindLineText+1+Len, FFindLineY);       
lazarus 3.2-fpc-3.2.2-win32/win64


TinyPortal © 2005-2018