From 16b634cb06617df2f8152c4158d3bf26fac7ad3c Mon Sep 17 00:00:00 2001 From: bordun Date: Mon, 9 Nov 2020 14:28:29 +0100 Subject: [PATCH] console: minor tweaks + some not ready code for live interpreter --- src/client/ui/ui-console.js | 29 ++++++++++++++++++++++++++--- src/scss/ui/console.scss | 21 ++++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/client/ui/ui-console.js b/src/client/ui/ui-console.js index f5348c0a..bfbf01b0 100644 --- a/src/client/ui/ui-console.js +++ b/src/client/ui/ui-console.js @@ -13,14 +13,16 @@ class UiConsole extends UiWidget { this.header = DOM.get(this.container, 'osc-panel-header')[0] this.header.appendChild(html``) + this.messages = this.container.appendChild(html``) + // this.inputWrapper = this.container.appendChild(html``) + // this.input = this.inputWrapper.appendChild(html``) + this.actions = this.header.appendChild(html`
`) this.clearBtn = this.actions.appendChild(html`
${raw(icon('trash'))}
`) this.clearBtn.addEventListener('click', ()=>{ this.clear() }) - - this.messages = this.container.appendChild(html``) 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) { diff --git a/src/scss/ui/console.scss b/src/scss/ui/console.scss index 800fbbbe..3197f803 100644 --- a/src/scss/ui/console.scss +++ b/src/scss/ui/console.scss @@ -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; + } +}