diff options
author | dan <[email protected]> | 2023-05-26 20:10:13 -0400 |
---|---|---|
committer | dan <[email protected]> | 2023-05-26 20:10:13 -0400 |
commit | 1d059ec9193202a7508134c1ec65364286f945ac (patch) | |
tree | 74f2b767f9f5bd7a8ce2cac74fa468e2f855f304 | |
parent | decb090db546c12b189091f95d5faba2561bcb22 (diff) | |
download | forth-1d059ec9193202a7508134c1ec65364286f945ac.tar.gz forth-1d059ec9193202a7508134c1ec65364286f945ac.tar.bz2 forth-1d059ec9193202a7508134c1ec65364286f945ac.zip |
fix: js forth prompt should be below output
-rw-r--r-- | forth.js | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -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">> </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; |