add button to copy CLI contents to clipboard

10.5.x-maintenance
Károly Kiripolszky 2018-11-19 22:58:21 +01:00
parent eb4a0d7808
commit eb899ddf21
3 changed files with 14 additions and 0 deletions

View File

@ -2256,6 +2256,9 @@
"cliClearOutputHistoryBtn": {
"message": "Clear output history"
},
"cliCopyToClipboardBtn": {
"message": "Copy to clipboard"
},
"loggingNote": {
"message": "Data will be logged in this tab <span class=\"message-negative\">only</span>, leaving the tab will <span class=\"message-negative\">cancel</span> logging and application will return to its normal <strong>\"configurator\"</strong> state.<br /> You are free to select the global update period, data will be written into the log file every <strong>1</strong> second for performance reasons."

View File

@ -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) {

View File

@ -17,6 +17,7 @@
<div class="btn save_btn pull-right">
<a class="save" href="#" i18n="cliSaveToFileBtn"></a>
<a class="clear" href="#" i18n="cliClearOutputHistoryBtn"></a>
<a class="copy" href="#" i18n="cliCopyToClipboardBtn"></a>
</div>
</div>
</div>