Merge pull request #38287 from martellaj/joem/issue-36271

Adds "copy on select" feature (with setting)
This commit is contained in:
Daniel Imms
2017-12-14 20:04:34 -08:00
committed by GitHub
2 changed files with 19 additions and 0 deletions

View File

@@ -120,6 +120,11 @@ configurationRegistry.registerConfiguration({
'type': 'boolean',
'default': TERMINAL_DEFAULT_RIGHT_CLICK_COPY_PASTE
},
'terminal.integrated.copyOnSelection': {
'description': nls.localize('terminal.integrated.copyOnSelection', "When set, text selected in the terminal will be copied to the clipboard."),
'type': 'boolean',
'default': false
},
'terminal.integrated.fontFamily': {
'description': nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to editor.fontFamily's value."),
'type': 'string'

View File

@@ -222,6 +222,20 @@ export class TerminalPanel extends Panel {
}
}
}));
this._register(dom.addDisposableListener(this._parentDomElement, 'mouseup', (event: MouseEvent) => {
if (this._configurationService.getValue('terminal.integrated.copyOnSelection')) {
if (this._terminalService.terminalInstances.length === 0) {
return;
}
if (event.which === 1) {
let terminal = this._terminalService.getActiveInstance();
if (terminal.hasSelection()) {
terminal.copySelection();
}
}
}
}));
this._register(dom.addDisposableListener(this._parentDomElement, 'contextmenu', (event: MouseEvent) => {
if (!this._cancelContextMenu) {
const standardEvent = new StandardMouseEvent(event);