SynEdit: Rename TextArea.TopLine to TopViewedLine

This commit is contained in:
Martin 2025-06-26 10:02:35 +02:00
parent 0c15c25f2b
commit a6734c4df9
8 changed files with 32 additions and 31 deletions

View File

@ -141,7 +141,7 @@ type
FRightEdgeColumn: integer;
FRightEdgeVisible: boolean;
FTopLine: TLinePos;
FViewedTopLine: TLinePos;
FLeftChar: Integer;
function GetExtraCharSpacing: integer;
@ -150,7 +150,7 @@ type
procedure SetExtraLineSpacing(AValue: integer);
procedure SetLeftChar(AValue: Integer);
procedure SetPadding(Side: TLazSynBorderSide; AValue: integer);
procedure SetTopLine(AValue: TLinePos);
procedure SetViewedTopLine(AValue: TLinePos);
procedure DoDrawerFontChanged(Sender: TObject; Changes: TSynStatusChanges);
protected
procedure BoundsChanged; override;
@ -183,7 +183,8 @@ type
property RightEdgeVisible: boolean read FRightEdgeVisible write FRightEdgeVisible;
property RightEdgeColor: TColor read FRightEdgeColor write FRightEdgeColor;
property TopLine: TLinePos read FTopLine write SetTopLine; // TopView
property TopViewedLine: TLinePos read FViewedTopLine write SetViewedTopLine;
property TopLine: TLinePos read FViewedTopLine write SetViewedTopLine; deprecated 'Renamed to TopViewedLine - To be removed in 5.99';
property LeftChar: Integer read FLeftChar write SetLeftChar;
property TheLinesView: TSynEditStrings read FTheLinesView write FTheLinesView;
@ -1324,14 +1325,14 @@ begin
ViewedRange := DisplayView.TextToViewIndex(FirstTextLine);
rcInval.Top := Max(TextArea.TextBounds.Top,
TextArea.TextBounds.Top + (ViewedRange.Top + AScreenLineOffset
- TextArea.TopLine + 1) * TextArea.LineHeight);
- TextArea.TopViewedLine + 1) * TextArea.LineHeight);
end;
if (LastTextLine >= 0) then begin
if LastTextLine <> FirstTextLine then
ViewedRange := DisplayView.TextToViewIndex(LastTextLine);
rcInval.Bottom := Min(TextArea.TextBounds.Bottom,
TextArea.TextBounds.Top + ({%H-}ViewedRange.Bottom + AScreenLineOffset
- TextArea.TopLine + 2) * TextArea.LineHeight);
- TextArea.TopViewedLine + 2) * TextArea.LineHeight);
end;
{$IFDEF VerboseSynEditInvalidate}
@ -1400,11 +1401,11 @@ begin
FontChanged;
end;
procedure TLazSynTextArea.SetTopLine(AValue: TLinePos);
procedure TLazSynTextArea.SetViewedTopLine(AValue: TLinePos);
begin
if AValue < 1 then AValue := 1;
if FTopLine = AValue then Exit;
FTopLine := AValue;
if FViewedTopLine = AValue then Exit;
FViewedTopLine := AValue;
end;
procedure TLazSynTextArea.DoDrawerFontChanged(Sender: TObject; Changes: TSynStatusChanges);
@ -1428,7 +1429,7 @@ end;
function TLazSynTextArea.RowColumnToPixels(const RowCol: TScreenPoint_0): TPoint;
begin
// Inludes LeftChar, but not Topline
// Inludes LeftChar, but not TopViewedline
Result.X := FTextBounds.Left + (RowCol.X - LeftChar) * CharWidth;
Result.Y := FTextBounds.Top + RowCol.Y * LineHeight;
end;
@ -1436,7 +1437,7 @@ end;
function TLazSynTextArea.PixelsToRowColumn(Pixels: TPoint;
aFlags: TSynCoordinateMappingFlags): TPhysScreenPoint_0;
begin
// Inludes LeftChar, but not Topline
// Inludes LeftChar, but not TopViewedline
if (Pixels.X >= FTextBounds.Left) and (Pixels.X < FTextBounds.Right) then begin
if not (scmForceLeftSidePos in aFlags) then
Pixels.X := Pixels.X + (CharWidth div 2); // nearest side of char
@ -1469,7 +1470,7 @@ begin
FPaintLineColor2 := TSynSelectedColor.Create;
for i := low(TLazSynBorderSide) to high(TLazSynBorderSide) do
FPadding[i] := 0;
FTopLine := 1;
FViewedTopLine := 1;
FLeftChar := 1;
FRightEdgeColumn := 80;
FRightEdgeVisible := True;
@ -1512,7 +1513,7 @@ begin
for i := low(TLazSynBorderSide) to high(TLazSynBorderSide) do
FPadding[i] := TLazSynTextArea(Src).FPadding[i];
FTopLine := TLazSynTextArea(Src).FTopLine;
FViewedTopLine := TLazSynTextArea(Src).FViewedTopLine;
FLeftChar := TLazSynTextArea(Src).FLeftChar;
BoundsChanged;
@ -1528,13 +1529,13 @@ begin
if (FirstTextLine >= 0) then begin
ViewedRange := DisplayView.TextToViewIndex(FirstTextLine);
rcInval.Top := Max(TextBounds.Top,
TextBounds.Top + (ViewedRange.Top + AScreenLineOffset - TopLine + 1) * LineHeight);
TextBounds.Top + (ViewedRange.Top + AScreenLineOffset - TopViewedLine + 1) * LineHeight);
end;
if (LastTextLine >= 0) then begin
if LastTextLine <> FirstTextLine then
ViewedRange := DisplayView.TextToViewIndex(LastTextLine);
rcInval.Bottom := Min(TextBounds.Bottom,
TextBounds.Top + ({%H-}ViewedRange.Bottom + AScreenLineOffset - TopLine + 2) * LineHeight);
TextBounds.Top + ({%H-}ViewedRange.Bottom + AScreenLineOffset - TopViewedLine + 2) * LineHeight);
end;
{$IFDEF VerboseSynEditInvalidate}
@ -1920,7 +1921,7 @@ var
rcLine := AClip;
rcLine.Bottom := TextBounds.Top + FirstLine * fTextHeight;
TV := TopLine - 1;
TV := TopViewedLine - 1;
// Now loop through all the lines. The indices are valid for Lines.
MaxLine := DisplayView.GetLinesCount-1;
@ -1991,7 +1992,7 @@ begin
//DebugLn(['TCustomSynEdit.PaintTextLines ',dbgs(AClip)]);
CurLine:=-1;
//DebugLn('TCustomSynEdit.PaintTextLines ',DbgSName(Self),' TopLine=',dbgs(TopLine),' AClip=',dbgs(AClip));
//DebugLn('TCustomSynEdit.PaintTextLines ',DbgSName(Self),' TopViewedLine=',dbgs(TopViewedLine),' AClip=',dbgs(AClip));
colEditorBG := BackgroundColor;
// If the right edge is visible and in the invalid area, prepare to paint it.
// Do this first to realize the pen when getting the dc variable.

View File

@ -1987,7 +1987,7 @@ begin
if not Assigned(FTextArea) then
Result := -1
else
Result := FTheLinesView.ViewToTextIndex(ToIdx(FTextArea.TopLine)) + 1;
Result := FTheLinesView.ViewToTextIndex(ToIdx(FTextArea.TopViewedLine)) + 1;
end;
procedure TCustomSynEdit.SetBlockTabIndent(AValue: integer);
@ -5811,10 +5811,10 @@ begin
*)
FFoldedLinesView.TopViewPos := AValue;
if FTextArea.TopLine <> AValue then begin
if FTextArea.TopViewedLine <> AValue then begin
if FPaintLock = 0 then
FOldTopView := TopView;
FTextArea.TopLine := AValue;
FTextArea.TopViewedLine := AValue;
UpdateScrollBars;
// call MarkupMgr before ScrollAfterTopLineChanged, in case we aren't in a PaintLock
fMarkupManager.TopLine := TopLine;
@ -5832,7 +5832,7 @@ end;
function TCustomSynEdit.GetTopView : Integer;
begin
Result := FTextArea.TopLine;
Result := FTextArea.TopViewedLine;
end;
procedure TCustomSynEdit.SetWordBlock(Value: TPoint);

View File

@ -156,12 +156,12 @@ begin
rcInval.Top := Max(TextArea.TextBounds.Top,
TextArea.TextBounds.Top
+ (DisplayView.TextToViewIndex(FirstTextLine).Top + AScreenLineOffset
- TextArea.TopLine + 1) * TextArea.LineHeight);
- TextArea.TopViewedLine + 1) * TextArea.LineHeight);
if (LastTextLine >= 0) then
rcInval.Bottom := Min(TextArea.TextBounds.Bottom,
TextArea.TextBounds.Top
+ (DisplayView.TextToViewIndex(LastTextLine).Bottom + AScreenLineOffset
- TextArea.TopLine + 2) * TextArea.LineHeight);
- TextArea.TopViewedLine + 2) * TextArea.LineHeight);
{$IFDEF VerboseSynEditInvalidate}
DebugLn(['TCustomSynEdit.InvalidateGutterLines ',DbgSName(self), ' FirstLine=',FirstTextLine, ' LastLine=',LastTextLine, ' rect=',dbgs(rcInval)]);

View File

@ -83,7 +83,7 @@ begin
LineHeight := SynEdit.LineHeight;
c := SynEdit.Lines.Count;
t := ToIdx(GutterArea.TextArea.TopLine);
t := ToIdx(GutterArea.TextArea.TopViewedLine);
PaintBackground(Canvas, AClip);

View File

@ -193,7 +193,7 @@ begin
tmp := FoldView.FoldType[AScreenLine];
tmp2 := FoldView.FoldType[AScreenLine-1];
FIsFoldHidePreviousLine := False;
if (AScreenLine = 0) and (ToIdx(GutterArea.TextArea.TopLine) = 0) and
if (AScreenLine = 0) and (ToIdx(GutterArea.TextArea.TopViewedLine) = 0) and
(cfCollapsedHide in tmp2)
then begin
Result := cfCollapsedHide;
@ -536,7 +536,7 @@ var
ScrLine: Integer;
begin
Result := False;
ScrLine := ToIdx(AnInfo.NewCaret.ViewedLinePos) - ToIdx(GutterArea.TextArea.TopLine);
ScrLine := ToIdx(AnInfo.NewCaret.ViewedLinePos) - ToIdx(GutterArea.TextArea.TopViewedLine);
tmp := FoldTypeForLine(ScrLine);
case tmp of
cfCollapsedFold, cfCollapsedHide:
@ -562,7 +562,7 @@ begin
if (ACommand = emcNone) then exit;
line := AnInfo.NewCaret.LinePos;
ScrLine := ToIdx(AnInfo.NewCaret.ViewedLinePos) - ToIdx(GutterArea.TextArea.TopLine);
ScrLine := ToIdx(AnInfo.NewCaret.ViewedLinePos) - ToIdx(GutterArea.TextArea.TopViewedLine);
// TODO: Keepvisible is incorrect, if the line can fold AND unfold, and the action does not match the symbol
@ -572,7 +572,7 @@ begin
if (FoldTypeForLine(ScrLine) = cfCollapsedHide) then begin
if IsFoldHidePreviousLine(ScrLine) then
line := ToPos(ViewedTextBuffer.DisplayView.ViewToTextIndex(ScrLine - 1 + ToIdx(GutterArea.TextArea.TopLine)));
line := ToPos(ViewedTextBuffer.DisplayView.ViewToTextIndex(ScrLine - 1 + ToIdx(GutterArea.TextArea.TopViewedLine)));
inc(line);
KeepVisible := 0;
end

View File

@ -244,7 +244,7 @@ begin
LineHeight := SynEdit.LineHeight;
c := SynEdit.Lines.Count;
t := ToIdx(GutterArea.TextArea.TopLine);
t := ToIdx(GutterArea.TextArea.TopViewedLine);
// Changed to use fTextDrawer.BeginDrawing and fTextDrawer.EndDrawing only
// when absolutely necessary. Note: Never change brush / pen / font of the
// canvas inside of this block (only through methods of fTextDrawer)!

View File

@ -358,7 +358,7 @@ begin
aFirstCustomColumnIdx := 0;
if (FBookMarkOpt.DrawBookmarksFirst) then
aFirstCustomColumnIdx := 1;
aScreenLine := aScreenLine + ToIdx(GutterArea.TextArea.TopLine);
aScreenLine := aScreenLine + ToIdx(GutterArea.TextArea.TopViewedLine);
j := ViewedTextBuffer.DisplayView.ViewToTextIndexEx(aScreenLine, iRange);
if aScreenLine <> iRange.Top then
exit;

View File

@ -1531,7 +1531,7 @@ begin
txt := TLazSynTextArea.Create(AOwner, FOriginalManager.TextArea.TextDrawer);
txt.Assign(FOriginalManager.TextArea);
txt.TopLine := 1;
txt.TopViewedLine := 1;
txt.LeftChar := 1;
lgutter:= TSourceLazSynSurfaceGutter.Create(AOwner);
@ -2699,7 +2699,7 @@ var
begin
CheckTextBuffer;
aScreenLine2 := aScreenLine + ToIdx(GutterArea.TextArea.TopLine);
aScreenLine2 := aScreenLine + ToIdx(GutterArea.TextArea.TopViewedLine);
TxtIdx:= ViewedTextBuffer.DisplayView.ViewToTextIndexEx(aScreenLine2, iRange);
FCurLineHasDebugMark := (aScreenLine2 = iRange.Top) and (aScreenLine2 >= 0) and
(TxtIdx >= 0) and (TxtIdx < TSynEdit(SynEdit).Lines.Count) and