along with this program. If not, see <http://www.gnu.org/licenses/>. */
'use strict'
const initialize = Promise.all([
along with this program. If not, see <http://www.gnu.org/licenses/>. */
'use strict'
const initialize = Promise.all([
- fetch('forth.forth').then((re) => re.text()),
- fetch('forth.wasm').then(re => re.arrayBuffer())
+ fetch('forth.forth', {credentials: 'include', headers:{'content-type':'text/plain'}}).then((re) => re.text()),
+ fetch('forth.wasm', {credentials: 'include', headers:{'content-type':'application/wasm'}}).then(re => re.arrayBuffer())
outframe.appendChild(stackview)
const txtoutput = document.createElement("pre")
txtoutput.setAttribute("style", "white-space:pre-wrap;overflow-y:scroll;flex:1 0 342px;")
outframe.appendChild(stackview)
const txtoutput = document.createElement("pre")
txtoutput.setAttribute("style", "white-space:pre-wrap;overflow-y:scroll;flex:1 0 342px;")
rstackview.setAttribute("style", "white-space:pre-wrap;flex:0 1 8%;")
outframe.appendChild(rstackview)
const memview = document.createElement("pre")
rstackview.setAttribute("style", "white-space:pre-wrap;flex:0 1 8%;")
outframe.appendChild(rstackview)
const memview = document.createElement("pre")
outframe.appendChild(memview)
const txtinput = document.createElement("textarea")
txtinput.setAttribute("autofocus", "true")
outframe.appendChild(memview)
const txtinput = document.createElement("textarea")
txtinput.setAttribute("autofocus", "true")
- txtinput.setAttribute("rows", "1")
- txtinput.setAttribute("style", "white-space:pre;margin-left:8%;width:60%;")
- txtinput.oninput = () => txtinput.rows = (txtinput.value.match(/[\n]/g) || [1]).length;
+ txtinput.setAttribute("wrap", "hard")
+ txtinput.setAttribute("style", "resize:none;white-space:pre;margin-left:8%;width:60%;")
+ txtinput.oninput = () => txtinput.rows = (txtinput.value.match(/[\n]/g) || [1]).length + 1;
+ txtinput.oninput()
let here = new DataView(wasmMem.buffer, 14340 /* here */, 4).getUint32(0,true)
memview.textContent = Array.from(new Uint8Array(wasmMem.buffer, here - maxBytes, maxBytes), (v) => {
cnt++;
v = ('0' + (v & 0xFF).toString(16)).slice(-2)
if (cnt === maxBytes)
return v
let here = new DataView(wasmMem.buffer, 14340 /* here */, 4).getUint32(0,true)
memview.textContent = Array.from(new Uint8Array(wasmMem.buffer, here - maxBytes, maxBytes), (v) => {
cnt++;
v = ('0' + (v & 0xFF).toString(16)).slice(-2)
if (cnt === maxBytes)
return v
+ const endPos = txtinput.selectionStart + 1
+ txtinput.value =
+ txtinput.value.substring(0, txtinput.selectionStart) +
+ '\n' +
+ txtinput.value.substring(txtinput.selectionEnd, txtinput.value.length)
+ txtinput.setSelectionRange(endPos, endPos)
is_whitespace: (key) => /\s/.test(String.fromCharCode(key)),
sys_stack: () => console.log(`[${simstack}]`),
sys_parsenum: (addr, u, base) => {
is_whitespace: (key) => /\s/.test(String.fromCharCode(key)),
sys_stack: () => console.log(`[${simstack}]`),
sys_parsenum: (addr, u, base) => {