SynEdit: Fix for right overview Gutter

git-svn-id: trunk@27632 -
This commit is contained in:
martin 2010-10-09 16:06:56 +00:00
parent c4c3db3775
commit 871136835b

View File

@ -91,7 +91,7 @@ type
TSynGutterLOvLineMarks = class(TSynGutterLOvMarkList) TSynGutterLOvLineMarks = class(TSynGutterLOvMarkList)
private private
FLine: Integer; FPixLine: Integer;
protected protected
procedure ReSort; override; // by prior procedure ReSort; override; // by prior
procedure ReSortByLine; procedure ReSortByLine;
@ -100,7 +100,7 @@ type
constructor Create; constructor Create;
procedure Paint(Canvas: TCanvas; AClip: TRect; TopOffset: integer; AnItemHeight: Integer); procedure Paint(Canvas: TCanvas; AClip: TRect; TopOffset: integer; AnItemHeight: Integer);
procedure Add(AValue: TSynGutterLOvMark); override; procedure Add(AValue: TSynGutterLOvMark); override;
property Line: Integer read FLine; property PixLine: Integer read FPixLine;
end; end;
{ TSynGutterLOvLineMarksList { TSynGutterLOvLineMarksList
@ -426,7 +426,7 @@ end;
function TSynGutterLOvLineMarks.Compare(Other: TSynGutterLOvLineMarks): Integer; function TSynGutterLOvLineMarks.Compare(Other: TSynGutterLOvLineMarks): Integer;
begin begin
Result := Line - Other.Line; Result := PixLine - Other.PixLine;
if Result <> 0 then exit; if Result <> 0 then exit;
Result := PtrUint(self) - PtrUInt(Other); Result := PtrUint(self) - PtrUInt(Other);
end; end;
@ -442,13 +442,13 @@ procedure TSynGutterLOvLineMarks.Paint(Canvas: TCanvas; AClip: TRect; TopOffset:
var var
bs: TFPBrushStyle; bs: TFPBrushStyle;
begin begin
if (FLine + AnItemHeight < AClip.Top - TopOffset) or if (FPixLine + AnItemHeight < AClip.Top - TopOffset) or
(FLine > AClip.Bottom - TopOffset) (FPixLine > AClip.Bottom - TopOffset)
then then
exit; exit;
AClip.Top := FLine; AClip.Top := FPixLine;
AClip.Bottom := Max(FLine+1, FLine + AnItemHeight - 1); AClip.Bottom := Max(FPixLine+1, FPixLine + AnItemHeight - 1);
inc(AClip.Left); inc(AClip.Left);
dec(AClip.Right); dec(AClip.Right);
@ -496,7 +496,7 @@ var
begin begin
LMark := TSynGutterLOvMark(Sender).LineMarks; LMark := TSynGutterLOvMark(Sender).LineMarks;
j := TextLineToPixLine(TSynGutterLOvMark(Sender).Line); j := TextLineToPixLine(TSynGutterLOvMark(Sender).Line);
if (j >= LMark.Line) and (j < LMark.Line + ItemHeight) then begin if (j >= LMark.PixLine) and (j < LMark.PixLine + ItemHeight) then begin
LMark.ReSort; LMark.ReSort;
exit; exit;
end; end;
@ -522,7 +522,8 @@ end;
function TSynGutterLOvLineMarksList.TextLineToPixLine(ATxtLine: Integer): Integer; function TSynGutterLOvLineMarksList.TextLineToPixLine(ATxtLine: Integer): Integer;
begin begin
Result:= (ATxtLine - 1) * Max(1, PixelHeight - ItemHeight + 1) div TextLineCount - 1; Result := Int64(ATxtLine - 1) * Int64(Max(1, PixelHeight - ItemHeight + 1)) div TextLineCount - 1;
//Result := MulDiv(ATxtLine - 1, Max(1, PixelHeight - ItemHeight + 1), TextLineCount) - 1;
end; end;
procedure TSynGutterLOvLineMarksList.ReBuild(AFromIndex: Integer = -1); procedure TSynGutterLOvLineMarksList.ReBuild(AFromIndex: Integer = -1);
@ -534,9 +535,9 @@ procedure TSynGutterLOvLineMarksList.ReBuild(AFromIndex: Integer = -1);
i := ASrc.Count -1; i := ASrc.Count -1;
while i >= 0 do begin while i >= 0 do begin
j := TextLineToPixLine(ASrc[i].Line); j := TextLineToPixLine(ASrc[i].Line);
if j >= ASrc.Line +ItemHeight then begin if j >= ASrc.PixLine +ItemHeight then begin
if (ADest.Count = 0) or (ADest.Line > j) then if (ADest.Count = 0) or (ADest.PixLine > j) then
ADest.FLine := j; ADest.FPixLine := j;
ADest.Add(ASrc[i]); ADest.Add(ASrc[i]);
ASrc.Delete(i); ASrc.Delete(i);
end; end;
@ -552,7 +553,7 @@ procedure TSynGutterLOvLineMarksList.ReBuild(AFromIndex: Integer = -1);
NewLine := MaxInt; NewLine := MaxInt;
while i >= 0 do begin while i >= 0 do begin
j := TextLineToPixLine(ASrc[i].Line); j := TextLineToPixLine(ASrc[i].Line);
if j < ADest.Line + ItemHeight then begin if j < ADest.PixLine + ItemHeight then begin
ADest.Add(ASrc[i]); ADest.Add(ASrc[i]);
ASrc.Delete(i); ASrc.Delete(i);
end end
@ -560,7 +561,7 @@ procedure TSynGutterLOvLineMarksList.ReBuild(AFromIndex: Integer = -1);
if j < NewLine then NewLine := j; if j < NewLine then NewLine := j;
dec(i); dec(i);
end; end;
ASrc.FLine := NewLine; ASrc.FPixLine := NewLine;
end; end;
var var
@ -576,7 +577,7 @@ begin
if (i = 0) or (j < NewIdx) then if (i = 0) or (j < NewIdx) then
NewIdx := j; NewIdx := j;
end; end;
Items[0][i].FLine := NewIdx; Items[0].FPixLine := NewIdx;
AFromIndex := 0; AFromIndex := 0;
end; end;
@ -585,7 +586,7 @@ begin
NextItem := Items[AFromIndex]; NextItem := Items[AFromIndex];
NextItem.Lock; NextItem.Lock;
while NextItem <> nil do begin while NextItem <> nil do begin
if (TmpItem.Count > 0) and (TmpItem.Line < NextItem.Line) then begin if (TmpItem.Count > 0) and (TmpItem.PixLine < NextItem.PixLine) then begin
Insert(AFromIndex, TmpItem); Insert(AFromIndex, TmpItem);
CurItem := TmpItem; CurItem := TmpItem;
TmpItem := TSynGutterLOvLineMarks.Create; TmpItem := TSynGutterLOvLineMarks.Create;
@ -598,8 +599,8 @@ begin
if AFromIndex < Count then begin if AFromIndex < Count then begin
NextItem := Items[AFromIndex]; NextItem := Items[AFromIndex];
NextItem.Lock; NextItem.Lock;
if NextItem.Line < CurItem.Line + ItemHeight then if NextItem.PixLine < CurItem.PixLine + ItemHeight then
NextItem.FLine := CurItem.Line + ItemHeight; NextItem.FPixLine := CurItem.PixLine + ItemHeight;
end end
else else
NextItem := nil; NextItem := nil;
@ -667,7 +668,7 @@ begin
i := IndexForLine(PixLine, True); i := IndexForLine(PixLine, True);
if i >= 0 then begin if i >= 0 then begin
LMarks := Items[i]; LMarks := Items[i];
if (PixLine >= LMarks.Line) and (PixLine < LMarks.Line + ItemHeight) then begin if (PixLine >= LMarks.PixLine) and (PixLine < LMarks.PixLine + ItemHeight) then begin
LMarks.Add(AMark); LMarks.Add(AMark);
// sendinvalidate // sendinvalidate
exit; exit;
@ -676,13 +677,13 @@ begin
inc(i); inc(i);
LMarks := TSynGutterLOvLineMarks.Create; LMarks := TSynGutterLOvLineMarks.Create;
LMarks.FLine := PixLine; LMarks.FPixLine := PixLine;
Insert(i, LMarks); Insert(i, LMarks);
LMarks.Add(AMark); LMarks.Add(AMark);
// sendinvalidate // sendinvalidate
if (i < Count - 1) and (Items[i+1].Line < LMarks.Line + ItemHeight) then if (i < Count - 1) and (Items[i+1].PixLine < LMarks.PixLine + ItemHeight) then
ReBuild(i); ReBuild(i);
end; end;
@ -690,9 +691,9 @@ function TSynGutterLOvLineMarksList.IndexForLine(ALine: Integer;
PreviousIfNotExist: Boolean = False): Integer; PreviousIfNotExist: Boolean = False): Integer;
begin begin
Result := Count - 1; Result := Count - 1;
while (Result >= 0) and (Items[Result].Line > ALine) do while (Result >= 0) and (Items[Result].PixLine > ALine) do
dec(Result); dec(Result);
if ((Result >= 0) and (Items[Result].Line = ALine)) or (PreviousIfNotExist) then if ((Result >= 0) and (Items[Result].PixLine = ALine)) or (PreviousIfNotExist) then
exit; exit;
Result := -1; Result := -1;
end; end;
@ -704,10 +705,10 @@ var
LMarks: TSynGutterLOvLineMarks; LMarks: TSynGutterLOvLineMarks;
begin begin
i := IndexForLine(ALine, CreateIfNotExists); i := IndexForLine(ALine, CreateIfNotExists);
if CreateIfNotExists and ( (i < 0) or (Items[i].Line <> ALine) ) then begin if CreateIfNotExists and ( (i < 0) or (Items[i].PixLine <> ALine) ) then begin
inc(i); inc(i);
LMarks := TSynGutterLOvLineMarks.Create; LMarks := TSynGutterLOvLineMarks.Create;
LMarks.FLine := i; LMarks.FPixLine := i;
Insert(i, LMarks); Insert(i, LMarks);
end; end;
if i >= 0 then if i >= 0 then
@ -741,7 +742,7 @@ constructor TSynGutterLineOverviewProvider.Create(AOwner: TComponent);
begin begin
inherited; inherited;
FGutterPart := Owner.Owner; FGutterPart := Owner.Owner;
FColor := clGray; FColor := clLtGray;
FriendEdit := SynEdit; FriendEdit := SynEdit;
FMarkList := TSynGutterLOvMarkList.Create; FMarkList := TSynGutterLOvMarkList.Create;
end; end;
@ -923,7 +924,7 @@ constructor TSynGutterLOvProviderCurrentPage.Create(AOwner: TComponent);
begin begin
inherited; inherited;
FColor := 0; FColor := 0;
Color := clGray; Color := $C0C0C0;
TSynEdit(SynEdit).RegisterStatusChangedHandler({$IFDEF FPC}@{$ENDIF}SynStatusChanged, TSynEdit(SynEdit).RegisterStatusChangedHandler({$IFDEF FPC}@{$ENDIF}SynStatusChanged,
[scTopLine, scLinesInWindow]); [scTopLine, scLinesInWindow]);
end; end;
@ -1192,7 +1193,7 @@ begin
FLineMarks := TSynGutterLOvLineMarksList.Create; FLineMarks := TSynGutterLOvLineMarksList.Create;
FProviders := TSynGutterLineOverviewProviderList.Create(Self); FProviders := TSynGutterLineOverviewProviderList.Create(Self);
MarkupInfo.Background := clLtGray; MarkupInfo.Background := $E0E0E0;
LineCountchanged(nil, 0, 0); LineCountchanged(nil, 0, 0);
end; end;