Mercurial > web-gnusto
changeset 62:3355248e2638
Fixed a top-window display bug in curses.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 16 May 2008 13:44:46 -0700 |
parents | 7714b3322ee3 |
children | 605a0060e5a7 |
files | console.js engine-runner.js web-zui.js |
diffstat | 3 files changed, 53 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/console.js Fri May 16 12:23:14 2008 -0700 +++ b/console.js Fri May 16 13:44:46 2008 -0700 @@ -8,19 +8,45 @@ } Console.prototype = { + resize: function(height) { + var linesAdded = height - this._height; + + if (linesAdded == 0) + return; + + var y; + + if (linesAdded > 0) + for (y = 0; y < linesAdded; y++) + this._addRow(); + else + for (y = 0; y < -linesAdded; y++) + this._delRow(); + this._height = height; + this.render(); + }, + + _delRow: function() { + this._characters.pop(); + this._styles.pop(); + }, + + _addRow: function() { + var charRow = []; + var styleRow = []; + for (var x = 0; x < this._width; x++) { + charRow.push(" "); + styleRow.push(null); + } + this._characters.push(charRow); + this._styles.push(styleRow); + }, + clear: function() { this._characters = []; this._styles = []; - for (var y = 0; y < this._height; y++) { - var charRow = []; - var styleRow = []; - for (var x = 0; x < this._width; x++) { - charRow.push(" "); - styleRow.push(null); - } - this._characters.push(charRow); - this._styles.push(styleRow); - } + for (var y = 0; y < this._height; y++) + this._addRow(); this.render(); },
--- a/engine-runner.js Fri May 16 12:23:14 2008 -0700 +++ b/engine-runner.js Fri May 16 13:44:46 2008 -0700 @@ -2,6 +2,8 @@ } Zui.prototype = { + setVersion: function(version) { + }, // Returns a 2-element list containing the width and height of the // screen, in characters. The width may be 255, which means @@ -95,6 +97,7 @@ run: function() { var size = self._zui.getSize(); + self._zui.setVersion(self._engine.m_version); self._isRunning = true; self._engine.m_memory[0x20] = size[1];
--- a/web-zui.js Fri May 16 12:23:14 2008 -0700 +++ b/web-zui.js Fri May 16 13:44:46 2008 -0700 @@ -145,6 +145,10 @@ $("#content").html(""); }, + setVersion: function(version) { + self._version = version; + }, + getSize: function() { return self._size; }, @@ -237,11 +241,16 @@ self._console.close(); self._console = null; } - } else - self._console = new Console(self._size[0], - numlines, - $("#top-window").get(0), - self); + } else { + if (!self._console || self._version == 3) { + self._console = new Console(self._size[0], + numlines, + $("#top-window").get(0), + self); + } else { + self._console.resize(numlines); + } + } }, onPrint: function(output) {