From 1aacfd24ba91634da32aab2cc90346fbe11516ad Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Wed, 20 Jul 2022 23:20:30 -0700 Subject: [PATCH] Tweaks for mobile. --- Makefile | 1 + site/ESP32forth.html | 3 +-- site/classic.html | 3 +-- site/head.html | 20 ++++++++++++++++++++ site/index.html | 3 +-- site/internals.html | 3 +-- site/linux.html | 3 +-- site/static/eforth.css | 8 ++++++++ site/web.html | 5 ++--- site/windows.html | 3 +-- tools/replace.js | 4 ++-- web/platform.fs | 33 +++++++++++++++++++++++++++++---- 12 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 site/head.html diff --git a/Makefile b/Makefile index c47eb9f..49cd457 100644 --- a/Makefile +++ b/Makefile @@ -544,6 +544,7 @@ $(DEPLOY): mkdir -p $@ REPLACE = tools/replace.js \ + HEAD=@site/head.html \ COMMON=@site/common.html \ POSIX_COMMON=@site/posix_common.html \ DESKTOP_COMMON=@site/desktop_common.html \ diff --git a/site/ESP32forth.html b/site/ESP32forth.html index a5c4eed..72f0e60 100644 --- a/site/ESP32forth.html +++ b/site/ESP32forth.html @@ -16,9 +16,8 @@ limitations under the License. --> - + {{HEAD}} ESP32forth - diff --git a/site/classic.html b/site/classic.html index 8e58e09..fd70c59 100644 --- a/site/classic.html +++ b/site/classic.html @@ -15,9 +15,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + {{HEAD}} Classic EForth - diff --git a/site/head.html b/site/head.html new file mode 100644 index 0000000..72a3439 --- /dev/null +++ b/site/head.html @@ -0,0 +1,20 @@ + + + + + + diff --git a/site/index.html b/site/index.html index 04b713a..c672978 100644 --- a/site/index.html +++ b/site/index.html @@ -16,9 +16,8 @@ limitations under the License. --> - +{{HEAD}} EForth - diff --git a/site/internals.html b/site/internals.html index 7c596b7..e44beec 100644 --- a/site/internals.html +++ b/site/internals.html @@ -16,9 +16,8 @@ limitations under the License. --> - + {{HEAD}} µEforth Internals - diff --git a/site/linux.html b/site/linux.html index 2e6b062..81a1044 100644 --- a/site/linux.html +++ b/site/linux.html @@ -16,9 +16,8 @@ limitations under the License. --> - + {{HEAD}} µEforth for Linux - diff --git a/site/static/eforth.css b/site/static/eforth.css index 18ebb02..5707668 100644 --- a/site/static/eforth.css +++ b/site/static/eforth.css @@ -21,6 +21,9 @@ body { max-width: 800px; padding: 0px 10px; } +.web_wrapper { + padding: 0px 10px; +} h1 { border-top: 3px solid #777; background-color: #111; @@ -47,6 +50,10 @@ h5 { margin: 2px; width: 30%; } +pre { + white-space: pre-wrap; + width: 100%; +} a:link { color: #00c; } @@ -67,6 +74,7 @@ a:hover { .menu span { margin: 0px; padding: 10px; + line-height: 32px; } .menu a:link { color: #fff; diff --git a/site/web.html b/site/web.html index 3de452b..d3a99f5 100644 --- a/site/web.html +++ b/site/web.html @@ -16,15 +16,14 @@ limitations under the License. --> - +{{HEAD}} µEforth for Web -

µEforth for Web

{{MENU}} -
+
diff --git a/site/windows.html b/site/windows.html index 88b7ccb..d480a46 100644 --- a/site/windows.html +++ b/site/windows.html @@ -16,9 +16,8 @@ limitations under the License. --> - + {{HEAD}} µEforth for Windows - diff --git a/tools/replace.js b/tools/replace.js index 51c0d44..af326fb 100755 --- a/tools/replace.js +++ b/tools/replace.js @@ -23,7 +23,7 @@ function DropCopyright(source) { while (lines[i] != '-->') { ++i; } - i += 2; + ++i; } if (lines[i].search('Copyright') >= 0) { while (lines[i] != '') { @@ -33,7 +33,7 @@ function DropCopyright(source) { cleaned.push(lines[i]); } } - return cleaned.join('\n'); + return cleaned.join('\n').trim(); } var source = fs.readFileSync(process.stdin.fd).toString(); diff --git a/web/platform.fs b/web/platform.fs index 08bbe9c..861ba89 100644 --- a/web/platform.fs +++ b/web/platform.fs @@ -31,9 +31,22 @@ r| context.inbuffer = []; context.outbuffer = ''; if (!globalObj.write) { + function AddMeta(name, content) { + var meta = document.createElement('meta'); + meta.name = name; + meta.content = content; + document.head.appendChild(meta); + } + + AddMeta('apple-mobile-web-app-capable', 'yes'); + AddMeta('apple-mobile-web-app-status-bar-style', 'black-translucent'); + AddMeta('viewport', 'width=device-width, initial-scale=1.0, ' + + 'maximum-scale=1.0, user-scalable=no, minimal-ui'); + context.screen = document.getElementById('ueforth'); if (context.screen === null) { context.screen = document.createElement('div'); + context.screen.style.width = '100%'; document.body.appendChild(context.screen); } context.filler = document.createElement('div'); @@ -50,6 +63,8 @@ if (!globalObj.write) { context.screen.appendChild(context.canvas); context.ctx = context.canvas.getContext('2d'); context.terminal = document.createElement('pre'); + context.terminal.style.width = '100%'; + context.terminal.style.whiteSpace = 'pre-wrap'; context.screen.appendChild(context.terminal); context.text_fraction = 1667; context.min_text_portion = 120; @@ -100,13 +115,23 @@ if (!globalObj.write) { window.onresize = function(e) { Resize(); }; - window.onkeypress = function(e) { + function KeyPress(e) { context.inbuffer.push(e.keyCode); - }; - window.onkeydown = function(e) { + e.preventDefault(); + return false; + } + window.onkeypress = KeyPress; + function KeyDown(e) { if (e.keyCode == 8) { context.inbuffer.push(e.keyCode); + e.preventDefault(); + return false; } + } + window.onkeydown = KeyDown; + context.Update = function(active) { + var cursor = String.fromCharCode(0x2592); + context.terminal.innerText = context.outbuffer + cursor; }; setMode(0); context.Clear(); @@ -132,7 +157,7 @@ r| context.outbuffer += String.fromCharCode(ch); } } - context.terminal.innerText = context.outbuffer + String.fromCharCode(0x2592); + context.Update(); window.scrollTo(0, document.body.scrollHeight); } return sp;