mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 07:19:18 +02:00
SynEdit: fix issue with setting caret and then topline, if the handle is not yet created. TopLIne was ignored, even if it was set after caret.
git-svn-id: trunk@48404 -
This commit is contained in:
parent
f95d44c481
commit
5cde3a8237
@ -184,6 +184,7 @@ type
|
|||||||
|
|
||||||
TSynStateFlag = (sfCaretChanged, sfHideCursor,
|
TSynStateFlag = (sfCaretChanged, sfHideCursor,
|
||||||
sfEnsureCursorPos, sfEnsureCursorPosAtResize,
|
sfEnsureCursorPos, sfEnsureCursorPosAtResize,
|
||||||
|
sfExplicitTopLine, sfExplicitLeftChar, // when doing EnsureCursorPos keep top/Left, if they where set explicitly after the caret (only applies before handle creation)
|
||||||
sfIgnoreNextChar, sfPainting, sfHasPainted, sfHasScrolled,
|
sfIgnoreNextChar, sfPainting, sfHasPainted, sfHasScrolled,
|
||||||
sfScrollbarChanged, sfHorizScrollbarVisible, sfVertScrollbarVisible,
|
sfScrollbarChanged, sfHorizScrollbarVisible, sfVertScrollbarVisible,
|
||||||
sfAfterLoadFromFileNeeded,
|
sfAfterLoadFromFileNeeded,
|
||||||
@ -4353,6 +4354,7 @@ end;
|
|||||||
procedure TCustomSynEdit.CaretChanged(Sender: TObject);
|
procedure TCustomSynEdit.CaretChanged(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Include(fStateFlags, sfCaretChanged);
|
Include(fStateFlags, sfCaretChanged);
|
||||||
|
fStateFlags := fStateFlags - [sfExplicitTopLine, sfExplicitLeftChar];
|
||||||
if FCaret.OldCharPos <> FCaret.CharPos then
|
if FCaret.OldCharPos <> FCaret.CharPos then
|
||||||
Include(fStatusChanges, scCaretX);
|
Include(fStatusChanges, scCaretX);
|
||||||
if FCaret.OldLinePos <> FCaret.LinePos then begin
|
if FCaret.OldLinePos <> FCaret.LinePos then begin
|
||||||
@ -4389,6 +4391,8 @@ begin
|
|||||||
//{BUG21996} DebugLn(['TCustomSynEdit.SetLeftChar=',Value,' Caret=',dbgs(CaretXY),', BlockBegin=',dbgs(BlockBegin),' BlockEnd=',dbgs(BlockEnd), ' StateFlags=',dbgs(fStateFlags), ' paintlock', FPaintLock]);
|
//{BUG21996} DebugLn(['TCustomSynEdit.SetLeftChar=',Value,' Caret=',dbgs(CaretXY),', BlockBegin=',dbgs(BlockBegin),' BlockEnd=',dbgs(BlockEnd), ' StateFlags=',dbgs(fStateFlags), ' paintlock', FPaintLock]);
|
||||||
Value := Min(Value, CurrentMaxLeftChar);
|
Value := Min(Value, CurrentMaxLeftChar);
|
||||||
Value := Max(Value, 1);
|
Value := Max(Value, 1);
|
||||||
|
if not HandleAllocated then
|
||||||
|
Include(fStateFlags, sfExplicitLeftChar);
|
||||||
if Value <> FTextArea.LeftChar then begin
|
if Value <> FTextArea.LeftChar then begin
|
||||||
FTextArea.LeftChar := Value;
|
FTextArea.LeftChar := Value;
|
||||||
UpdateScrollBars;
|
UpdateScrollBars;
|
||||||
@ -4510,6 +4514,8 @@ begin
|
|||||||
if FFoldedLinesView.FoldedAtTextIndex[Value-1] then
|
if FFoldedLinesView.FoldedAtTextIndex[Value-1] then
|
||||||
Value := FindNextUnfoldedLine(Value, True);
|
Value := FindNextUnfoldedLine(Value, True);
|
||||||
|
|
||||||
|
if not HandleAllocated then
|
||||||
|
Include(fStateFlags, sfExplicitTopLine);
|
||||||
NewTopView := FFoldedLinesView.TextIndexToViewPos(Value-1);
|
NewTopView := FFoldedLinesView.TextIndexToViewPos(Value-1);
|
||||||
if NewTopView <> TopView then begin
|
if NewTopView <> TopView then begin
|
||||||
TopView := NewTopView;
|
TopView := NewTopView;
|
||||||
@ -5108,6 +5114,9 @@ begin
|
|||||||
AValue := Min(AValue, CurrentMaxTopView);
|
AValue := Min(AValue, CurrentMaxTopView);
|
||||||
AValue := Max(AValue, 1);
|
AValue := Max(AValue, 1);
|
||||||
|
|
||||||
|
if not HandleAllocated then
|
||||||
|
Include(fStateFlags, sfExplicitTopLine);
|
||||||
|
|
||||||
(* ToDo: FFoldedLinesView.TopLine := AValue;
|
(* ToDo: FFoldedLinesView.TopLine := AValue;
|
||||||
Required, if "TopView := TopView" or "TopLine := TopLine" is called,
|
Required, if "TopView := TopView" or "TopLine := TopLine" is called,
|
||||||
after ScanRanges (used to be: LineCountChanged / LineTextChanged)
|
after ScanRanges (used to be: LineCountChanged / LineTextChanged)
|
||||||
@ -6248,24 +6257,28 @@ begin
|
|||||||
MaxX:=Min(PhysBlockEndXY.X,MinX+CharsInWindow-1);
|
MaxX:=Min(PhysBlockEndXY.X,MinX+CharsInWindow-1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{DebugLn('TCustomSynEdit.EnsureCursorPosVisible A CaretX=',dbgs(PhysCaretXY.X),
|
if not (sfExplicitLeftChar in fStateFlags) then begin
|
||||||
' BlockX=',dbgs(PhysBlockBeginXY.X)+'-'+dbgs(PhysBlockEndXY.X),
|
{DebugLn('TCustomSynEdit.EnsureCursorPosVisible A CaretX=',dbgs(PhysCaretXY.X),
|
||||||
' CharsInWindow='+dbgs(CharsInWindow), MinX='+dbgs(MinX),' MaxX='+dbgs(MaxX),
|
' BlockX=',dbgs(PhysBlockBeginXY.X)+'-'+dbgs(PhysBlockEndXY.X),
|
||||||
' LeftChar='+dbgs(LeftChar), '');}
|
' CharsInWindow='+dbgs(CharsInWindow), MinX='+dbgs(MinX),' MaxX='+dbgs(MaxX),
|
||||||
if MinX < LeftChar then
|
' LeftChar='+dbgs(LeftChar), '');}
|
||||||
LeftChar := MinX
|
if MinX < LeftChar then
|
||||||
else if LeftChar < MaxX - (Max(1, CharsInWindow) - 1 - FScreenCaret.ExtraLineChars) then
|
LeftChar := MinX
|
||||||
LeftChar := MaxX - (Max(1, CharsInWindow) - 1 - FScreenCaret.ExtraLineChars)
|
else if LeftChar < MaxX - (Max(1, CharsInWindow) - 1 - FScreenCaret.ExtraLineChars) then
|
||||||
else
|
LeftChar := MaxX - (Max(1, CharsInWindow) - 1 - FScreenCaret.ExtraLineChars)
|
||||||
LeftChar := LeftChar; //mh 2000-10-19
|
else
|
||||||
//DebugLn(['TCustomSynEdit.EnsureCursorPosVisible B LeftChar=',LeftChar,' MinX=',MinX,' MaxX=',MaxX,' CharsInWindow=',CharsInWindow]);
|
LeftChar := LeftChar; //mh 2000-10-19
|
||||||
// Make sure Y is visible
|
end;
|
||||||
if CaretY < TopLine then
|
if not (sfExplicitTopLine in fStateFlags) then begin
|
||||||
TopLine := CaretY
|
//DebugLn(['TCustomSynEdit.EnsureCursorPosVisible B LeftChar=',LeftChar,' MinX=',MinX,' MaxX=',MaxX,' CharsInWindow=',CharsInWindow]);
|
||||||
else if CaretY > ScreenRowToRow(Max(1, LinesInWindow) - 1) then //mh 2000-10-19
|
// Make sure Y is visible
|
||||||
TopLine := FFoldedLinesView.TextPosAddLines(CaretY, -Max(0, LinesInWindow-1))
|
if CaretY < TopLine then
|
||||||
else
|
TopLine := CaretY
|
||||||
TopView := TopView; //mh 2000-10-19
|
else if CaretY > ScreenRowToRow(Max(1, LinesInWindow) - 1) then //mh 2000-10-19
|
||||||
|
TopLine := FFoldedLinesView.TextPosAddLines(CaretY, -Max(0, LinesInWindow-1))
|
||||||
|
else
|
||||||
|
TopView := TopView; //mh 2000-10-19
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
DoDecPaintLock(Self);
|
DoDecPaintLock(Self);
|
||||||
//{BUG21996} DebugLnExit(['TCustomSynEdit.EnsureCursorPosVisible Caret=',dbgs(CaretXY),', BlockBegin=',dbgs(BlockBegin),' BlockEnd=',dbgs(BlockEnd), ' StateFlags=',dbgs(fStateFlags), ' paintlock', FPaintLock]);
|
//{BUG21996} DebugLnExit(['TCustomSynEdit.EnsureCursorPosVisible Caret=',dbgs(CaretXY),', BlockBegin=',dbgs(BlockBegin),' BlockEnd=',dbgs(BlockEnd), ' StateFlags=',dbgs(fStateFlags), ' paintlock', FPaintLock]);
|
||||||
|
Loading…
Reference in New Issue
Block a user