diff --git a/CHANGELOG.md b/CHANGELOG.md index e99dd731..f122afbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - matrices: support setting `split` property as a string to allow using children's indexes in their address (`$` is replaced with the index number) - text: `wrap` property doesn't break words by default anymore - rgb: added `range` property +- launcher + - right-click context menu (copy, paste, clear console, toggle console autoscoll) ## 0.27.2 diff --git a/app/main/launcher/launcher.js b/app/main/launcher/launcher.js index 3c407b61..35b6b339 100644 --- a/app/main/launcher/launcher.js +++ b/app/main/launcher/launcher.js @@ -1,5 +1,6 @@ var {remote, ipcRenderer, shell} = require('electron'), - {dialog, webContents} = remote.require('electron'), + {dialog, webContents, Menu, MenuItem} = remote.require('electron'), + menu = new Menu(), settings = remote.require('./main/settings'), packageInfos = remote.require('./package.json') packageVersion = packageInfos.version, @@ -195,21 +196,50 @@ $(document).ready(()=>{ }) // Fake console - var terminal = $(`
`).appendTo(form).hide() + var terminal = $(`
`).appendTo(form).hide(), + autoscoll = true ipcRenderer.on('stdout', function(e, msg){ - var scroll = document.body.offsetHeight + document.body.scrollTop == document.body.scrollHeight terminal.append(`
${msg}
`) - if (scroll) document.body.scrollTop = document.body.offsetHeight + document.body.scrollHeight + if (autoscoll) document.body.scrollTop = document.body.offsetHeight + document.body.scrollHeight }) + var scroll = document.body.offsetHeight + document.body.scrollTop == document.body.scrollHeight ipcRenderer.on('stderr', function(e, msg){ - var scroll = document.body.offsetHeight + document.body.scrollTop == document.body.scrollHeight terminal.append(`
${msg}
`) - if (scroll) document.body.scrollTop = document.body.offsetHeight + document.body.scrollHeight + if (autoscoll) document.body.scrollTop = document.body.offsetHeight + document.body.scrollHeight }) + // context-menu + + menu.append(new MenuItem({role: 'copy'})) + menu.append(new MenuItem({role: 'paste'})) + menu.append(new MenuItem({type: 'submenu' , label: 'Console', submenu: [ + new MenuItem({ + label: 'Clear', + click: ()=>{ + terminal.empty() + } + }), + new MenuItem({ + label: 'Autoscroll', + type: 'checkbox', + checked: true, + click: function(e){ + autoscoll = e.checked + } + }) + ]})) + + + window.addEventListener('contextmenu', function (e) { + menu.items[0].enabled = !!window.getSelection().toString() + menu.items[1].enabled = $(e.target).is('input:not([disabled])') + menu.popup({ window: remote.getCurrentWindow(), x: e.pageX, y: e.pageY - document.body.scrollTop}) + }, false) + + // ready $('input').trigger('change') diff --git a/src/browser/scss/style.scss b/src/browser/scss/style.scss index a6829820..a0c16137 100644 --- a/src/browser/scss/style.scss +++ b/src/browser/scss/style.scss @@ -408,6 +408,7 @@ body { cursor: auto; flex:1; height: auto; + min-height: 50rem; div { user-select:text;