From 3c354a22676ffba3defb01243ee04e05a1e4db22 Mon Sep 17 00:00:00 2001 From: Gordon Hall Date: Thu, 5 Jun 2014 13:04:08 -0400 Subject: [PATCH] add mousetrap, enable copy/paste in shell --- bower.json | 3 ++- index.html | 3 ++- js/shell.js | 28 +++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index fbb7cb541..9512c0007 100644 --- a/bower.json +++ b/bower.json @@ -20,6 +20,7 @@ "qrcode-decoder-js": "*", "bitcore": "~0.1.19", "angular-moment": "~0.7.1", - "socket.io-client": ">=1.0.0" + "socket.io-client": ">=1.0.0", + "mousetrap": "1.4.6" } } diff --git a/index.html b/index.html index 1f86ca8ac..1128cd712 100644 --- a/index.html +++ b/index.html @@ -548,7 +548,7 @@
- first seen at + first seen at
@@ -777,6 +777,7 @@ on supported browsers please check http://www.w + diff --git a/js/shell.js b/js/shell.js index 2e888719f..4fe83d25c 100644 --- a/js/shell.js +++ b/js/shell.js @@ -35,8 +35,34 @@ function initCopayShellBindings() { - var ipc = require('ipc'); + var ipc = require('ipc'); + var clipb = require('clipboard'); + // atom shell forces to implement the clipboard on our own - thanks obama. + + Mousetrap.stopCallback = function() { return false }; + + Mousetrap.bind('ctrl+c', function(e) { + clipb.writeText(window.getSelection().toString()); + }); + + Mousetrap.bind('ctrl+v', function(e) { + if (document.activeElement) { + document.activeElement.value = clipb.readText(); + } + }); + + Mousetrap.bind('command+c', function(e) { + clipb.writeText(window.getSelection().toString()); + }); + + Mousetrap.bind('command+v', function(e) { + if (document.activeElement) { + document.activeElement.value = clipb.readText(); + } + }); + + // handle messages ipc.on('address:create', function(data) { location.href = '#/addresses'; var ctrl = controller('AddressesController');