Skip to content

Commit

Permalink
[from now] 2012/04/05 23:08:20
Browse files Browse the repository at this point in the history
diff --git a/browser/main.js b/browser/main.js
index cc36f55..6588cd8 100644
--- a/browser/main.js
+++ b/browser/main.js
@@ -17,4 +17,5 @@ socket.on('snapshot', function (data) {
   for (var prop in data) {
     term[prop] = data[prop];
   }
+  term.refresh(0, 29);
 });
\ No newline at end of file
diff --git a/browser/term.js b/browser/term.js
index 7423080..1d3cb06 100644
--- a/browser/term.js
+++ b/browser/term.js
@@ -150,7 +150,8 @@ Terminal.prototype.refresh = function(start, end) {
     , defAttr
     , fgColor
     , bgColor
-    , row;
+    , row
+    , isInverse;

   for (y = start; y <= end; y++) {
     row = y + this.ydisp;
@@ -187,14 +188,19 @@ Terminal.prototype.refresh = function(start, end) {
             out += '<span style="';
             fgColor = (data >> 3) & 7;
             bgColor = data & 7;
-            if (fgColor !== 7) {
+            isInverse = (data >> 8) & 8;
+            if (fgColor !== 7 || isInverse) {
               out += 'color:'
-                + this.fgColors[fgColor]
+                + (!isInverse
+                   ? this.fgColors[fgColor]
+                   : this.bgColors[bgColor])
                 + ';';
             }
-            if (bgColor !== 0) {
+            if (bgColor !== 0 || isInverse) {
               out += 'background-color:'
-                + this.bgColors[bgColor]
+                + (isInverse
+                   ? this.fgColors[fgColor]
+                   : this.bgColors[bgColor])
                 + ';';
             }
             if ((data >> 8) & 1) {
@@ -1640,12 +1646,18 @@ Terminal.prototype.charAttributes = function(params) {
       } else if (p === 4) {
         // underlined text
         this.curAttr = this.curAttr | (4 << 8);
+      } else if (p === 7) {
+        // inverse text
+        this.curAttr = this.curAttr | (8 << 8);
       } else if (p === 22) {
         // not bold
         this.curAttr = this.curAttr & ~(1 << 8);
       } else if (p === 24) {
         // not underlined
         this.curAttr = this.curAttr & ~(4 << 8);
+      } else if (p === 27) {
+        // not inverse text
+        this.curAttr = this.curAttr & ~(8 << 8);
       } else if (p === 39) {
         // reset fg
         p = this.curAttr & 7;
diff --git a/master_terminal/term.js b/master_terminal/term.js
index c16206b..e0dbb4e 100644
--- a/master_terminal/term.js
+++ b/master_terminal/term.js
@@ -152,7 +152,8 @@ Terminal.prototype.refresh = function(start, end) {
     , defAttr
     , fgColor
     , bgColor
-    , row;
+    , row
+    , isInverse;

   for (y = start; y <= end; y++) {
     row = y + this.ydisp;
@@ -189,14 +190,19 @@ Terminal.prototype.refresh = function(start, end) {
             out += '<span style="';
             fgColor = (data >> 3) & 7;
             bgColor = data & 7;
-            if (fgColor !== 7) {
+            isInverse = (data >> 8) & 8;
+            if (fgColor !== 7 || isInverse) {
               out += 'color:'
-                + this.fgColors[fgColor]
+                + (!isInverse
+                   ? this.fgColors[fgColor]
+                   : this.bgColors[bgColor])
                 + ';';
             }
-            if (bgColor !== 0) {
+            if (bgColor !== 0 || isInverse) {
               out += 'background-color:'
-                + this.bgColors[bgColor]
+                + (isInverse
+                   ? this.fgColors[fgColor]
+                   : this.bgColors[bgColor])
                 + ';';
             }
             if ((data >> 8) & 1) {
@@ -1642,12 +1648,18 @@ Terminal.prototype.charAttributes = function(params) {
       } else if (p === 4) {
         // underlined text
         this.curAttr = this.curAttr | (4 << 8);
+      } else if (p === 7) {
+        // inverse text
+        this.curAttr = this.curAttr | (8 << 8);
       } else if (p === 22) {
         // not bold
         this.curAttr = this.curAttr & ~(1 << 8);
       } else if (p === 24) {
         // not underlined
         this.curAttr = this.curAttr & ~(4 << 8);
+      } else if (p === 27) {
+        // not inverse text
+        this.curAttr = this.curAttr & ~(8 << 8);
       } else if (p === 39) {
         // reset fg
         p = this.curAttr & 7;
diff --git a/server/app.js b/server/app.js
index c820649..f5c01c6 100644
--- a/server/app.js
+++ b/server/app.js
@@ -12,6 +12,8 @@ var mterm = new (require('../master_terminal'))(80, 30),
     io,
     handlers = {};

+mterm.open();
+
 function isObject(obj) {
   return typeof obj === 'object' && obj !== null;
 }
  • Loading branch information
KOBA789 committed Apr 5, 2012
1 parent 336dc84 commit 82d5e28
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
1 change: 1 addition & 0 deletions browser/main.js
Expand Up @@ -17,4 +17,5 @@ socket.on('snapshot', function (data) {
for (var prop in data) {
term[prop] = data[prop];
}
term.refresh(0, 29);
});
22 changes: 17 additions & 5 deletions browser/term.js
Expand Up @@ -150,7 +150,8 @@ Terminal.prototype.refresh = function(start, end) {
, defAttr
, fgColor
, bgColor
, row;
, row
, isInverse;

for (y = start; y <= end; y++) {
row = y + this.ydisp;
Expand Down Expand Up @@ -187,14 +188,19 @@ Terminal.prototype.refresh = function(start, end) {
out += '<span style="';
fgColor = (data >> 3) & 7;
bgColor = data & 7;
if (fgColor !== 7) {
isInverse = (data >> 8) & 8;
if (fgColor !== 7 || isInverse) {
out += 'color:'
+ this.fgColors[fgColor]
+ (!isInverse
? this.fgColors[fgColor]
: this.bgColors[bgColor])
+ ';';
}
if (bgColor !== 0) {
if (bgColor !== 0 || isInverse) {
out += 'background-color:'
+ this.bgColors[bgColor]
+ (isInverse
? this.fgColors[fgColor]
: this.bgColors[bgColor])
+ ';';
}
if ((data >> 8) & 1) {
Expand Down Expand Up @@ -1640,12 +1646,18 @@ Terminal.prototype.charAttributes = function(params) {
} else if (p === 4) {
// underlined text
this.curAttr = this.curAttr | (4 << 8);
} else if (p === 7) {
// inverse text
this.curAttr = this.curAttr | (8 << 8);
} else if (p === 22) {
// not bold
this.curAttr = this.curAttr & ~(1 << 8);
} else if (p === 24) {
// not underlined
this.curAttr = this.curAttr & ~(4 << 8);
} else if (p === 27) {
// not inverse text
this.curAttr = this.curAttr & ~(8 << 8);
} else if (p === 39) {
// reset fg
p = this.curAttr & 7;
Expand Down
22 changes: 17 additions & 5 deletions master_terminal/term.js
Expand Up @@ -152,7 +152,8 @@ Terminal.prototype.refresh = function(start, end) {
, defAttr
, fgColor
, bgColor
, row;
, row
, isInverse;

for (y = start; y <= end; y++) {
row = y + this.ydisp;
Expand Down Expand Up @@ -189,14 +190,19 @@ Terminal.prototype.refresh = function(start, end) {
out += '<span style="';
fgColor = (data >> 3) & 7;
bgColor = data & 7;
if (fgColor !== 7) {
isInverse = (data >> 8) & 8;
if (fgColor !== 7 || isInverse) {
out += 'color:'
+ this.fgColors[fgColor]
+ (!isInverse
? this.fgColors[fgColor]
: this.bgColors[bgColor])
+ ';';
}
if (bgColor !== 0) {
if (bgColor !== 0 || isInverse) {
out += 'background-color:'
+ this.bgColors[bgColor]
+ (isInverse
? this.fgColors[fgColor]
: this.bgColors[bgColor])
+ ';';
}
if ((data >> 8) & 1) {
Expand Down Expand Up @@ -1642,12 +1648,18 @@ Terminal.prototype.charAttributes = function(params) {
} else if (p === 4) {
// underlined text
this.curAttr = this.curAttr | (4 << 8);
} else if (p === 7) {
// inverse text
this.curAttr = this.curAttr | (8 << 8);
} else if (p === 22) {
// not bold
this.curAttr = this.curAttr & ~(1 << 8);
} else if (p === 24) {
// not underlined
this.curAttr = this.curAttr & ~(4 << 8);
} else if (p === 27) {
// not inverse text
this.curAttr = this.curAttr & ~(8 << 8);
} else if (p === 39) {
// reset fg
p = this.curAttr & 7;
Expand Down
2 changes: 2 additions & 0 deletions server/app.js
Expand Up @@ -12,6 +12,8 @@ var mterm = new (require('../master_terminal'))(80, 30),
io,
handlers = {};

mterm.open();

function isObject(obj) {
return typeof obj === 'object' && obj !== null;
}
Expand Down

0 comments on commit 82d5e28

Please sign in to comment.