mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-05 17:37:21 +01:00
SynEdit: Move FoldedAtTextIndex from folded view to TSynEditStrings.IsTextIdxVisible / Improve FindNextUnfoldedLine
git-svn-id: trunk@63414 -
This commit is contained in:
parent
2b2844292f
commit
b0e6dc49cf
@ -358,6 +358,7 @@ type
|
||||
function ViewToTextIndex(aViewIndex : TLineIdx) : TLineIdx; virtual;
|
||||
|
||||
function AddVisibleOffsetToTextIndex(aTextIndex: TLineIdx; LineOffset : Integer) : TLineIdx; virtual; (* Add/Sub to/from TextIndex (0-based) skipping invisible (folded) *)
|
||||
function IsTextIdxVisible(aTextIndex: TLineIdx): Boolean; virtual;
|
||||
procedure GetInfoForViewedXY(AViewedXY: TPhysPoint; AFlags: TViewedXYInfoFlags; out AViewedXYInfo: TViewedXYInfo);
|
||||
// ViewedToPhysAndLog
|
||||
(* Convert between TextBuffer and ViewedText
|
||||
@ -521,6 +522,7 @@ type
|
||||
function ViewToTextIndex(aViewIndex : TLineIdx) : TLineIdx; override;
|
||||
|
||||
function AddVisibleOffsetToTextIndex(aTextIndex: TLineIdx; LineOffset: Integer): TLineIdx; override;
|
||||
function IsTextIdxVisible(aTextIndex: TLineIdx): Boolean; override;
|
||||
// ViewedToPhysAndLog
|
||||
(* Convert between TextBuffer and ViewedText
|
||||
X/Y are all 1-based
|
||||
@ -1298,6 +1300,11 @@ begin
|
||||
Result := aTextIndex + LineOffset;
|
||||
end;
|
||||
|
||||
function TSynEditStrings.IsTextIdxVisible(aTextIndex: TLineIdx): Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TSynEditStrings.GetInfoForViewedXY(AViewedXY: TPhysPoint;
|
||||
AFlags: TViewedXYInfoFlags; out AViewedXYInfo: TViewedXYInfo);
|
||||
begin
|
||||
@ -1794,6 +1801,11 @@ begin
|
||||
Result := fSynStrings.AddVisibleOffsetToTextIndex(aTextIndex, LineOffset);
|
||||
end;
|
||||
|
||||
function TSynEditStringsLinked.IsTextIdxVisible(aTextIndex: TLineIdx): Boolean;
|
||||
begin
|
||||
Result := fSynStrings.IsTextIdxVisible(aTextIndex);
|
||||
end;
|
||||
|
||||
function TSynEditStringsLinked.ViewXYToTextXY(APhysViewXY: TPhysPoint
|
||||
): TPhysPoint;
|
||||
begin
|
||||
|
||||
@ -4245,13 +4245,11 @@ function TCustomSynEdit.FindNextUnfoldedLine(iLine: integer; Down: boolean
|
||||
): Integer;
|
||||
// iLine is 1 based
|
||||
begin
|
||||
Result:=iLine;
|
||||
Result := FTheLinesView.TextToViewIndex(ToIdx(iLine));
|
||||
if Down then
|
||||
while (Result<FTheLinesView.Count) and (FFoldedLinesView.FoldedAtTextIndex[Result-1]) do
|
||||
inc(Result)
|
||||
Result := ToPos(FTheLinesView.ViewToTextIndex(Result+1))
|
||||
else
|
||||
while (Result>1) and (FFoldedLinesView.FoldedAtTextIndex[Result-1]) do
|
||||
dec(Result);
|
||||
Result := ToPos(FTheLinesView.ViewToTextIndex(Result));
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.CreateGutter(AOwner : TSynEditBase; ASide: TSynGutterSide;
|
||||
@ -4940,10 +4938,8 @@ var
|
||||
NewTopView: Integer;
|
||||
begin
|
||||
// TODO : Above hidden line only if folded, if hidden then use below
|
||||
if FFoldedLinesView.FoldedAtTextIndex[Value-1] then
|
||||
if not FTheLinesView.IsTextIdxVisible(ToIdx(Value)) then
|
||||
Value := FindNextUnfoldedLine(Value, False);
|
||||
if FFoldedLinesView.FoldedAtTextIndex[Value-1] then
|
||||
Value := FindNextUnfoldedLine(Value, True);
|
||||
|
||||
if not HandleAllocated then
|
||||
Include(fStateFlags, sfExplicitTopLine);
|
||||
@ -7038,7 +7034,7 @@ begin
|
||||
ecSmartWordLeft, ecSelSmartWordLeft: CaretNew := PrevWordLogicalPos(swbWordSmart);
|
||||
else CaretNew := PrevWordLogicalPos;
|
||||
end;
|
||||
if FFoldedLinesView.FoldedAtTextIndex[CaretNew.Y - 1] then begin
|
||||
if not FTheLinesView.IsTextIdxVisible(ToIdx(CaretNew.Y)) then begin
|
||||
CY := FindNextUnfoldedLine(CaretNew.Y, False);
|
||||
CaretNew := Point(1 + Length(FTheLinesView[CY-1]), CY);
|
||||
end;
|
||||
@ -7054,7 +7050,7 @@ begin
|
||||
ecSmartWordRight, ecSelSmartWordRight: CaretNew := NextWordLogicalPos(swbWordSmart);
|
||||
else CaretNew := NextWordLogicalPos;
|
||||
end;
|
||||
if FFoldedLinesView.FoldedAtTextIndex[CaretNew.Y - 1] then
|
||||
if not FTheLinesView.IsTextIdxVisible(ToIdx(CaretNew.Y)) then
|
||||
CaretNew := Point(1, FindNextUnfoldedLine(CaretNew.Y, True));
|
||||
FCaret.LineBytePos := CaretNew;
|
||||
end;
|
||||
|
||||
@ -455,6 +455,7 @@ type
|
||||
function ScreenLineToTextIndex(aLine : Integer) : Integer; (* Convert Screen (0-based) to TextIndex (0-based) *)
|
||||
|
||||
function AddVisibleOffsetToTextIndex(aTextIndex: TLineIdx; LineOffset: Integer): TLineIdx; override; (* Add/Sub to/from TextPos (1-based) skipping folded *)
|
||||
function IsTextIdxVisible(aTextIndex: TLineIdx): Boolean; override;
|
||||
|
||||
property BlockSelection: TSynEditSelection write SetBlockSelection;
|
||||
// Attributes for Visible-Lines-On-screen
|
||||
@ -3270,6 +3271,13 @@ begin
|
||||
// Result := inherited AddVisibleOffsetToTextIndex(aTextIndex, LineOffset);
|
||||
end;
|
||||
|
||||
function TSynEditFoldedView.IsTextIdxVisible(aTextIndex: TLineIdx): Boolean;
|
||||
begin
|
||||
Result := not FoldedAtTextIndex[aTextIndex];
|
||||
if Result then
|
||||
Result := inherited IsTextIdxVisible(aTextIndex);
|
||||
end;
|
||||
|
||||
procedure TSynEditFoldedView.Lock;
|
||||
begin
|
||||
if fLockCount=0 then begin
|
||||
|
||||
Loading…
Reference in New Issue
Block a user