mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-28 01:29:12 +02:00
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:
parent
a11d2db8f4
commit
dde5b39675
@ -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;
|
||||
|
@ -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'),
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user