IDE, SynEdit: ecPasteAsColums, paste clipboard - forcing column mode

git-svn-id: trunk@63118 -
This commit is contained in:
martin 2020-05-05 14:40:11 +00:00
parent 6dd8905c57
commit 42226b563a
4 changed files with 16 additions and 8 deletions

View File

@ -926,7 +926,7 @@ type
procedure SetSelStart(const Value: integer);
property TextView : TSynEditFoldedView read FFoldedLinesView;
property TopView: Integer read GetTopView write SetTopView; // TopLine converted into Visible(View) lines
function PasteFromClipboardEx(ClipHelper: TSynClipboardStream): Boolean;
function PasteFromClipboardEx(ClipHelper: TSynClipboardStream; AForceColumnMode: Boolean = False): Boolean;
function FindNextUnfoldedLine(iLine: integer; Down: boolean): Integer;
// Todo: Reduce the argument list of Creategutter
function CreateGutter(AOwner : TSynEditBase; ASide: TSynGutterSide;
@ -1015,7 +1015,7 @@ type
// Clipboard
procedure CopyToClipboard;
procedure CutToClipboard;
procedure PasteFromClipboard;
procedure PasteFromClipboard(AForceColumnMode: Boolean = False);
procedure DoCopyToClipboard(SText: string; FoldInfo: String = '');
property CanPaste: Boolean read GetCanPaste;
@ -4363,20 +4363,21 @@ begin
FOverrideCursor := c;
end;
procedure TCustomSynEdit.PasteFromClipboard;
procedure TCustomSynEdit.PasteFromClipboard(AForceColumnMode: Boolean);
var
ClipHelper: TSynClipboardStream;
begin
ClipHelper := TSynClipboardStream.Create;
try
ClipHelper.ReadFromClipboard(Clipboard);
PasteFromClipboardEx(ClipHelper);
PasteFromClipboardEx(ClipHelper, AForceColumnMode);
finally
ClipHelper.Free;
end;
end;
function TCustomSynEdit.PasteFromClipboardEx(ClipHelper: TSynClipboardStream) : Boolean;
function TCustomSynEdit.PasteFromClipboardEx(ClipHelper: TSynClipboardStream;
AForceColumnMode: Boolean): Boolean;
var
PTxt: PChar;
PStr: String;
@ -4388,7 +4389,10 @@ begin
InternalBeginUndoBlock;
try
PTxt := ClipHelper.TextP;
PMode := ClipHelper.SelectionMode;
if AForceColumnMode then
PMode := smColumn
else
PMode := ClipHelper.SelectionMode;
PasteAction := scaContinue;
if assigned(FOnPaste) then begin
if ClipHelper.IsPlainText then PasteAction := scaPlainText;
@ -7128,9 +7132,9 @@ begin
begin
CopyToClipboard;
end;
ecPaste:
ecPaste, ecPasteAsColumns:
begin
if not ReadOnly then PasteFromClipboard;
if not ReadOnly then PasteFromClipboard(Command = ecPasteAsColumns);
end;
ecCopyAdd, ecCutAdd:
if SelAvail then begin

View File

@ -265,6 +265,8 @@ const
ecCutCurrentLine = 609; //
ecCutAddCurrentLine = 610; //
ecPasteAsColumns = 611; // Paste clipboard to current position as if it was column mode
ecBlockIndent = 615; // Indent selection
ecBlockUnindent = 616; // Unindent selection
ecTab = 617; // Tab key

View File

@ -2700,6 +2700,7 @@ begin
AddDefault(C, 'Copy selection to clipboard', srkmecCopy, ecCopy);
AddDefault(C, 'Cut selection to clipboard', srkmecCut, ecCut);
AddDefault(C, 'Paste clipboard to current position', srkmecPaste, ecPaste);
AddDefault(C, 'Paste clipboard (as columns) to current position', srkmecPasteAsColumns, ecPasteAsColumns);
AddDefault(C, 'Copy - Add to Clipboard', srkmecCopyAdd, ecCopyAdd);
AddDefault(C, 'Cut - Add to Clipboard', srkmecCutAdd, ecCutAdd);
AddDefault(C, 'Copy current line', srkmecCopyCurrentLine, ecCopyCurrentLine);

View File

@ -3121,6 +3121,7 @@ resourcestring
srkmecCut = 'Cut';
srkmecCopy = 'Copy';
srkmecPaste = 'Paste';
srkmecPasteAsColumns = 'Paste (as Columns)';
srkmecCopyAdd = 'Copy (Add to Clipboard)';
srkmecCutAdd = 'Cut (Add to Clipboard)';
srkmecCopyCurrentLine = 'Copy current line';