* Fix colors in relation to MCI codes

* iCE colors working, I think...
This commit is contained in:
Bryan Ashby 2014-11-12 23:16:47 -07:00
parent 7bac1b5193
commit 008e9f46d8
6 changed files with 24 additions and 20 deletions

View File

@ -29,11 +29,6 @@ function ANSIEscapeParser(options) {
this.termHeight = miscUtil.valueWithDefault(options.termHeight, 25); this.termHeight = miscUtil.valueWithDefault(options.termHeight, 25);
this.termWidth = miscUtil.valueWithDefault(options.termWidth, 80); this.termWidth = miscUtil.valueWithDefault(options.termWidth, 80);
function saveLastColor() {
self.lastFlags = self.flags;
self.lastFgCololr = self.fgColor;
self.lastBgColor = self.bgColor;
}
function getArgArray(array) { function getArgArray(array) {
var i = array.length; var i = array.length;
@ -128,7 +123,7 @@ function ANSIEscapeParser(options) {
function getProcessedMCI(mci) { function getProcessedMCI(mci) {
if(self.mciReplaceChar.length > 0) { if(self.mciReplaceChar.length > 0) {
var eraseColor = ansi.sgr(self.lastFlags, self.lastFgColor, self.lastBgColor); var eraseColor = ansi.sgr(self.eraseColor.flags, self.eraseColor.fgColor, self.eraseColor.bgColor);
return eraseColor + new Array(mci.length + 1).join(self.mciReplaceChar); return eraseColor + new Array(mci.length + 1).join(self.mciReplaceChar);
} else { } else {
return mci; return mci;
@ -161,12 +156,24 @@ function ANSIEscapeParser(options) {
args = []; args = [];
} }
// if MCI codes are changing, save off the current color
var fullMciCode = mciCode + (id || '');
if(self.lastMciCode !== fullMciCode) {
self.lastMciCode = fullMciCode;
self.eraseColor = {
flags : self.flags,
fgColor : self.fgColor,
bgColor : self.bgColor,
};
}
self.emit('mci', mciCode, id, args); self.emit('mci', mciCode, id, args);
if(self.mciReplaceChar.length > 0) { if(self.mciReplaceChar.length > 0) {
escape('m', [self.lastFlags, self.lastFgColor, self.lastBgColor]); self.emit('chunk', ansi.sgr(self.eraseColor.flags, self.eraseColor.fgColor, self.eraseColor.bgColor));
self.emit('chunk', ansi.sgr(self.lastFlags, self.lastFgColor, self.lastBgColor));
literal(new Array(match[0].length + 1).join(self.mciReplaceChar)); literal(new Array(match[0].length + 1).join(self.mciReplaceChar));
} else { } else {
literal(match[0]); literal(match[0]);
@ -270,8 +277,6 @@ function ANSIEscapeParser(options) {
// set graphic rendition // set graphic rendition
case 'm' : case 'm' :
saveLastColor();
for(i = 0, len = args.length; i < len; ++i) { for(i = 0, len = args.length; i < len; ++i) {
arg = args[i]; arg = args[i];
/*if(0x00 === arg) { /*if(0x00 === arg) {
@ -292,7 +297,7 @@ function ANSIEscapeParser(options) {
} else if(arg >= 40 && arg <= 47) { } else if(arg >= 40 && arg <= 47) {
self.bgColor = arg; self.bgColor = arg;
} else { } else {
self.flags = arg; self.flags |= arg;
if(0 === arg) { if(0 === arg) {
self.resetColor(); self.resetColor();
} }
@ -311,7 +316,6 @@ function ANSIEscapeParser(options) {
} }
this.resetColor(); this.resetColor();
saveLastColor();
} }
util.inherits(ANSIEscapeParser, events.EventEmitter); util.inherits(ANSIEscapeParser, events.EventEmitter);

View File

@ -51,8 +51,8 @@ var CONTROL = {
goto : 'H', // row Pr, column Pc -- same as f goto : 'H', // row Pr, column Pc -- same as f
gotoAlt : 'f', // same as H gotoAlt : 'f', // same as H
blinkToBrightIntensity : '33h', blinkToBrightIntensity : '?33h',
blinkNormal : '33l', blinkNormal : '?33l',
emulationSpeed : '*r' // Set output emulation speed. See cterm.txt emulationSpeed : '*r' // Set output emulation speed. See cterm.txt
}; };

View File

@ -420,7 +420,7 @@ function display(options, cb) {
parser.removeAllListeners(); // :TODO: Necessary??? parser.removeAllListeners(); // :TODO: Necessary???
if(iceColors) { if(iceColors) {
options.client.term.write(ansi.blinkNormal()); // options.client.term.write(ansi.blinkNormal());
} }
cb(null, mci); cb(null, mci);

View File

@ -1,4 +1,5 @@
"use strict"; /* jslint node: true */
'use strict';
var bunyan = require('bunyan'); var bunyan = require('bunyan');
var miscUtil = require('./misc_util.js'); var miscUtil = require('./misc_util.js');
@ -6,8 +7,6 @@ var paths = require('path');
var conf = require('./config.js'); var conf = require('./config.js');
module.exports = { module.exports = {
log : undefined,
init : function() { init : function() {
//var ringBufferLimit = miscUtil.valueWithDefault(config.logRingBufferLimit, 100); //var ringBufferLimit = miscUtil.valueWithDefault(config.logRingBufferLimit, 100);
var logPath = miscUtil.valueWithDefault(conf.config.paths.logs); var logPath = miscUtil.valueWithDefault(conf.config.paths.logs);

View File

@ -4,6 +4,7 @@
var Config = require('./config.js').config; var Config = require('./config.js').config;
var art = require('./art.js'); var art = require('./art.js');
var miscUtil = require('./misc_util.js'); var miscUtil = require('./misc_util.js');
var logger = require('./logger.js').log;
var fs = require('fs'); var fs = require('fs');
var paths = require('path'); var paths = require('path');
var async = require('async'); var async = require('async');
@ -55,6 +56,7 @@ function initAvailableThemes(cb) {
availableThemes = {}; availableThemes = {};
} }
availableThemes[themeId] = info; availableThemes[themeId] = info;
logger.debug( { info : info }, 'Theme loaded');
} }
}); });
}); });
@ -123,7 +125,6 @@ function displayThemeArt(name, client, cb) {
} }
} }
console.log(artInfo.sauce.flags);
art.display( { art : artInfo.data, client : client, iceColors : iceColors }, function onDisplayed(err, mci) { art.display( { art : artInfo.data, client : client, iceColors : iceColors }, function onDisplayed(err, mci) {
cb(err, mci); cb(err, mci);
}); });

Binary file not shown.