From 87d4c2b37e4e86c04a591ea30bc3ea687745cc2d Mon Sep 17 00:00:00 2001 From: CHaBou Date: Sun, 21 Jan 2018 12:21:16 +0100 Subject: [PATCH] Fix selectAll command (#2436) * Fix selectAll command * Fix typo --- app/commands.js | 3 +++ app/menus/menus/edit.js | 7 +++++-- lib/components/term.js | 4 ++++ lib/containers/hyper.js | 9 +++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/commands.js b/app/commands.js index fa1d9a87..ad848260 100644 --- a/app/commands.js +++ b/app/commands.js @@ -29,6 +29,9 @@ const commands = { 'editor:clearBuffer': focusedWindow => { focusedWindow && focusedWindow.rpc.emit('session clear req'); }, + 'editor:selectAll': focusedWindow => { + focusedWindow.rpc.emit('term selectAll'); + }, 'plugins:update': () => { updatePlugins(); }, diff --git a/app/menus/menus/edit.js b/app/menus/menus/edit.js index 6c01cf22..301cf034 100644 --- a/app/menus/menus/edit.js +++ b/app/menus/menus/edit.js @@ -28,8 +28,11 @@ module.exports = (commandKeys, execCommand) => { accelerator: commandKeys['editor:paste'] }, { - role: 'selectall', - accelerator: commandKeys['editor:selectAll'] + label: 'Select All', + accelerator: commandKeys['editor:selectAll'], + click(item, focusedWindow) { + execCommand('editor:selectAll', focusedWindow); + } }, { type: 'separator' diff --git a/lib/components/term.js b/lib/components/term.js index ac31bd2c..80d3c2ea 100644 --- a/lib/components/term.js +++ b/lib/components/term.js @@ -195,6 +195,10 @@ export default class Term extends PureComponent { this.term.resize(cols, rows); } + selectAll() { + this.term.selectAll(); + } + fitResize() { if (!this.termWrapperRef) { return; diff --git a/lib/containers/hyper.js b/lib/containers/hyper.js index 2b347c43..9ef6ea6d 100644 --- a/lib/containers/hyper.js +++ b/lib/containers/hyper.js @@ -18,6 +18,7 @@ class Hyper extends PureComponent { constructor(props) { super(props); this.handleFocusActive = this.handleFocusActive.bind(this); + this.handleSelectAll = this.handleSelectAll.bind(this); this.onTermsRef = this.onTermsRef.bind(this); this.mousetrap = null; this.state = { @@ -45,6 +46,13 @@ class Hyper extends PureComponent { } } + handleSelectAll() { + const term = this.terms.getActiveTerm(); + if (term) { + term.selectAll(); + } + } + attachKeyListeners() { if (!this.mousetrap) { this.mousetrap = new Mousetrap(window, true); @@ -74,6 +82,7 @@ class Hyper extends PureComponent { componentDidMount() { this.attachKeyListeners(); + window.rpc.on('term selectAll', this.handleSelectAll); } onTermsRef(terms) {