Tweaks for mobile.

This commit is contained in:
Brad Nelson
2022-07-20 23:20:30 -07:00
parent 19aa66062b
commit 1aacfd24ba
12 changed files with 68 additions and 21 deletions

View File

@ -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 \

View File

@ -16,9 +16,8 @@ limitations under the License.
-->
<head>
<meta charset="UTF-8">
{{HEAD}}
<title>ESP32forth</title>
<link rel="stylesheet" href="static/eforth.css">
</head>
<body>

View File

@ -15,9 +15,8 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<meta charset="UTF-8">
{{HEAD}}
<title>Classic EForth</title>
<link rel="stylesheet" href="static/eforth.css">
</head>
<body>

20
site/head.html Normal file
View File

@ -0,0 +1,20 @@
<!--
Copyright 2021 Bradley D. Nelson
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<meta charset="UTF-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="static/eforth.css">

View File

@ -16,9 +16,8 @@ limitations under the License.
-->
<head>
<meta charset="UTF-8">
{{HEAD}}
<title>EForth</title>
<link rel="stylesheet" href="static/eforth.css">
</head>
<body>

View File

@ -16,9 +16,8 @@ limitations under the License.
-->
<head>
<meta charset="UTF-8">
{{HEAD}}
<title>µEforth Internals</title>
<link rel="stylesheet" href="static/eforth.css">
</head>
<body>

View File

@ -16,9 +16,8 @@ limitations under the License.
-->
<head>
<meta charset="UTF-8">
{{HEAD}}
<title>µEforth for Linux</title>
<link rel="stylesheet" href="static/eforth.css">
</head>
<body>

View File

@ -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;

View File

@ -16,15 +16,14 @@ limitations under the License.
-->
<head>
<meta charset="UTF-8">
{{HEAD}}
<title>µEforth for Web</title>
<link rel="stylesheet" href="static/eforth.css">
</head>
<body>
<h1>µEforth for Web</h1>
{{MENU}}
<div class="wrapper">
<div class="web_wrapper">
<div id="ueforth"></div>
<script src="ueforth.js"></script>

View File

@ -16,9 +16,8 @@ limitations under the License.
-->
<head>
<meta charset="UTF-8">
{{HEAD}}
<title>µEforth for Windows</title>
<link rel="stylesheet" href="static/eforth.css">
</head>
<body>

View File

@ -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();

View File

@ -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;