Forum > SynEdit
sLineBreak / chr(13) + chr(10) / markup
(1/1)
BubikolRamios:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- var YourMarkup:TSynEditMarkupHighlightAll; YourMarkup1:TSynEditMarkupHighlightAll;begin while synedit1.MarkupManager.Count > 0 do begin synedit1.MarkupManager.RemoveMarkUp( synedit1.MarkupManager.Markup[0]); end; YourMarkup := TSynEditMarkupHighlightAll.create(synedit1); synedit1.MarkupManager.AddMarkUp(YourMarkup); YourMarkup.MarkupInfo.Background := clYellow; YourMarkup.MarkupInfo.Foreground := clBlack; YourMarkup.MarkupInfo.Style := [fsUnderline]; YourMarkup.SearchString := ('foo' + chr(13) + chr(10)); YourMarkup1 := TSynEditMarkupHighlightAll.create(synedit1); synedit1.MarkupManager.AddMarkUp(YourMarkup1); YourMarkup1.MarkupInfo.Background := clLtGray; YourMarkup1.MarkupInfo.Foreground := clBlack; YourMarkup1.MarkupInfo.Style := [fsUnderline]; YourMarkup1.SearchString := (chr(13) + chr(10) + 'foo');
Martin_fr:
--- Quote from: BubikolRamios on July 18, 2022, 06:30:15 am ---Logically nothing should be painted except for 'foo' (having sLineBreak glued next to it, sLineBreak excluded ).
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- YourMarkup.SearchString := ('foo' + chr(13) + chr(10));
--- End quote ---
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 ?
--- End quote ---
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:
a note to myself:
TSynEditMarkupHighlightAllMulti.DoMatchFound
...
FMatches.StartPoint := Point(MatchBegin-FFindLineText+1, FFindLineY);
FMatches.EndPoint := Point(MatchBegin-FFindLineText+1+Len, FFindLineY);
Navigation
[0] Message Index