changeset 52:a1e72e9c4bf7

The top window now supports styles, although due to some layout issues, as well as some aesthetic considerations, I've decided to ignore the reverse-video style and have anything in the top window always displayed in reverse video. This can be changed later via CSS and, I think, some code changes.
author Atul Varma <varmaa@toolness.com>
date Fri, 16 May 2008 02:47:31 -0700
parents 7435749633eb
children 0abb2dbc2dd1
files console.js gnusto.css trivial-zui.js
diffstat 3 files changed, 31 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/console.js	Fri May 16 02:15:55 2008 -0700
+++ b/console.js	Fri May 16 02:47:31 2008 -0700
@@ -10,12 +10,16 @@
 Console.prototype = {
   clear: function() {
     this._characters = [];
+    this._styles = [];
     for (var y = 0; y < this._height; y++) {
-      var row = [];
+      var charRow = [];
+      var styleRow = [];
       for (var x = 0; x < this._width; x++) {
-        row.push("&nbsp;");
+        charRow.push("&nbsp;");
+        styleRow.push(null);
       }
-      this._characters.push(row);
+      this._characters.push(charRow);
+      this._styles.push(styleRow);
     }
     this.render();
   },
@@ -24,7 +28,7 @@
     this._pos = [x, y];
   },
 
-  write: function(string) {
+  write: function(string, style) {
     var x = this._pos[0];
     var y = this._pos[1];
     for (var i = 0; i < string.length; i++) {
@@ -40,6 +44,7 @@
 
       if (character != null) {
         this._characters[y][x] = character;
+        this._styles[y][x] = style;
         x += 1;
       }
     }
@@ -50,9 +55,19 @@
   render: function() {
     var string = "";
     for (var y = 0; y < this._height; y++) {
+      var currStyle = null;
       for (var x = 0; x < this._width; x++) {
+        if (this._styles[y][x] !== currStyle) {
+          if (currStyle !== null)
+            string += "</span>";
+          currStyle = this._styles[y][x];
+          if (currStyle !== null)
+            string += '<span class="' + currStyle + '">';
+        }
         string += this._characters[y][x];
       }
+      if (currStyle !== null)
+        string += "</span>";
       string += "<br/>";
     }
     this._element.innerHTML = string;
--- a/gnusto.css	Fri May 16 02:15:55 2008 -0700
+++ b/gnusto.css	Fri May 16 02:47:31 2008 -0700
@@ -53,3 +53,12 @@
 .z-fixed-pitch {
     font-family: monaco;
 }
+
+#top-window .z-roman {
+    color: #ffffff;
+}
+
+#top-window .z-bold {
+    font-variant: none;
+    font-weight: bold;
+}
--- a/trivial-zui.js	Fri May 16 02:15:55 2008 -0700
+++ b/trivial-zui.js	Fri May 16 02:47:31 2008 -0700
@@ -181,9 +181,9 @@
     },
 
     onPrint: function(output) {
+      var styles = self._currStyles.join(" ");
+
       if (self._activeWindow == 0) {
-        var styles = self._currStyles.join(" ");
-
         var lines = output.split("\n");
         for (var i = 0; i < lines.length; i++) {
           var addNewline = false;
@@ -203,7 +203,7 @@
 
         window.scroll(0, document.body.scrollHeight);
       } else {
-        self._console.write(output);
+        self._console.write(output, styles);
       }
     }
   };