SynEdit: Markup, fix markup for empty line-part after wrap-pos

git-svn-id: trunk@63294 -
This commit is contained in:
martin 2020-06-05 00:12:59 +00:00
parent 47a4815c09
commit 680762bdbf
4 changed files with 98 additions and 7 deletions

View File

@ -64,6 +64,7 @@ type
FCurViewToken: TLazSynDisplayTokenInfo;
FCurViewCurTokenStartPos: TLazSynDisplayTokenBound; // Start bound of the HL token
FCurViewAttr: TSynSelectedColorMergeResult;
FWrapEndBound: TLazSynDisplayTokenBound;
// Scanner Pos
FCurViewScannerPos: TLazSynDisplayTokenBound; // Start according to Logical flow. Left for LTR, or Right for RTL
FCurViewScannerPhysCharPos: Integer; // 1 based - Full char bound (Before FCurViewScannerPos.Physical (PaintStart))
@ -78,7 +79,7 @@ type
FNextMarkupPhysPos, FNextMarkupLogPos: Integer;
FCurMarkupNextStart: TLazSynDisplayTokenBound;
FCurMarkupNextRtlInfo: TLazSynDisplayRtlInfo;
FCurMarkupState: (cmPreInit, cmLine, cmPastEOL);
FCurMarkupState: (cmPreInit, cmLine, cmPastEOL, cmPastWrapEnd);
FMarkupTokenAttr: TSynSelectedColorMergeResult;
procedure InitCurMarkup;
public
@ -340,6 +341,20 @@ begin
if FCurMarkupState = cmPreInit then
InitCurMarkup;
if (FCurLineByteLen < FCharWidthsLen) and (FCurViewScannerPos.Logical > FCurLineByteLen)
then begin
if FCurMarkupState <> cmPastWrapEnd then begin
assert(FCurViewScannerPos.Logical = FCurLineByteLen + 1, 'TLazSynPaintTokenBreaker.GetNextHighlighterTokenEx: FCurViewScannerPos.Logical = FCurLineByteLen + 1');
FCurMarkupState := cmPastWrapEnd;
FWrapEndBound := FCurViewScannerPos;
end;
end;
if (FCurMarkupState = cmPastWrapEnd) then begin
FNextMarkupPhysPos := MaxInt;
FNextMarkupLogPos := MaxInt;
end
else
if (FNextMarkupPhysPos < 0) or
(FCurMarkupNextRtlInfo.IsRtl and (FNextMarkupPhysPos >= FCurMarkupNextStart.Physical)) or
((not FCurMarkupNextRtlInfo.IsRtl) and (FNextMarkupPhysPos <= FCurMarkupNextStart.Physical)) or
@ -356,14 +371,19 @@ begin
FNextMarkupLogPos := MaxInt;
end;
if (FCurMarkupState <> cmPastWrapEnd) and (FCurLineByteLen < FCharWidthsLen) and
(FNextMarkupLogPos > FCurLineByteLen + 1)
then
FNextMarkupLogPos := FCurLineByteLen + 1; // stop at WrapEnd / EOL // tokens should have a bound there anyway
ATokenInfo.Attr := nil;
if FCurMarkupState = cmPastEOL
if FCurMarkupState in [cmPastEOL, cmPastWrapEnd]
then Result := False
else Result := GetNextHighlighterTokenFromView(ATokenInfo, FNextMarkupPhysPos, FNextMarkupLogPos);
if (not Result) then begin
if not Result then begin
// the first run StartPos is set by GetNextHighlighterTokenFromView
if FCurMarkupState = cmPastEOL then begin
if FCurMarkupState in [cmPastEOL, cmPastWrapEnd] then begin
ATokenInfo.StartPos := FCurMarkupNextStart
end
else
@ -372,7 +392,8 @@ begin
ATokenInfo.StartPos.Physical := FFirstCol;
end;
FCurMarkupState := cmPastEOL;
if (FCurMarkupState <> cmPastWrapEnd) then
FCurMarkupState := cmPastEOL;
Result := (ATokenInfo.StartPos.Physical < FLastCol);
if not Result then
@ -433,8 +454,12 @@ begin
FMarkupTokenAttr.CurrentEndX := ATokenInfo.EndPos;
end;
fMarkupManager.MergeMarkupAttributeAtRowCol(FCurTxtLineIdx + 1,
ATokenInfo.StartPos, ATokenInfo.EndPos, ATokenInfo.RtlInfo, FMarkupTokenAttr);
if FCurMarkupState = cmPastWrapEnd then
fMarkupManager.MergeMarkupAttributeAtWrapEnd(FCurTxtLineIdx + 1,
FWrapEndBound, FMarkupTokenAttr)
else
fMarkupManager.MergeMarkupAttributeAtRowCol(FCurTxtLineIdx + 1,
ATokenInfo.StartPos, ATokenInfo.EndPos, ATokenInfo.RtlInfo, FMarkupTokenAttr);
FMarkupTokenAttr.ProcessMergeInfo;

View File

@ -116,6 +116,14 @@ type
const AnRtlInfo: TLazSynDisplayRtlInfo;
AMarkup: TSynSelectedColorMergeResult); virtual;
function GetMarkupAttributeAtWrapEnd(const aRow: Integer;
const aWrapCol: TLazSynDisplayTokenBound): TSynSelectedColor; virtual;
// experimental; // params may still change
procedure MergeMarkupAttributeAtWrapEnd(const aRow: Integer;
const aWrapCol: TLazSynDisplayTokenBound;
AMarkup: TSynSelectedColorMergeResult); virtual;
// experimental; // params may still change
// Notifications about Changes to the text
Procedure TextChanged(aFirstCodeLine, aLastCodeLine, ACountDiff: Integer); virtual; // 1 based
Procedure TempDisable;
@ -183,6 +191,10 @@ type
const AnRtlInfo: TLazSynDisplayRtlInfo;
AMarkup: TSynSelectedColorMergeResult); override;
procedure MergeMarkupAttributeAtWrapEnd(const aRow: Integer;
const aWrapCol: TLazSynDisplayTokenBound;
AMarkup: TSynSelectedColorMergeResult); override;
// Notifications about Changes to the text
Procedure TextChanged(aFirstCodeLine, aLastCodeLine, ACountDiff: Integer); override; // lines are 1 based
end;
@ -449,6 +461,23 @@ begin
AMarkup.Merge(c, aStartCol, AEndCol);
end;
function TSynEditMarkup.GetMarkupAttributeAtWrapEnd(const aRow: Integer;
const aWrapCol: TLazSynDisplayTokenBound): TSynSelectedColor;
begin
Result := nil;
end;
procedure TSynEditMarkup.MergeMarkupAttributeAtWrapEnd(const aRow: Integer;
const aWrapCol: TLazSynDisplayTokenBound;
AMarkup: TSynSelectedColorMergeResult);
var
c: TSynSelectedColor;
begin
c := GetMarkupAttributeAtWrapEnd(aRow, aWrapCol);
if assigned(c) then
AMarkup.Merge(c);
end;
procedure TSynEditMarkup.TextChanged(aFirstCodeLine, aLastCodeLine, ACountDiff: Integer);
begin
DoTextChanged(aFirstCodeLine, aLastCodeLine, ACountDiff);
@ -601,6 +630,19 @@ begin
end;
end;
procedure TSynEditMarkupManager.MergeMarkupAttributeAtWrapEnd(
const aRow: Integer; const aWrapCol: TLazSynDisplayTokenBound;
AMarkup: TSynSelectedColorMergeResult);
var
i : integer;
begin
for i := 0 to fMarkUpList.Count-1 do begin
if TSynEditMarkup(fMarkUpList[i]).RealEnabled then
TSynEditMarkup(fMarkUpList[i]).MergeMarkupAttributeAtWrapEnd
(aRow, aWrapCol, AMarkup);
end;
end;
function TSynEditMarkupManager.GetMarkupAttributeAtRowCol(const aRow: Integer;
const aStartCol: TLazSynDisplayTokenBound;
const AnRtlInfo: TLazSynDisplayRtlInfo): TSynSelectedColor;

View File

@ -59,6 +59,8 @@ type
const aStartCol: TLazSynDisplayTokenBound;
const AnRtlInfo: TLazSynDisplayRtlInfo;
out ANextPhys, ANextLog: Integer); override;
function GetMarkupAttributeAtWrapEnd(const aRow: Integer;
const aWrapCol: TLazSynDisplayTokenBound): TSynSelectedColor; override;
property ColorTillEol: boolean read FColorTillEol write SetColorTillEol;
property UseIncrementalColor : Boolean read FUseIncrementalColor write SetUseIncrementalColor;
@ -212,6 +214,16 @@ begin
//end;
end;
function TSynEditMarkupSelection.GetMarkupAttributeAtWrapEnd(
const aRow: Integer; const aWrapCol: TLazSynDisplayTokenBound
): TSynSelectedColor;
begin
result := nil;
if (nSelStart <= aWrapCol.Logical) and ((nSelEnd > aWrapCol.Logical) or (nSelEnd < 0)) then
Result := MarkupInfo;
end;
procedure TSynEditMarkupSelection.GetNextMarkupColAfterRowCol(const aRow: Integer;
const aStartCol: TLazSynDisplayTokenBound; const AnRtlInfo: TLazSynDisplayRtlInfo; out ANextPhys,
ANextLog: Integer);

View File

@ -65,6 +65,8 @@ type
const aStartCol: TLazSynDisplayTokenBound;
const AnRtlInfo: TLazSynDisplayRtlInfo;
out ANextPhys, ANextLog: Integer); override;
function GetMarkupAttributeAtWrapEnd(const aRow: Integer;
const aWrapCol: TLazSynDisplayTokenBound): TSynSelectedColor; override;
function RealEnabled: Boolean; override;
procedure InvalidateLineHighlight;
@ -209,6 +211,16 @@ begin
ANextPhys := -1; // always valid for the whole line
end;
function TSynEditMarkupSpecialLine.GetMarkupAttributeAtWrapEnd(
const aRow: Integer; const aWrapCol: TLazSynDisplayTokenBound
): TSynSelectedColor;
begin
Result := nil;
MarkupInfo.SetFrameBoundsPhys(1, MaxInt);
if FSpecialLine then
Result := MarkupInfo;
end;
procedure TSynEditMarkupSpecialLine.InvalidateLineHighlight;
var
NewLine: Integer;