SynEdit: Add ec-commands for "move line up/down", "duplicate line", "copy/cut add to existing clipboard", "copy/cut (add) line/sel to clip"

git-svn-id: trunk@62185 -
This commit is contained in:
martin 2019-11-04 00:09:24 +00:00
parent a11d2db8f4
commit dde5b39675
3 changed files with 96 additions and 7 deletions

View File

@ -7100,6 +7100,74 @@ begin
begin
if not ReadOnly then PasteFromClipboard;
end;
ecCopyAdd, ecCutAdd:
if SelAvail then begin
Temp := Clipboard.AsText;
Helper := SelText;
if (Temp <> '') and (not (Temp[Length(Temp)] in [#10,#13, #9, #32])) and
(not (Helper[1] in [#10,#13, #9, #32]))
then
Temp := Temp + ' ';
Clipboard.AsText := Temp + Helper;
if (not ReadOnly) and (Command = ecCutAdd) then
SelText := '';
end;
ecCopyCurrentLine, ecCutCurrentLine,
ecCopyAddCurrentLine, ecCutAddCurrentLine:
begin
FInternalBlockSelection.AssignFrom(FBlockSelection);
FInternalBlockSelection.ActiveSelectionMode := smLine;
FInternalBlockSelection.ForceSingleLineSelected := True;
Temp := '';
if (Command = ecCopyAddCurrentLine) or (Command = ecCutAddCurrentLine) then begin
Temp := Clipboard.AsText;
if (Temp <> '') and not (Temp[Length(Temp)] in [#10,#13]) then
Temp := Temp + LineEnding;
end;
Clipboard.AsText := Temp + FInternalBlockSelection.SelText;
if (not ReadOnly) and ((Command = ecCutCurrentLine) or (Command = ecCutAddCurrentLine)) then begin
FCaret.IncAutoMoveOnEdit;
FInternalBlockSelection.SelText := '';
FCaret.DecAutoMoveOnEdit;
end;
FInternalBlockSelection.ForceSingleLineSelected := False;
end;
ecMoveLineUp:
if (not ReadOnly) then begin
CY := BlockBegin.y;
if CY > 1 then begin
FBlockSelection.IncPersistentLock;
FCaret.IncAutoMoveOnEdit;
FTheLinesView.EditLinesInsert(BlockEnd.y + 1, 1, FTheLinesView[ToIdx(CY) - 1]);
FTheLinesView.EditLinesDelete(CY - 1, 1);
FCaret.DecAutoMoveOnEdit;
FBlockSelection.DecPersistentLock;
end;
end;
ecMoveLineDown:
if (not ReadOnly) then begin
CY := BlockEnd.y;
if CY < FTheLinesView.Count - 1 then begin
FBlockSelection.IncPersistentLock;
FCaret.IncAutoMoveOnEdit;
FTheLinesView.EditLinesInsert(BlockBegin.y, 1, FTheLinesView[ToIdx(CY) + 1]);
FTheLinesView.EditLinesDelete(CY + 2, 1);
FCaret.DecAutoMoveOnEdit;
FBlockSelection.DecPersistentLock;
end;
end;
ecDuplicateLine:
if (not ReadOnly) then begin
FBlockSelection.IncPersistentLock;
FInternalBlockSelection.AssignFrom(FBlockSelection);
FInternalBlockSelection.ActiveSelectionMode := smLine;
FInternalBlockSelection.ForceSingleLineSelected := True;
Temp := FInternalBlockSelection.SelText;
FInternalBlockSelection.ForceSingleLineSelected := False;
FInternalBlockSelection.StartLineBytePos := Point(1, FInternalBlockSelection.LastLineBytePos.y+1);
FInternalBlockSelection.SelText := Temp;
FBlockSelection.DecPersistentLock;
end;
ecScrollUp:
begin
TopView := TopView - 1;

View File

@ -258,10 +258,17 @@ const
ecCut = 603; // Cut selection to clipboard
ecPaste = 604; // Paste clipboard to current position
ecBlockIndent = 610; // Indent selection
ecBlockUnindent = 611; // Unindent selection
ecTab = 612; // Tab key
ecShiftTab = 613; // Shift+Tab key
ecCopyAdd = 605; // add selection to existing clipboard (space separated, unless whitespace exists)
ecCutAdd = 606; //
ecCopyCurrentLine = 607; // copy current line (or all covered at least partly by selection) to clipboard
ecCopyAddCurrentLine = 608; // add to existing clipboard
ecCutCurrentLine = 609; //
ecCutAddCurrentLine = 610; //
ecBlockIndent = 615; // Indent selection
ecBlockUnindent = 616; // Unindent selection
ecTab = 617; // Tab key
ecShiftTab = 618; // Shift+Tab key
ecUpperCase = 620; // apply to the current or previous word
ecLowerCase = 621;
@ -271,7 +278,11 @@ const
ecLowerCaseBlock = 626;
ecToggleCaseBlock = 627;
ecString = 630; //Insert a whole string
ecMoveLineUp = 630; // Moves current line (or selection) one line up
ecMoveLineDown = 631; // Moves current line (or selection) one line down
ecDuplicateLine = 632; // Line or selection (full lines)
ecString = 640; //Insert a whole string
ecAutoCompletion = 650;
@ -495,7 +506,7 @@ end;
{ Command mapping routines }
const
EditorCommandStrs: array[0..157] of TIdentMapEntry = (
EditorCommandStrs: array[0..166] of TIdentMapEntry = (
(Value: ecNone; Name: 'ecNone'),
(Value: ecLeft; Name: 'ecLeft'),
(Value: ecRight; Name: 'ecRight'),
@ -584,6 +595,15 @@ const
(Value: ecCut; Name: 'ecCut'),
(Value: ecCopy; Name: 'ecCopy'),
(Value: ecPaste; Name: 'ecPaste'),
(Value: ecCopyAdd; Name: 'ecCopyAdd'),
(Value: ecCutAdd; Name: 'ecCutAdd'),
(Value: ecCopyCurrentLine; Name: 'ecCopyCurrentLine'),
(Value: ecCopyAddCurrentLine; Name: 'ecCopyAddCurrentLine'),
(Value: ecCutCurrentLine; Name: 'ecCutCurrentLine'),
(Value: ecCutAddCurrentLine; Name: 'ecCutAddCurrentLine'),
(Value: ecMoveLineUp; Name: 'ecMoveLineUp'),
(Value: ecMoveLineDown; Name: 'ecMoveLineDown'),
(Value: ecDuplicateLine; Name: 'ecDuplicateLine'),
(Value: ecScrollUp; Name: 'ecScrollUp'),
(Value: ecScrollDown; Name: 'ecScrollDown'),
(Value: ecScrollLeft; Name: 'ecScrollLeft'),

View File

@ -2629,7 +2629,8 @@ begin
Action := ccaDefaultAction;
case Command of
ecCopy, ecCut: Action := ccaNoneRepeatCommand;
ecCopy, ecCut,
ecCopyCurrentLine, ecCutCurrentLine: Action := ccaNoneRepeatCommand;
ecGotoMarker0..ecGotoMarker9: Action := ccaClearCarets;
ecSelectAll: Action := ccaClearCarets;
ecDeleteChar: if smcoDeleteSkipLineBreak in Options then