Skip to content
Tcl Source Code Artifact [4effa0c682]
Login

Artifact [4effa0c682]

Artifact 4effa0c682778593486e2ceecd2b383a4d08a8d5:


# sourced by inter.html demo

::nacl::js {
    t0=document.getElementById('txt');
    function bot(w) {
        len=w.value.length+1;
	w.setSelectionRange(len,len);
   	w.focus();     
    }
    t0.value = "# Type Tcl code in there\n";
    t0.onkeydown=function(event) {
	if (event.which==13) {
	    bot(t0);
	    tclDoCoro("swallow \""+tclEsc(t0.value.replace(/.*\n/g,''))+"\"");
	    bot(t0);
	}
	return true;
    }
    bot(t0);
}

proc swallow s {
    append ::accu $s \n
    if {[info complete $::accu]} {
	set x $::accu
	unset ::accu
	set res [uplevel #0 $x]
	::nacl::js "t0.value+=[::nacl::jsquote $res\n];bot(t0);"
    }
}

proc ::nacl::bgerror s {
    ::nacl::js "t0.value+=[::nacl::jsquote ###$s\n];bot(t0);"
}

source rowland.natcl