diff --git a/lib/components/term.js b/lib/components/term.js index 57581e1b..476a6991 100644 --- a/lib/components/term.js +++ b/lib/components/term.js @@ -1,6 +1,7 @@ /* global Blob,URL,requestAnimationFrame */ import React from 'react'; import Terminal from 'xterm'; +import {clipboard} from 'electron'; import {PureComponent} from '../base-components'; import terms from '../terms'; import returnKey from '../utils/keymaps'; @@ -26,6 +27,7 @@ export default class Term extends PureComponent { this.onWindowPaste = this.onWindowPaste.bind(this); this.onTermRef = this.onTermRef.bind(this); this.onTermWrapperRef = this.onTermWrapperRef.bind(this); + this.onMouseUp = this.onMouseUp.bind(this); } componentDidMount() { @@ -129,6 +131,13 @@ export default class Term extends PureComponent { } } + onMouseUp() { + // handle copying selected text + if (this.props.copyOnSelect && this.term.hasSelection()) { + clipboard.writeText(this.term.getSelection()); + } + } + write(data) { this.term.write(data); } @@ -225,7 +234,11 @@ export default class Term extends PureComponent { template(css) { return ( -
+
{this.props.customChildrenBefore}