# HG changeset patch # User Atul Varma # Date 1210965794 25200 # Node ID 7714b3322ee3568772938fca18e59f6e8265c79c # Parent 8c98e4025e9ec4a5159b67b231a910a3692e960c WebZui now logs print opcodes. diff -r 8c98e4025e9e -r 7714b3322ee3 web-zui.js --- a/web-zui.js Fri May 16 12:06:50 2008 -0700 +++ b/web-zui.js Fri May 16 12:23:14 2008 -0700 @@ -1,19 +1,31 @@ var BACKSPACE_KEYCODE = 8; var RETURN_KEYCODE = 13; -function WebZui() { +function WebZui(logfunc) { this._size = [80, 255]; this._console = null; this._activeWindow = 0; this._inputString = ""; this._currentCallback = null; this._currStyles = ["z-roman"]; + + if (logfunc) { + this._log = logfunc; + } else { + this._log = function() {}; + } + var self = this; this.__proto__ = { onConsoleRender: function() { var height = $("#top-window").get(0).clientHeight; $("#content").get(0).style.padding = "" + height + "px 0 0 0"; + self._scrollBottomWindow(); + }, + + _scrollBottomWindow: function() { + window.scroll(0, document.body.scrollHeight); }, _finalize: function() { @@ -235,6 +247,9 @@ onPrint: function(output) { var styles = self._currStyles.join(" "); + self._log("print wind: " + self._activeWindow + " output: " + + output.quote() + " style: " + styles); + if (self._activeWindow == 0) { var lines = output.split("\n"); for (var i = 0; i < lines.length; i++) { @@ -253,7 +268,7 @@ $("#content").append("
"); } - window.scroll(0, document.body.scrollHeight); + self._scrollBottomWindow(); } else { self._console.write(output, styles); } @@ -273,7 +288,7 @@ } var engine = new GnustoEngine(); - var zui = new WebZui(); + var zui = new WebZui(logfunc); var runner = new EngineRunner(engine, zui, logfunc); engine.loadStory(zcode.slice());