aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordan <[email protected]>2023-05-26 20:10:13 -0400
committerdan <[email protected]>2023-05-26 20:10:13 -0400
commit1d059ec9193202a7508134c1ec65364286f945ac (patch)
tree74f2b767f9f5bd7a8ce2cac74fa468e2f855f304
parentdecb090db546c12b189091f95d5faba2561bcb22 (diff)
downloadforth-1d059ec9193202a7508134c1ec65364286f945ac.tar.gz
forth-1d059ec9193202a7508134c1ec65364286f945ac.tar.bz2
forth-1d059ec9193202a7508134c1ec65364286f945ac.zip
fix: js forth prompt should be below output
-rw-r--r--forth.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/forth.js b/forth.js
index d3e90c7..436387a 100644
--- a/forth.js
+++ b/forth.js
@@ -112,6 +112,8 @@ if (typeof window !== 'undefined') { // browser UI
#forthouter {
cursor: text;
border: solid thin black;
+ height: 90vh;
+ overflow: scroll;
}
#forthline {
width: 97%;
@@ -121,10 +123,8 @@ if (typeof window !== 'undefined') { // browser UI
outline: none;
}
#forthresultsbox {
- height: 90vh;
}
#forthresults {
- height: 100%;
margin-top: 0px;
overflow: clip;
margin: 0px;
@@ -141,21 +141,25 @@ if (typeof window !== 'undefined') { // browser UI
document.head.appendChild(style);
forthroot.innerHTML = `
<div id="forthouter">
- <form id="forthform">
- <label id="forthlinelabel" for="forthline" position="left">></label>
- <input id="forthline" type="text" value="" autocomplete="off">
- </form>
<div id='forthresultsbox'>
<pre id="forthresults"></pre>
</div>
+ <form id="forthform">
+ <label id="forthlinelabel" for="forthline" position="left">>&nbsp;</label>
+ <input id="forthline" type="text" value="" autocomplete="off">
+ </form>
</div>`
forthouter.onclick = () => forthline.focus();
- const print = x => { forthresults.innerHTML = x + '\n' + forthresults.innerHTML; };
+ const print = x => {
+ forthresults.innerHTML = forthresults.innerHTML + x + '\n' ;
+ forthouter.scrollTo(0, forthouter.scrollHeight);
+ };
const m = forth(print);
forthform.onsubmit = () => {
const input = forthline.value;
if (input !== '') {
- m(input).then(() => print(`> ${input}`));
+ print(`> ${input}`);
+ m(input);
forthline.value = '';
}
return false;