terminal: support ctrl+shift+c/v for copy paste
This commit is contained in:
@@ -241,7 +241,7 @@ export default {
|
||||
|
||||
// Let the browser handle paste
|
||||
this.terminal.attachCustomKeyEventHandler(function (e) {
|
||||
if (e.key === 'v' && (e.ctrlKey || e.metaKey)) return false;
|
||||
if (e.key === 'V' && (e.ctrlKey || e.metaKey)) return false;
|
||||
});
|
||||
|
||||
// websocket cannot use relative urls
|
||||
@@ -250,6 +250,11 @@ export default {
|
||||
|
||||
this.terminal.loadAddon(new AttachAddon(this.socket));
|
||||
|
||||
// Let the browser handle paste
|
||||
// this.terminal.attachCustomKeyEventHandler((event) => {
|
||||
// if (event.key === 'V' && (event.ctrlKey || event.metaKey)) return false;
|
||||
// });
|
||||
|
||||
this.socket.addEventListener('open', (event) => {
|
||||
this.connected = true;
|
||||
});
|
||||
@@ -308,6 +313,21 @@ export default {
|
||||
|
||||
window.document.title = `Terminal - ${this.name}`;
|
||||
|
||||
window.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'C' && (event.ctrlKey || event.metaKey)) { // ctrl shift c
|
||||
event.preventDefault();
|
||||
|
||||
if (!this.terminal) return;
|
||||
|
||||
// execCommand('copy') would copy any selection from the page, so do this only if terminal has a selection
|
||||
if (!this.terminal.getSelection()) return;
|
||||
|
||||
document.execCommand('copy');
|
||||
|
||||
this.terminal.focus();
|
||||
}
|
||||
});
|
||||
|
||||
this.connect();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user