mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-12 09:19:41 +02:00
SynEdit: Drag-Selection copy/move - Allow line/column selections Issue #0037431
git-svn-id: trunk@63758 -
This commit is contained in:
parent
447eff955c
commit
3efdc51977
@ -3607,7 +3607,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
emcStartDragMove:
|
emcStartDragMove:
|
||||||
begin
|
begin
|
||||||
if SelAvail and (SelectionMode = smNormal) then begin
|
if SelAvail then begin
|
||||||
Include(fStateFlags, sfWaitForDragging);
|
Include(fStateFlags, sfWaitForDragging);
|
||||||
if AnAction.Option = emcoNotDragedNoCaretOnUp then
|
if AnAction.Option = emcoNotDragedNoCaretOnUp then
|
||||||
Include(fStateFlags, sfWaitForDraggingNoCaret);
|
Include(fStateFlags, sfWaitForDraggingNoCaret);
|
||||||
@ -6443,12 +6443,13 @@ end;
|
|||||||
procedure TCustomSynEdit.DragDrop(Source: TObject; X, Y: Integer);
|
procedure TCustomSynEdit.DragDrop(Source: TObject; X, Y: Integer);
|
||||||
var
|
var
|
||||||
NewCaret: TPoint;
|
NewCaret: TPoint;
|
||||||
DropAfter, DropMove: boolean;
|
DropMove: boolean;
|
||||||
BB, BE: TPoint;
|
BB, BE: TPoint;
|
||||||
DragDropText: string;
|
DragDropText: string;
|
||||||
Adjust: integer;
|
Adjust: integer;
|
||||||
FoldInfo: String;
|
FoldInfo: String;
|
||||||
BlockSel: TSynEditSelection;
|
BlockSel: TSynEditSelection;
|
||||||
|
sm: TSynSelectionMode;
|
||||||
begin
|
begin
|
||||||
if not ReadOnly and (Source is TCustomSynEdit)
|
if not ReadOnly and (Source is TCustomSynEdit)
|
||||||
and TCustomSynEdit(Source).SelAvail
|
and TCustomSynEdit(Source).SelAvail
|
||||||
@ -6461,8 +6462,6 @@ begin
|
|||||||
if CheckDragDropAccecpt(NewCaret, Source, DropMove) then begin
|
if CheckDragDropAccecpt(NewCaret, Source, DropMove) then begin
|
||||||
BB := BlockBegin;
|
BB := BlockBegin;
|
||||||
BE := BlockEnd;
|
BE := BlockEnd;
|
||||||
DropAfter := (NewCaret.Y > BE.Y)
|
|
||||||
or ((NewCaret.Y = BE.Y) and (NewCaret.X >= BE.X));
|
|
||||||
InternalBeginUndoBlock; //mh 2000-11-20
|
InternalBeginUndoBlock; //mh 2000-11-20
|
||||||
try
|
try
|
||||||
DragDropText := TCustomSynEdit(Source).SelText;
|
DragDropText := TCustomSynEdit(Source).SelText;
|
||||||
@ -6471,32 +6470,29 @@ begin
|
|||||||
FoldInfo := TCustomSynEdit(Source).FFoldedLinesView.GetFoldDescription(
|
FoldInfo := TCustomSynEdit(Source).FFoldedLinesView.GetFoldDescription(
|
||||||
BlockSel.FirstLineBytePos.Y - 1, BlockSel.FirstLineBytePos.X,
|
BlockSel.FirstLineBytePos.Y - 1, BlockSel.FirstLineBytePos.X,
|
||||||
BlockSel.LastLineBytePos.Y - 1, BlockSel.LastLineBytePos.X);
|
BlockSel.LastLineBytePos.Y - 1, BlockSel.LastLineBytePos.X);
|
||||||
|
sm := BlockSel.ActiveSelectionMode;
|
||||||
|
if sm = smLine then
|
||||||
|
sm := smNormal;
|
||||||
|
|
||||||
// delete the selected text if necessary
|
// delete the selected text if necessary
|
||||||
if DropMove then begin
|
if DropMove then begin
|
||||||
if Source <> Self then
|
if Source <> Self then
|
||||||
TCustomSynEdit(Source).SelText := ''
|
TCustomSynEdit(Source).SelText := ''
|
||||||
else begin
|
else begin
|
||||||
SetSelTextExternal('');
|
FInternalCaret.AssignFrom(FCaret);
|
||||||
// adjust horizontal drop position
|
FInternalCaret.IncAutoMoveOnEdit;
|
||||||
if DropAfter and (NewCaret.Y = BE.Y) then begin
|
FBlockSelection.SelText := '';
|
||||||
if BB.Y = BE.Y then
|
FInternalCaret.DecAutoMoveOnEdit;
|
||||||
Adjust := BE.X - BB.X
|
NewCaret := FInternalCaret.LineBytePos;
|
||||||
else
|
|
||||||
Adjust := BE.X - 1;
|
|
||||||
Dec(NewCaret.X, Adjust);
|
|
||||||
end;
|
|
||||||
// adjust vertical drop position
|
|
||||||
if DropAfter and (BE.Y > BB.Y) then
|
|
||||||
Dec(NewCaret.Y, BE.Y - BB.Y);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// insert the selected text
|
// insert the selected text
|
||||||
FCaret.IncForcePastEOL;
|
FCaret.IncForcePastEOL;
|
||||||
try
|
try
|
||||||
if (eoPersistentBlock in Options2) and SelAvail then
|
if (eoPersistentBlock in Options2) and SelAvail then
|
||||||
SetTextBetweenPoints(NewCaret, NewCaret, DragDropText, [setMoveBlock], scamEnd, smaMoveUp, smNormal)
|
SetTextBetweenPoints(NewCaret, NewCaret, DragDropText, [setMoveBlock], scamEnd, smaMoveUp, sm)
|
||||||
else
|
else
|
||||||
SetTextBetweenPoints(NewCaret, NewCaret, DragDropText, [setSelect], scamEnd, smaMoveUp, smNormal);
|
SetTextBetweenPoints(NewCaret, NewCaret, DragDropText, [setSelect], scamEnd, smaMoveUp, sm);
|
||||||
if FoldInfo <> '' then begin
|
if FoldInfo <> '' then begin
|
||||||
ScanRanges;
|
ScanRanges;
|
||||||
FFoldedLinesView.ApplyFoldDescription(NewCaret.Y -1, NewCaret.X,
|
FFoldedLinesView.ApplyFoldDescription(NewCaret.Y -1, NewCaret.X,
|
||||||
|
Loading…
Reference in New Issue
Block a user