launcher: add a console that prints stderr and stdout

This commit is contained in:
bordun 2017-09-16 15:35:43 +02:00
parent 28b1fc2d4f
commit 9e0ad98955
5 changed files with 84 additions and 10 deletions

View file

@ -4,6 +4,8 @@
- bug fixes
- allow loading `.json` session files from the launcher
- launcher
- new log/error console (shows once the app is started)
## 0.20.2

View file

@ -167,20 +167,32 @@ $(document).ready(()=>{
})
form.appendTo('#launcher')
// server started callback
ipcRenderer.on('started',function(){
var addresses = settings.read('appAddresses').map((a)=>{return `<a href="${a}">${a}</a>`})
start.addClass('started').html('App available at ' + addresses.join(' & '))
start.remove()
save.remove()
terminal.show()
})
// Fake console
var terminal = $(`<div class="terminal"></div>`).appendTo('#launcher').hide()
ipcRenderer.on('stdout', function(e, msg){
terminal.append(`<div class="log">${msg}</div>`)
terminal.scrollTop(terminal.prop('scrollHeight'))
})
ipcRenderer.on('stderr', function(e, msg){
terminal.append(`<div class="error">${msg}</div>`)
terminal.scrollTop(terminal.prop('scrollHeight'))
})
// ready
form.appendTo('#launcher')
$('input').trigger('change')

View file

@ -57,9 +57,24 @@ if (settings.cli) {
launcher
app.on('ready',function(){
launcher = require('./electron-window')({address:address, shortcuts:false, width:680, height:568, color:'#283143'})
launcher = require('./electron-window')({address:address, shortcuts:true, width:680, height:568, color:'#283143'})
})
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
launcher.webContents.send('stdout', string)
}
})(process.stdout.write)
process.stderr.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
launcher.webContents.send('stderr', string)
}
})(process.stderr.write)
ipcMain.on('start',function(e, options){
var gui = start()

View file

@ -31,6 +31,7 @@
}
}
@mixin arrow($r) {
background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="50px" width="50px"><g stroke="rgba(255,255,255,0.5)" transform="rotate('+$r+' 25 25)"><line x1="16" y1="20" x2="25" y2="29" stroke-width="2" /><line x1="25" y1="29" x2="34" y2="20" stroke-width="2" /></g></svg>');
background-blend-mode: difference, normal;
@ -76,3 +77,12 @@
}
}
// ::-webkit-resizer {
// border-left:2rem solid var(--color-bg);
// border-top:2rem solid var(--color-bg);
// background:var(--color-fg);
// background-size:contain;
// background-position: 2rem 2rem;
// @include arrow(-45)
// }

View file

@ -204,13 +204,12 @@ body {
#launcher {
background: var(--color-fg);
padding:2rem;
padding:14rem;
display: flex;
flex-direction: column;
.form {
width: 100%; // box-shadow: none;
height: 100%;
width: 100%;
background: var(--color-fg);
padding:12rem;
overflow: hidden;
opacity: 0;
transition: opacity .25s;
@ -368,6 +367,42 @@ body {
}
}
.terminal {
margin-top: 5rem;
background: var(--color-bg);
font-family: monospace;
text-transform: none;
padding:3rem;
border:2rem solid var(--color-bg);
letter-spacing: normal;
cursor: auto;
flex:1;
height: 100%;
overflow: hidden;
overflow-y: scroll;
height: 50rem;
&::-webkit-scrollbar-button:decrement:start, &::-webkit-scrollbar-button:increment:end {
display:none;
}
&::-webkit-scrollbar {
width: 8rem;
}
div {
user-select:text;
width: 100%;
white-space: pre-line;
word-wrap: break-word;
text-indent: -10px;
padding-left: 10px;
margin-top: 4rem;
}
.log {
}
.error {
color: rgba(255, 150, 50, 1)
}
}
}