From 9b5aef7fc5d5fc5720c57a9e3bfb293cb3de4ec9 Mon Sep 17 00:00:00 2001 From: Bamidev Date: Mon, 11 Mar 2024 21:46:53 +0100 Subject: [PATCH] Improve layout of the terminal example. --- examples/northern-lights.txt | 2 +- examples/preview-art.sh | 0 examples/resources/main.js | 19 +++++++++++++------ examples/resources/style.css | 3 ++- examples/resources/terminal.html | 4 +++- 5 files changed, 19 insertions(+), 9 deletions(-) mode change 100644 => 100755 examples/preview-art.sh diff --git a/examples/northern-lights.txt b/examples/northern-lights.txt index f31a429..8f97b6e 100644 --- a/examples/northern-lights.txt +++ b/examples/northern-lights.txt @@ -19,4 +19,4 @@ __ + * `' `'|. `: "' `---"""----....____,..^---`^``----.,.___ `. `. . ____,.,- ___,--'""`---"' ^ ^ ^ ^ """'---,..___ __,..---""' ---"' ^ ``--..,__ D. Rice \ No newline at end of file +--"' ^ ``--..,__ D. Rice diff --git a/examples/preview-art.sh b/examples/preview-art.sh old mode 100644 new mode 100755 diff --git a/examples/resources/main.js b/examples/resources/main.js index e4f5208..b4df455 100644 --- a/examples/resources/main.js +++ b/examples/resources/main.js @@ -39,28 +39,35 @@ function onExecutionEnded() { is_executing = false } +function escapeText(text) { + return text + .replaceAll(' ', ' ') + .replaceAll("\r\n", '
') + .replaceAll("\n", '
') +} + function onOutputReceived( output ) { let span = document.createElement("span") - span.innerText = output + span.innerHTML = escapeText(output) - document.body.appendChild( span ) + document.body.firstElementChild.appendChild( span ) } function onErrorOutputReceived( output ) { let span = document.createElement("span") span.setAttribute("class", "stderr") - span.innerText = output + span.innerHTML = escapeText(output) - document.body.appendChild( span ) + document.body.firstElementChild.appendChild( span ) } function print( text ) { - $('body').append( text ) + $('body div').append( text ) } function printPrefix() { - print( working_dir + '$ ' ) + print(working_dir + '$ ') } diff --git a/examples/resources/style.css b/examples/resources/style.css index ddd6a83..97e81f5 100644 --- a/examples/resources/style.css +++ b/examples/resources/style.css @@ -1,7 +1,8 @@ body { background-color: #000; color: #0F0; - font: 1em coolFont; + font: 1.2em coolFont; + margin-top: 0; word-break: break-all; word-wrap: break-word; white-space: pre-line; diff --git a/examples/resources/terminal.html b/examples/resources/terminal.html index df823f2..e130b10 100644 --- a/examples/resources/terminal.html +++ b/examples/resources/terminal.html @@ -11,5 +11,7 @@ - + +
+