diff --git a/js-assembler/runtime-src/baselib-ports.js b/js-assembler/runtime-src/baselib-ports.js index 1df7073..f84d490 100644 --- a/js-assembler/runtime-src/baselib-ports.js +++ b/js-assembler/runtime-src/baselib-ports.js @@ -67,20 +67,20 @@ var isInputPort = baselib.makeClassPredicate(InputPort); - var DefaultInputPort = function() { + var StandardInputPort = function() { this.content = []; this.closed = false; }; - DefaultInputPort.prototype = baselib.heir(InputPort.prototype); + StandardInputPort.prototype = baselib.heir(InputPort.prototype); - DefaultInputPort.prototype.readByte = function(MACHINE) { + StandardInputPort.prototype.readByte = function(MACHINE) { if (this.content.length !== 0) { return this.content.shift(); } return baselib.constants.EOF_VALUE; }; - DefaultInputPort.prototype.callWhenReady = function(MACHINE, k) { + StandardInputPort.prototype.callWhenReady = function(MACHINE, k) { if (this.content.length > 0) { return k(); } @@ -89,8 +89,8 @@ } var that = this; var textFieldDiv = $("
" + - " " + - " "+ + " " + + " "+ "
"); var readLine = textFieldDiv.find(".readline"); var eofRead = textFieldDiv.find(".eofread"); @@ -101,14 +101,14 @@ return k(); }; - readLine.find(".readline").keypress( + readLine.keypress( function(e) { var val, i; // On return, send the text content into that.content; if (e.which === 13) { e.stopPropagation(); e.preventDefault(); - val = textFieldDiv.val(); + val = readLine.val(); for (i = 0; i < val.length; i++) { that.content.push(val.charCodeAt(i)); } @@ -116,8 +116,10 @@ cleanupAndContinue(); } }); - eofRead.find(".eofread").click( + eofRead.click( function(e) { + e.stopPropagation(); + e.preventDefault(); that.closed = true; cleanupAndContinue(); }); @@ -135,5 +137,7 @@ exports.InputPort = InputPort; exports.isInputPort = isInputPort; + exports.StandardInputPort = StandardInputPort; + }(this.plt.baselib, $)); \ No newline at end of file diff --git a/js-assembler/runtime-src/baselib-primitives.js b/js-assembler/runtime-src/baselib-primitives.js index ab5f834..a7843c5 100644 --- a/js-assembler/runtime-src/baselib-primitives.js +++ b/js-assembler/runtime-src/baselib-primitives.js @@ -334,7 +334,7 @@ inputPort = checkInputPort(M, 'read-byte', 0); } plt.runtime.PAUSE(function(restart) { - inputPort.callWhenReady(function() { + inputPort.callWhenReady(M, function() { restart(function(MACHINE) { plt.runtime.finalizeClosureCall(MACHINE, inputPort.readByte(MACHINE)); diff --git a/js-assembler/runtime-src/runtime.js b/js-assembler/runtime-src/runtime.js index 30bd399..78fe167 100644 --- a/js-assembler/runtime-src/runtime.js +++ b/js-assembler/runtime-src/runtime.js @@ -93,6 +93,7 @@ var isOutputPort = baselib.ports.isOutputPort; var StandardOutputPort = baselib.ports.StandardOutputPort; var StandardErrorPort = baselib.ports.StandardErrorPort; + var StandardInputPort = baselib.ports.StandardInputPort; var isOutputStringPort = baselib.ports.isOutputStringPort; @@ -247,6 +248,7 @@ 'currentOutputPort': new StandardOutputPort(), 'currentErrorPort': new StandardErrorPort(), + 'currentInputPort': new StandardInputPort(), 'currentSuccessHandler': function(MACHINE) {}, 'currentErrorHandler': function(MACHINE, exn) { MACHINE.params.currentErrorDisplayer( diff --git a/lang/kernel.rkt b/lang/kernel.rkt index fbeb074..4b81c63 100644 --- a/lang/kernel.rkt +++ b/lang/kernel.rkt @@ -467,9 +467,11 @@ char=? make-reader-graph make-placeholder - placeholder-set!) + placeholder-set! + read-byte) + diff --git a/version.rkt b/version.rkt index 1c5d403..781ab75 100644 --- a/version.rkt +++ b/version.rkt @@ -6,4 +6,4 @@ (provide version) (: version String) -(define version "1.40") +(define version "1.41")