SynEdit: improved merging of frames and markups

git-svn-id: trunk@27672 -
This commit is contained in:
martin 2010-10-13 01:07:10 +00:00
parent 32c2a1c1f2
commit cf34fd38f0
3 changed files with 24 additions and 22 deletions

View File

@ -3547,7 +3547,6 @@ var
len: Integer;
SubTokenByteLen, SubCharLen, TokenCharLen : Integer;
NextPhysPos : Integer;
MarkupInfo : TSynSelectedColor;
function CharToByteLen(aCharLen: Integer) : Integer;
begin
@ -3646,9 +3645,8 @@ var
PhysicalEndPos:= PhysicalStartPos + SubCharLen - 1;
// Calculate Markup
MarkupInfo := fMarkupManager.GetMarkupAttributeAtRowCol(FFoldedLinesView.TextIndex[CurLine]+1, PhysicalStartPos);
if Assigned(MarkupInfo) then
FPaintLineColor2.Merge(MarkupInfo, PhysicalStartPos, PhysicalEndPos);
fMarkupManager.MergeMarkupAttributeAtRowCol(FFoldedLinesView.TextIndex[CurLine]+1,
PhysicalStartPos, FPaintLineColor2);
// Deal with equal colors
if (FPaintLineColor2.Background = FPaintLineColor2.Foreground) then begin // or if diff(gb,fg) < x

View File

@ -150,6 +150,7 @@ type
Procedure EndMarkup; override;
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override;
Procedure MergeMarkupAttributeAtRowCol(const aRow, aCol : Integer; AMarkup: TSynSelectedColor);
// Notifications about Changes to the text
Procedure TextChanged(aFirstCodeLine, aLastCodeLine: Integer); override;
@ -478,29 +479,30 @@ begin
TSynEditMarkup(fMarkUpList[i]).PrepareMarkupForRow(aRow);
end;
function TSynEditMarkupManager.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
procedure TSynEditMarkupManager.MergeMarkupAttributeAtRowCol(const aRow, aCol: Integer;
AMarkup: TSynSelectedColor);
var
i, EndCol : integer;
c : TSynSelectedColor;
begin
Result := nil;
EndCol := GetNextMarkupColAfterRowCol(aRow, aCol) - 1;
for i := 0 to fMarkUpList.Count-1 do begin
if not TSynEditMarkup(fMarkUpList[i]).Enabled then continue;
c := TSynEditMarkup(fMarkUpList[i]).GetMarkupAttributeAtRowCol(aRow, aCol);
if assigned(c) then begin
if not Assigned(Result) then begin
Result := MarkupInfo;
Result.Assign(c);
Result.MergeFrames(nil, aCol, EndCol);
end else begin
Result.Merge(c, aCol, EndCol);
end;
AMarkup.Merge(c, aCol, EndCol);
end;
end;
end;
function TSynEditMarkupManager.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
begin
Result := MarkupInfo;
Result.Clear;
MergeMarkupAttributeAtRowCol(aRow, aCol, Result);
end;
function TSynEditMarkupManager.GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer;
var
i, j : integer;

View File

@ -631,20 +631,22 @@ begin
Other := nil;
end;
if (Other = nil) and (FrameColor <> clNone) then begin
if (Other = nil) then begin // XXXX initialization...
// initialize individual borders
for i := low(TSynFrameSide) to high(TSynFrameSide) do begin
FFrameSideColors[i] := clNone;
FFrameSideStyles[i] := slsSolid;
end;
if (FrameEdges in [sfeAround, sfeLeft]) and (StartX = LeftCol) then
SetSide(sfdLeft, Self);
if (FrameEdges in [sfeAround]) and (EndX = RightCol) then
SetSide(sfdRight, Self);
if FrameEdges in [sfeAround, sfeBottom] then
SetSide(sfdBottom, Self);
if FrameEdges in [sfeAround] then
SetSide(sfdTop, Self);
if (FrameColor <> clNone) then begin
if (FrameEdges in [sfeAround, sfeLeft]) and (StartX = LeftCol) then
SetSide(sfdLeft, Self);
if (FrameEdges in [sfeAround]) and (EndX = RightCol) then
SetSide(sfdRight, Self);
if FrameEdges in [sfeAround, sfeBottom] then
SetSide(sfdBottom, Self);
if FrameEdges in [sfeAround] then
SetSide(sfdTop, Self);
end;
end;
If (Other = nil) or (Other.FrameColor = clNone) then