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