mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 13:39:11 +02:00
Merged revision(s) 59971 #6bedb95bcd, 59983 #f3eefeade7 from trunk:
SynEdit: fix selection with smLine (include some selection via gutter) should include folded lines, if the "fold start" line gets selected. Issue #0034760 ........ SynEdit: Added checks for revision 59971 #6bedb95bcd (fix selection with smLine should include folded lines - Issue #0034760) - apply only if AutoExtend is true (indicates user input key/mouse) / Setting Selection from code should not be affected. ........ git-svn-id: branches/fixes_2_0@59995 -
This commit is contained in:
parent
91586cddc0
commit
c9d6f15be5
@ -2159,6 +2159,7 @@ begin
|
|||||||
FBlockSelection.Caret := FCaret;
|
FBlockSelection.Caret := FCaret;
|
||||||
FBlockSelection.InvalidateLinesMethod := @InvalidateLines;
|
FBlockSelection.InvalidateLinesMethod := @InvalidateLines;
|
||||||
FBlockSelection.AddChangeHandler(@DoBlockSelectionChanged);
|
FBlockSelection.AddChangeHandler(@DoBlockSelectionChanged);
|
||||||
|
FBlockSelection.{%H-}FoldedView := FFoldedLinesView;
|
||||||
|
|
||||||
FInternalBlockSelection := TSynEditSelection.Create(FTheLinesView, False);
|
FInternalBlockSelection := TSynEditSelection.Create(FTheLinesView, False);
|
||||||
FInternalBlockSelection.InvalidateLinesMethod := @InvalidateLines;
|
FInternalBlockSelection.InvalidateLinesMethod := @InvalidateLines;
|
||||||
@ -3300,7 +3301,9 @@ begin
|
|||||||
if (AnAction.Option <> emcoSelectionContinue) or (not SelAvail) then
|
if (AnAction.Option <> emcoSelectionContinue) or (not SelAvail) then
|
||||||
FBlockSelection.StartLineBytePos := FCaret.LineBytePos;
|
FBlockSelection.StartLineBytePos := FCaret.LineBytePos;
|
||||||
FBlockSelection.ActiveSelectionMode := smLine;
|
FBlockSelection.ActiveSelectionMode := smLine;
|
||||||
|
FBlockSelection.AutoExtend := True;
|
||||||
FBlockSelection.ForceSingleLineSelected := True;
|
FBlockSelection.ForceSingleLineSelected := True;
|
||||||
|
FBlockSelection.AutoExtend := AnAction.Option = emcoSelectionContinue;
|
||||||
end;
|
end;
|
||||||
emcStartSelectTokens, emcStartSelectWords, emcStartSelectLines: begin
|
emcStartSelectTokens, emcStartSelectWords, emcStartSelectLines: begin
|
||||||
FMouseSelectionCmd := ACommand;
|
FMouseSelectionCmd := ACommand;
|
||||||
|
@ -102,6 +102,7 @@ type
|
|||||||
|
|
||||||
TSynEditSelection = class(TSynEditPointBase)
|
TSynEditSelection = class(TSynEditPointBase)
|
||||||
private
|
private
|
||||||
|
FFoldedView: TObject;
|
||||||
FOnBeforeSetSelText: TSynBeforeSetSelTextList;
|
FOnBeforeSetSelText: TSynBeforeSetSelTextList;
|
||||||
FAutoExtend: Boolean;
|
FAutoExtend: Boolean;
|
||||||
FCaret: TSynEditCaret;
|
FCaret: TSynEditCaret;
|
||||||
@ -204,6 +205,8 @@ type
|
|||||||
property AutoExtend: Boolean read FAutoExtend write SetAutoExtend;
|
property AutoExtend: Boolean read FAutoExtend write SetAutoExtend;
|
||||||
property StickyAutoExtend: Boolean read FStickyAutoExtend write FStickyAutoExtend;
|
property StickyAutoExtend: Boolean read FStickyAutoExtend write FStickyAutoExtend;
|
||||||
property Hide: Boolean read FHide write SetHide;
|
property Hide: Boolean read FHide write SetHide;
|
||||||
|
|
||||||
|
property FoldedView: TObject read FFoldedView write FFoldedView; experimental; // until FoldedView becomes a TSynEditStrings
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TSynEditCaret }
|
{ TSynEditCaret }
|
||||||
@ -601,6 +604,9 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
SynEditFoldedView;
|
||||||
|
|
||||||
{ TSynBeforeSetSelTextList }
|
{ TSynBeforeSetSelTextList }
|
||||||
|
|
||||||
procedure TSynBeforeSetSelTextList.CallBeforeSetSelTextHandlers(Sender: TObject;
|
procedure TSynBeforeSetSelTextList.CallBeforeSetSelTextHandlers(Sender: TObject;
|
||||||
@ -2262,16 +2268,35 @@ var
|
|||||||
begin
|
begin
|
||||||
if FEnabled then begin
|
if FEnabled then begin
|
||||||
FStickyAutoExtend := False;
|
FStickyAutoExtend := False;
|
||||||
|
|
||||||
Value.y := MinMax(Value.y, 1, fLines.Count);
|
Value.y := MinMax(Value.y, 1, fLines.Count);
|
||||||
|
|
||||||
|
// ensure folded block at bottom line is in selection
|
||||||
|
if (ActiveSelectionMode = smLine) and (FFoldedView <> nil) and
|
||||||
|
(FAutoExtend or FStickyAutoExtend)
|
||||||
|
then begin
|
||||||
|
if ( (FStartLinePos > Value.y) or
|
||||||
|
( (FStartLinePos = Value.y) and (FStartBytePos > Value.x) )
|
||||||
|
) and
|
||||||
|
(not SelAvail)
|
||||||
|
then
|
||||||
|
FStartLinePos := TSynEditFoldedView(FFoldedView).TextPosAddLines(FStartLinePos, 1) - 1
|
||||||
|
else
|
||||||
|
if (Value.y < fLines.Count) then
|
||||||
|
Value.y := TSynEditFoldedView(FFoldedView).TextPosAddLines(Value.y, 1) - 1;
|
||||||
|
end;
|
||||||
|
|
||||||
if (FCaret = nil) or FCaret.AllowPastEOL then
|
if (FCaret = nil) or FCaret.AllowPastEOL then
|
||||||
Value.x := Max(Value.x, 1)
|
Value.x := Max(Value.x, 1)
|
||||||
else
|
else
|
||||||
Value.x := MinMax(Value.x, 1, length(Lines[Value.y - 1])+1);
|
Value.x := MinMax(Value.x, 1, length(Lines[Value.y - 1])+1);
|
||||||
|
|
||||||
if (ActiveSelectionMode = smNormal) then
|
if (ActiveSelectionMode = smNormal) then
|
||||||
if (Value.y >= 1) and (Value.y <= fLines.Count) then
|
if (Value.y >= 1) and (Value.y <= fLines.Count) then
|
||||||
Value.x := AdjustBytePosToCharacterStart(Value.y,Value.x)
|
Value.x := AdjustBytePosToCharacterStart(Value.y,Value.x)
|
||||||
else
|
else
|
||||||
Value.x := 1;
|
Value.x := 1;
|
||||||
|
|
||||||
if (Value.X <> FEndBytePos) or (Value.Y <> FEndLinePos) then begin
|
if (Value.X <> FEndBytePos) or (Value.Y <> FEndLinePos) then begin
|
||||||
{$IFDEF SYN_MBCSSUPPORT}
|
{$IFDEF SYN_MBCSSUPPORT}
|
||||||
if Value.Y <= fLines.Count then begin
|
if Value.Y <= fLines.Count then begin
|
||||||
@ -2325,6 +2350,14 @@ begin
|
|||||||
FForceSingleLineSelected := AValue;
|
FForceSingleLineSelected := AValue;
|
||||||
|
|
||||||
if WasAvail <> SelAvail then begin
|
if WasAvail <> SelAvail then begin
|
||||||
|
// ensure folded block at bottom line is in selection
|
||||||
|
// only when selection is new (WasAvail = False)
|
||||||
|
if SelAvail and (FAutoExtend or FStickyAutoExtend) then begin
|
||||||
|
if IsBackwardSel then
|
||||||
|
FStartLinePos := TSynEditFoldedView(FFoldedView).TextPosAddLines(FStartLinePos, 1) - 1
|
||||||
|
else
|
||||||
|
FEndLinePos := TSynEditFoldedView(FFoldedView).TextPosAddLines(FEndLinePos, 1) - 1;
|
||||||
|
end;
|
||||||
FInvalidateLinesMethod(Min(FStartLinePos, FEndLinePos),
|
FInvalidateLinesMethod(Min(FStartLinePos, FEndLinePos),
|
||||||
Max(FStartLinePos, FEndLinePos) );
|
Max(FStartLinePos, FEndLinePos) );
|
||||||
fOnChangeList.CallNotifyEvents(self);
|
fOnChangeList.CallNotifyEvents(self);
|
||||||
|
Loading…
Reference in New Issue
Block a user