From eb899ddf218a987e6894bc0e00b2e1f317b5a927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1roly=20Kiripolszky?= Date: Mon, 19 Nov 2018 22:58:21 +0100 Subject: [PATCH] add button to copy CLI contents to clipboard --- locales/en/messages.json | 3 +++ src/js/tabs/cli.js | 10 ++++++++++ src/tabs/cli.html | 1 + 3 files changed, 14 insertions(+) diff --git a/locales/en/messages.json b/locales/en/messages.json index fc3e3afa..3614ec4e 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2256,6 +2256,9 @@ "cliClearOutputHistoryBtn": { "message": "Clear output history" }, + "cliCopyToClipboardBtn": { + "message": "Copy to clipboard" + }, "loggingNote": { "message": "Data will be logged in this tab only, leaving the tab will cancel logging and application will return to its normal \"configurator\" state.
You are free to select the global update period, data will be written into the log file every 1 second for performance reasons." diff --git a/src/js/tabs/cli.js b/src/js/tabs/cli.js index f1163ece..d618fcc5 100644 --- a/src/js/tabs/cli.js +++ b/src/js/tabs/cli.js @@ -107,6 +107,16 @@ TABS.cli.initialize = function (callback) { $('.tab-cli .window .wrapper').empty(); }); + $('.tab-cli .copy').click(function() { + try { + let gui = require('nw.gui'), + clipboard = gui.Clipboard.get(); + clipboard.set(self.outputHistory, "text"); + } catch (ex) { + console.warn(ex); + } + }); + // Tab key detection must be on keydown, // `keypress`/`keyup` happens too late, as `textarea` will have already lost focus. textarea.keydown(function (event) { diff --git a/src/tabs/cli.html b/src/tabs/cli.html index 2ba6514f..b25699ec 100644 --- a/src/tabs/cli.html +++ b/src/tabs/cli.html @@ -17,6 +17,7 @@
+