mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Fix cut and copy events
- Do not actually cut on cut - Strip trailing whitespaces on copy (fix #66)
This commit is contained in:
+19
-4
@@ -422,9 +422,10 @@
|
||||
* Initialize default behavior
|
||||
*/
|
||||
Terminal.prototype.initGlobal = function() {
|
||||
Terminal.bindPaste(this);
|
||||
Terminal.bindKeys(this);
|
||||
Terminal.bindPaste(this);
|
||||
Terminal.bindCopy(this);
|
||||
Terminal.bindCut(this);
|
||||
Terminal.bindDrop(this);
|
||||
};
|
||||
|
||||
@@ -524,12 +525,26 @@
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Bind copy event
|
||||
/**
|
||||
* Bind copy event. Stript trailing whitespaces from selection.
|
||||
*/
|
||||
Terminal.bindCopy = function(term) {
|
||||
on(term.element, 'copy', function(ev) {
|
||||
return;
|
||||
var selectedText = window.getSelection().toString(),
|
||||
copiedText = selectedText.split('\n').map(function (element) {
|
||||
return element.replace(/\s+$/g, '');
|
||||
}).join('\n');
|
||||
ev.clipboardData.setData('text/plain', copiedText);
|
||||
ev.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel the cut event completely
|
||||
*/
|
||||
Terminal.bindCut = function(term) {
|
||||
on(term.element, 'cut', function (ev) {
|
||||
ev.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user