mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 18:20:41 +02:00
SynEdit: add option eoNoScrollOnSelectRange, to prevent scroll on select all/paragraph/to-brace // Fix select-to-brace to scroll by default.
git-svn-id: trunk@62181 -
This commit is contained in:
parent
546b5cedd7
commit
97e5dde402
@ -219,6 +219,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)
|
sfExplicitTopLine, sfExplicitLeftChar, // when doing EnsureCursorPos keep top/Left, if they where set explicitly after the caret (only applies before handle creation)
|
||||||
|
sfPreventScrollAfterSelect,
|
||||||
sfIgnoreNextChar, sfPainting, sfHasPainted, sfHasScrolled,
|
sfIgnoreNextChar, sfPainting, sfHasPainted, sfHasScrolled,
|
||||||
sfScrollbarChanged, sfHorizScrollbarVisible, sfVertScrollbarVisible,
|
sfScrollbarChanged, sfHorizScrollbarVisible, sfVertScrollbarVisible,
|
||||||
sfAfterLoadFromFileNeeded,
|
sfAfterLoadFromFileNeeded,
|
||||||
@ -286,7 +287,8 @@ type
|
|||||||
eoOverwriteBlock, // Allows to overwrite currently selected block, when pasting or typing new text
|
eoOverwriteBlock, // Allows to overwrite currently selected block, when pasting or typing new text
|
||||||
eoAutoHideCursor, // Hide mouse cursor, when new text is typed
|
eoAutoHideCursor, // Hide mouse cursor, when new text is typed
|
||||||
eoColorSelectionTillEol, // Colorize selection background only till EOL of each line, not till edge of control
|
eoColorSelectionTillEol, // Colorize selection background only till EOL of each line, not till edge of control
|
||||||
eoPersistentCaretStopBlink // only if eoPersistentCaret > do not blink, draw fixed line
|
eoPersistentCaretStopBlink,// only if eoPersistentCaret > do not blink, draw fixed line
|
||||||
|
eoNoScrollOnSelectRange // SelectALl, SelectParagraph, SelectToBrace will not scroll
|
||||||
);
|
);
|
||||||
TSynEditorOptions2 = set of TSynEditorOption2;
|
TSynEditorOptions2 = set of TSynEditorOption2;
|
||||||
|
|
||||||
@ -4434,6 +4436,8 @@ begin
|
|||||||
LastPt.y := 1;
|
LastPt.y := 1;
|
||||||
SetCaretAndSelection(LogicalToPhysicalPos(LastPt), Point(1, 1), LastPt);
|
SetCaretAndSelection(LogicalToPhysicalPos(LastPt), Point(1, 1), LastPt);
|
||||||
FBlockSelection.ActiveSelectionMode := smNormal;
|
FBlockSelection.ActiveSelectionMode := smNormal;
|
||||||
|
if eoNoScrollOnSelectRange in FOptions2 then
|
||||||
|
Include(fStateFlags, sfPreventScrollAfterSelect);
|
||||||
DoDecPaintLock(Self);
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4446,7 +4450,11 @@ end;
|
|||||||
|
|
||||||
procedure TCustomSynEdit.SelectToBrace;
|
procedure TCustomSynEdit.SelectToBrace;
|
||||||
begin
|
begin
|
||||||
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
FindMatchingBracket(CaretXY,true,true,true,false);
|
FindMatchingBracket(CaretXY,true,true,true,false);
|
||||||
|
if eoNoScrollOnSelectRange in FOptions2 then
|
||||||
|
Include(fStateFlags, sfPreventScrollAfterSelect);
|
||||||
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.SelectWord;
|
procedure TCustomSynEdit.SelectWord;
|
||||||
@ -5481,6 +5489,8 @@ begin
|
|||||||
FBlockSelection.ActiveSelectionMode := smNormal;
|
FBlockSelection.ActiveSelectionMode := smNormal;
|
||||||
CaretXY := FBlockSelection.EndLineBytePos;
|
CaretXY := FBlockSelection.EndLineBytePos;
|
||||||
//DebugLn(' FFF3 ',Value.X,',',Value.Y,' BlockBegin=',BlockBegin.X,',',BlockBegin.Y,' BlockEnd=',BlockEnd.X,',',BlockEnd.Y);
|
//DebugLn(' FFF3 ',Value.X,',',Value.Y,' BlockBegin=',BlockBegin.X,',',BlockBegin.Y,' BlockEnd=',BlockEnd.X,',',BlockEnd.Y);
|
||||||
|
if eoNoScrollOnSelectRange in FOptions2 then
|
||||||
|
Include(fStateFlags, sfPreventScrollAfterSelect);
|
||||||
DoDecPaintLock(Self);
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -6517,28 +6527,31 @@ begin
|
|||||||
MaxX:=Min(PhysBlockEndXY.X,MinX+CharsInWindow-1);
|
MaxX:=Min(PhysBlockEndXY.X,MinX+CharsInWindow-1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if not (sfExplicitLeftChar in fStateFlags) then begin
|
if not (sfPreventScrollAfterSelect in fStateFlags) then begin
|
||||||
{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
|
||||||
end;
|
LeftChar := LeftChar; //mh 2000-10-19
|
||||||
if not (sfExplicitTopLine in fStateFlags) then begin
|
end;
|
||||||
//DebugLn(['TCustomSynEdit.EnsureCursorPosVisible B LeftChar=',LeftChar,' MinX=',MinX,' MaxX=',MaxX,' CharsInWindow=',CharsInWindow]);
|
if not (sfExplicitTopLine in fStateFlags) then begin
|
||||||
// Make sure Y is visible
|
//DebugLn(['TCustomSynEdit.EnsureCursorPosVisible B LeftChar=',LeftChar,' MinX=',MinX,' MaxX=',MaxX,' CharsInWindow=',CharsInWindow]);
|
||||||
if CaretY < TopLine then
|
// Make sure Y is visible
|
||||||
TopLine := CaretY
|
if CaretY < TopLine then
|
||||||
else if CaretY > ScreenRowToRow(Max(1, LinesInWindow) - 1) then //mh 2000-10-19
|
TopLine := CaretY
|
||||||
TopLine := FFoldedLinesView.TextPosAddLines(CaretY, -Max(0, LinesInWindow-1))
|
else if CaretY > ScreenRowToRow(Max(1, LinesInWindow) - 1) then //mh 2000-10-19
|
||||||
else
|
TopLine := FFoldedLinesView.TextPosAddLines(CaretY, -Max(0, LinesInWindow-1))
|
||||||
TopView := TopView; //mh 2000-10-19
|
else
|
||||||
|
TopView := TopView; //mh 2000-10-19
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
Exclude(fStateFlags, sfPreventScrollAfterSelect);
|
||||||
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