From c7f195ba015fd55d1883feb5023d388d34b4a97c Mon Sep 17 00:00:00 2001 From: Philippe Potvin Date: Wed, 21 Dec 2016 10:19:41 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20ctrl+c=20to=20close=20WebView=20?= =?UTF-8?q?=F0=9F=8D=BE=20=20(#1287)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * rm hyperCaretFocus => prevent callstask * keep caret component --- lib/actions/sessions.js | 1 - lib/components/term.js | 49 +++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/actions/sessions.js b/lib/actions/sessions.js index 14630459..c7850360 100644 --- a/lib/actions/sessions.js +++ b/lib/actions/sessions.js @@ -57,7 +57,6 @@ export function addSessionData(uid, data) { const enterKey = Boolean(data.match(/\n/)); const url = enterKey ? isUrl(shell, data) : null; - if (url) { dispatch({ type: SESSION_URL_SET, diff --git a/lib/components/term.js b/lib/components/term.js index 55f1cfb8..db71fde2 100644 --- a/lib/components/term.js +++ b/lib/components/term.js @@ -16,8 +16,9 @@ export default class Term extends Component { this.handleMouseUp = this.handleMouseUp.bind(this); this.handleScrollEnter = this.handleScrollEnter.bind(this); this.handleScrollLeave = this.handleScrollLeave.bind(this); - this.handleFocus = this.handleFocus.bind(this); this.onHyperCaret = this.onHyperCaret.bind(this); + this.handleKeyDown = this.handleKeyDown.bind(this); + this.handleFocus = this.handleFocus.bind(this); props.ref_(this); } @@ -121,14 +122,6 @@ export default class Term extends Component { this.scrollMouseEnter = false; } - handleFocus() { - // This will in turn result in `this.focus()` being - // called, which is unecessary. - // Should investigate if it matters. - this.props.onActive(); - this.term.focusHyperCaret(); - } - handleMouseUp() { this.props.onActive(); // this makes sure that we focus the hyper caret only @@ -139,6 +132,18 @@ export default class Term extends Component { this.term.focusHyperCaret(); } } + handleFocus() { + // This will in turn result in `this.focus()` being + // called, which is unecessary. + // Should investigate if it matters. + this.props.onActive(); + } + + handleKeyDown(e) { + if (e.ctrlKey && e.key === 'c') { + this.props.onURLAbort(); + } + } onHyperCaret(caret) { this.hyperCaret = caret; @@ -262,13 +267,10 @@ export default class Term extends Component { // key input so that it doesn't conflict // with the if (nextProps.url) { - const io = this.term.io.push(); - io.onVTKeystroke = io.sendString = str => { - if (str.length === 1 && str.charCodeAt(0) === 3 /* Ctrl + C */) { - this.props.onURLAbort(); - } - }; + this.term.io.push(); + window.addEventListener('keydown', this.handleKeyDown); } else { + window.removeEventListener('keydown', this.handleKeyDown); this.term.io.pop(); } } @@ -349,6 +351,7 @@ export default class Term extends Component { /> { this.props.url ? : - [ -
, -
- ] +
} +
{ this.props.customChildren }
); }