console: minor tweaks + some not ready code for live interpreter

This commit is contained in:
bordun 2020-11-09 14:28:29 +01:00
parent 08147c7657
commit 16b634cb06
2 changed files with 44 additions and 6 deletions

View file

@ -13,14 +13,16 @@ class UiConsole extends UiWidget {
this.header = DOM.get(this.container, 'osc-panel-header')[0]
this.header.appendChild(html`<label>${locales('console_title')}</label>`)
this.messages = this.container.appendChild(html`<osc-console></osc-console>`)
// this.inputWrapper = this.container.appendChild(html`<osc-console-input></osc-console-inpu>`)
// this.input = this.inputWrapper.appendChild(html`<textarea></textarea>`)
this.actions = this.header.appendChild(html`<div class="actions"></div>`)
this.clearBtn = this.actions.appendChild(html`<div class="clear" title="${locales('console_clear')}">${raw(icon('trash'))}</div>`)
this.clearBtn.addEventListener('click', ()=>{
this.clear()
})
this.messages = this.container.appendChild(html`<osc-console></osc-console>`)
this.length = 0
this.maxLength = 200
@ -33,7 +35,7 @@ class UiConsole extends UiWidget {
_this.log('log', message)
log(...arguments)
}
console.error = function(message){
_this.log('error', message)
error(...arguments)
@ -44,6 +46,27 @@ class UiConsole extends UiWidget {
onerror(...arguments)
}
// this.input.addEventListener('keydown', (event)=>{
// if (event.keyCode === 13 && !event.shiftKey) {
//
// event.preventDefault()
// DOM.dispatchEvent(event.target, 'change')
//
// }
// })
//
// this.input.addEventListener('change', (event)=>{
// try {
// console.log(eval(this.input.value))
// } catch (err) {
// console.error(err)
// }
// this.input.value = ''
// })
}
log(type, message) {

View file

@ -38,8 +38,8 @@ $padding: 8rem;
osc-console {
display: block;
flex: 1;
padding: $padding $padding;
overflow: auto;
padding: $padding;
overflow-y: auto;
background: var(--color-background);
}
@ -47,10 +47,25 @@ osc-console-message {
user-select: text;
cursor: text;
display: block;
white-space: pre;
&.error {
color: var(--color-error);
}
margin-bottom: 4rem;
}
osc-console-input {
display: block;
padding: 4rem;
background: var(--color-ui-background);
height: 30rem;
textarea {
padding: 4rem;
display: block;
background: var(--color-background);
width: 100%;
height: 100%;
resize: none;
}
}