mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 22:58:50 +02:00
SynEdit: WrappedView, keep topline when rewrapping
This commit is contained in:
parent
507e0d9ceb
commit
aac3d8d8db
@ -914,7 +914,6 @@ type
|
||||
procedure SetSelEnd(const Value: integer); override;
|
||||
procedure SetSelStart(const Value: integer); override;
|
||||
property TextView : TSynEditStringsLinked read FTheLinesView;
|
||||
property TopView: Integer read GetTopView write SetTopView; // TopLine converted into Visible(View) lines
|
||||
function PasteFromClipboardEx(ClipHelper: TSynClipboardStream; AForceColumnMode: Boolean = False): Boolean;
|
||||
function FindNextUnfoldedLine(iLine: integer; Down: boolean): Integer;
|
||||
// Todo: Reduce the argument list of Creategutter
|
||||
@ -931,6 +930,7 @@ type
|
||||
procedure EndUpdate; override;
|
||||
|
||||
public
|
||||
property TopView: Integer read GetTopView write SetTopView; // TopLine converted into Visible(View) lines
|
||||
// Caret
|
||||
function CaretXPix: Integer; override;
|
||||
function CaretYPix: Integer; override;
|
||||
|
@ -2405,9 +2405,15 @@ end;
|
||||
procedure TLazSynEditLineWrapPlugin.ValidateAll;
|
||||
var
|
||||
AMaxWidth, i, w: Integer;
|
||||
LowLine, HighLine: TLineIdx;
|
||||
LowLine, HighLine, TopViewIdx, TopLineIdx, TopSubLine: TLineIdx;
|
||||
tsub: TLineRange;
|
||||
begin
|
||||
if not FLineMapView.Tree.NeedsValidation then exit;
|
||||
if not FLineMapView.Tree.NeedsValidation then exit;
|
||||
|
||||
TopViewIdx := ToIdx(TSynEdit(Editor).TopView);
|
||||
TopLineIdx := ViewedTextBuffer.DisplayView.ViewToTextIndexEx(TopViewIdx, tsub);
|
||||
TopSubLine := TopViewIdx - tsub.Top;
|
||||
|
||||
AMaxWidth := WrapColumn;
|
||||
|
||||
while FLineMapView.Tree.NextBlockForValidation(LowLine, HighLine) do begin
|
||||
@ -2418,6 +2424,10 @@ if not FLineMapView.Tree.NeedsValidation then exit;
|
||||
end;
|
||||
FLineMapView.Tree.EndValidate;
|
||||
FLineMapView.SendNotification(senrLineMappingChanged, FLineMapView, 0, 0);
|
||||
|
||||
tsub := ViewedTextBuffer.DisplayView.TextToViewIndex(TopLineIdx);
|
||||
TSynEdit(Editor).Topview := ToPos(tsub.Top + Min(TopSubLine, tsub.Bottom - tsub.Top));
|
||||
|
||||
TSynEdit(Editor).Invalidate;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user