Recent

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

BubikolRamios

  • Full Member
  • ***
  • Posts: 240
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][+][-]
  1.  
  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;
  10.  
  11.     YourMarkup := TSynEditMarkupHighlightAll.create(synedit1);
  12.     synedit1.MarkupManager.AddMarkUp(YourMarkup);
  13.  
  14.     YourMarkup.MarkupInfo.Background := clYellow;
  15.     YourMarkup.MarkupInfo.Foreground := clBlack;
  16.     YourMarkup.MarkupInfo.Style := [fsUnderline];
  17.  
  18.     YourMarkup.SearchString := ('foo' + chr(13) + chr(10));
  19.  
  20.  
  21.     YourMarkup1 := TSynEditMarkupHighlightAll.create(synedit1);
  22.     synedit1.MarkupManager.AddMarkUp(YourMarkup1);
  23.  
  24.     YourMarkup1.MarkupInfo.Background := clLtGray;
  25.     YourMarkup1.MarkupInfo.Foreground := clBlack;
  26.     YourMarkup1.MarkupInfo.Style := [fsUnderline];
  27.  
  28.     YourMarkup1.SearchString := (chr(13) + chr(10) + 'foo');    
  29.  
  30.  
lazarus-2.0.12-fpc-3.2.0-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8481
  • 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?
^foo|foo$

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

Quote
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.


BubikolRamios

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

 

TinyPortal © 2005-2018