synedit: fixed TSynEditMarkupGutterMark

git-svn-id: trunk@42009 -
This commit is contained in:
mattias 2013-07-07 09:39:37 +00:00
parent 659252a167
commit 2427149e18

View File

@ -36,6 +36,7 @@ type
Priority: Integer; Priority: Integer;
Markup: TSynSelectedColor; Markup: TSynSelectedColor;
end; end;
PMarkSection = ^TMarkSection;
{ TSynEditMarkupMark } { TSynEditMarkupMark }
@ -95,6 +96,8 @@ var
MLine: TSynEditMarkLine; MLine: TSynEditMarkLine;
i, j: Integer; i, j: Integer;
s: string; s: string;
Markup: TSynEditMarkupMark;
Section: PMarkSection;
begin begin
MLine := TCustomSynEdit(SynEdit).Marks.Line[ARow]; MLine := TCustomSynEdit(SynEdit).Marks.Line[ARow];
if MLine = nil then begin if MLine = nil then begin
@ -105,21 +108,23 @@ begin
j := 0; j := 0;
for i := 0 to MLine.Count - 1 do begin for i := 0 to MLine.Count - 1 do begin
if not ( (MLine[i] is TSynEditMarkupMark) and if not (MLine[i] is TSynEditMarkupMark) then
(TSynEditMarkupMark(MLine[i]).SourceMarkup <> nil) ) continue;
then Markup:=TSynEditMarkupMark(MLine[i]);
if Markup.SourceMarkup = nil then
continue; continue;
FRowData[i].Markup := TSynEditMarkupMark(MLine[i]).SourceMarkup; Section := @FRowData[j];
FRowData[i].Priority := MLine[i].Priority; Section^.Markup := Markup.SourceMarkup;
Section^.Priority := Markup.Priority;
s := Lines[MLine[i].Line - 1]; s := Lines[Markup.Line - 1];
FRowData[i].StartX := LogicalToPhysicalPos Section^.StartX := LogicalToPhysicalPos
(Point(FWordBreaker.PrevBoundary(s, MLine[i].Column, True), MLine[i].Line)).x; (Point(FWordBreaker.PrevBoundary(s, Markup.Column, True), Markup.Line)).x;
FRowData[i].EndX := LogicalToPhysicalPos Section^.EndX := LogicalToPhysicalPos
(Point(FWordBreaker.NextBoundary(s, MLine[i].Column), MLine[i].Line)).x; (Point(FWordBreaker.NextBoundary(s, Markup.Column), Markup.Line)).x;
if (FRowData[i].StartX > 0) and (FRowData[i].EndX > 0) then if (Section^.StartX > 0) and (Section^.EndX > 0) then
inc(j); inc(j);
end; end;
@ -130,16 +135,18 @@ function TSynEditMarkupGutterMark.GetMarkupAttributeAtRowCol(const aRow: Integer
const aStartCol: TLazSynDisplayTokenBound; const AnRtlInfo: TLazSynDisplayRtlInfo): TSynSelectedColor; const aStartCol: TLazSynDisplayTokenBound; const AnRtlInfo: TLazSynDisplayRtlInfo): TSynSelectedColor;
var var
i, FoundPri: Integer; i, FoundPri: Integer;
Section: PMarkSection;
begin begin
FoundPri := 0; FoundPri := 0;
Result := nil; Result := nil;
for i := 0 to length(FRowData) - 1 do begin for i := 0 to length(FRowData) - 1 do begin
if (FRowData[i].StartX <= aStartCol.Physical) and (FRowData[i].EndX > aStartCol.Physical) and Section := @FRowData[i];
( (FRowData[i].Priority < FoundPri) or (i = 0) ) if (Section^.StartX <= aStartCol.Physical) and (Section^.EndX > aStartCol.Physical) and
( (Section^.Priority < FoundPri) or (Result=nil) )
then begin then begin
Result := FRowData[i].Markup; Result := Section^.Markup;
MarkupInfo.SetFrameBoundsPhys(FRowData[i].StartX, FRowData[i].EndX); MarkupInfo.SetFrameBoundsPhys(Section^.StartX, Section^.EndX);
FoundPri := FRowData[i].Priority; FoundPri := Section^.Priority;
end; end;
end; end;
end; end;
@ -147,19 +154,33 @@ end;
procedure TSynEditMarkupGutterMark.GetNextMarkupColAfterRowCol(const aRow: Integer; procedure TSynEditMarkupGutterMark.GetNextMarkupColAfterRowCol(const aRow: Integer;
const aStartCol: TLazSynDisplayTokenBound; const AnRtlInfo: TLazSynDisplayRtlInfo; out ANextPhys, const aStartCol: TLazSynDisplayTokenBound; const AnRtlInfo: TLazSynDisplayRtlInfo; out ANextPhys,
ANextLog: Integer); ANextLog: Integer);
// return the next StartX or EndX after aStartCol
procedure Improve(Col: integer); inline;
begin
if Col <= aStartCol.Physical then exit;
if Col > ANextPhys then exit;
ANextPhys:=Col;
end;
var var
i: Integer; i: Integer;
Section: PMarkSection;
begin begin
ANextLog := -1; ANextLog := -1;
ANextPhys := -1;
if length(FRowData) = 0 then if length(FRowData) = 0 then
begin
ANextPhys := -1;
exit; exit;
for i := 0 to length(FRowData) - 1 do begin
if FRowData[i].StartX < ANextPhys then
ANextPhys := FRowData[0].StartX;;
if FRowData[i].EndX < ANextPhys then
ANextPhys := FRowData[0].EndX;;
end; end;
ANextPhys := High(ANextPhys);
for i := 0 to length(FRowData) - 1 do begin
Section := @FRowData[i];
Improve(Section^.StartX);
Improve(Section^.EndX);
end;
if ANextPhys = High(ANextPhys) then
ANextPhys := -1;
end; end;
end. end.