mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
copyOnSelect support in canary (#2390)
This commit is contained in:
parent
280f14e239
commit
0b57dc4158
1 changed files with 14 additions and 1 deletions
|
|
@ -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 (
|
||||
<div className={css('fit', this.props.isTermActive && 'active')} style={{padding: this.props.padding}}>
|
||||
<div
|
||||
className={css('fit', this.props.isTermActive && 'active')}
|
||||
style={{padding: this.props.padding}}
|
||||
onMouseUp={this.onMouseUp}
|
||||
>
|
||||
{this.props.customChildrenBefore}
|
||||
<div ref={this.onTermWrapperRef} className={css('fit', 'wrapper')}>
|
||||
<div ref={this.onTermRef} className={css('term')} />
|
||||
|
|
|
|||
Loading…
Reference in a new issue