diff --git a/core/mci_view_factory.js b/core/mci_view_factory.js index d88e107d..4a0386e7 100644 --- a/core/mci_view_factory.js +++ b/core/mci_view_factory.js @@ -8,6 +8,8 @@ var VerticalMenuView = require('./vertical_menu_view.js').VerticalMenuView; var SpinnerMenuView = require('./spinner_menu_view.js').SpinnerMenuView; var ToggleMenuView = require('./toggle_menu_view.js').ToggleMenuView; var Config = require('./config.js').config; +var ansi = require('./ansi_term.js'); + var packageJson = require('../package.json'); var assert = require('assert'); @@ -96,26 +98,12 @@ MCIViewFactory.prototype.createFromMCI = function(mci) { setOption(1, 'justify'); setWidth(2); - - /* - if(setOption(2, 'maxLength')) { - options.maxLength = parseInt(options.maxLength, 10); - options.dimens = { width : options.maxLength }; - } - */ - view = new TextView(options); break; // Edit Text case 'ET' : setWidth(0); - /* - if(setOption(0, 'maxLength')) { - options.maxLength = parseInt(options.maxLength, 10); // ensure number - options.dimens = { width : options.maxLength }; - } - */ setOption(1, 'textStyle'); setFocusOption(0, 'focusTextStyle'); @@ -132,13 +120,6 @@ MCIViewFactory.prototype.createFromMCI = function(mci) { setOption(2, 'justify'); setWidth(3); - /* - if(setOption(3, 'maxLength')) { - options.maxLength = parseInt(options.maxLength, 10); - options.dimens = { width : options.maxLength }; - } - */ - view = new TextView(options); } } @@ -179,13 +160,12 @@ MCIViewFactory.prototype.createFromMCI = function(mci) { break; case 'TM' : - // :TODO: convert to new Graphics Rendition system here: if(mci.args.length > 0) { - var color = { fg : parseInt(mci.args[0], 10), flags : 0 }; + var styleSG1 = { fg : parseInt(mci.args[0], 10) }; if(mci.args.length > 1) { - color.bg = parseInt(mci.args[1], 10); + styleSG1.bg = parseInt(mci.args[1], 10); } - options.styleColor1 = color; + options.styleSG1 = ansi.getSGRFromGraphicRendition(styleSG1, true); } setFocusOption(0, 'focusTextStyle'); diff --git a/core/toggle_menu_view.js b/core/toggle_menu_view.js index a01f3331..639df6aa 100644 --- a/core/toggle_menu_view.js +++ b/core/toggle_menu_view.js @@ -49,8 +49,10 @@ ToggleMenuView.prototype.redraw = function() { //console.log(this.styleColor1) //var sepColor = this.getANSIColor(this.styleColor1 || this.getColor()); //console.log(sepColor.substr(1)) - var sepColor = '\u001b[0m\u001b[1;30m'; // :TODO: FIX ME!!! - this.client.term.write(sepColor + ' / '); + //var sepColor = '\u001b[0m\u001b[1;30m'; // :TODO: FIX ME!!! + // :TODO: sepChar needs to be configurable!!! + this.client.term.write(this.styleSGR1 + ' / '); + //this.client.term.write(sepColor + ' / '); } this.client.term.write(i === this.focusedItemIndex ? this.getFocusSGR() : this.getSGR()); diff --git a/core/view.js b/core/view.js index 61d8037b..a251a039 100644 --- a/core/view.js +++ b/core/view.js @@ -67,9 +67,8 @@ function View(options) { this.ansiSGR = options.ansiSGR || ansi.getSGRFromGraphicRendition( { fg : 39, bg : 49 }, true); this.ansiFocusSGR = options.ansiFocusSGR || this.ansiSGR; - if(options.styleColor1) { - this.styleColor1 = options.styleColor1; - } + this.styleSGR1 = options.styleSGR1 || this.ansiSGR; + this.styleSGR2 = options.styleSGR2 || this.ansiFocusSGR; if(this.acceptsInput) { this.specialKeyMap = options.specialKeyMap || VIEW_SPECIAL_KEY_MAP_DEFAULT; diff --git a/core/view_controller.js b/core/view_controller.js index 808bdb32..5a87e85e 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -183,22 +183,25 @@ function ViewController(options) { setViewProp('focusTextStyle'); setViewProp('maxLength'); setViewProp('width', function(v) { view.dimens.width = parseInt(v, 10); }); - - // :TODO: This needs converted to new GraphicRendition object and possibly allow escaped ANSI SGR here if string - setViewProp('styleColor1', function(v) { - if(!_.has(v, 'fg')) { - return; + + setViewProp('styleSGR1', function(v) { + if(_.isObject(v)) { + view.styleSGR1 = ansi.getSGRFromGraphicRendition(v, true); + console.log(view.styleSGR1.substr(1)) + } else if(_.isString(v)) { + view.styleSGR1 = v; } - - var color = { - fg : v.fg, - bg : v.bg || 0, - flags : v.flags || 0 - }; - - view.styleColor1 = color; }); + setViewProp('styleSGR2', function(v) { + if(_.isObject(v)) { + view.styleSGR2 = ansi.getSGRFromGraphicRendition(v, true); + } else if(_.isString(v)) { + view.styleSGR2 = v; + } + }); + + setViewProp('fillChar', function(v) { if(_.isNumber(v)) { view.fillChar = String.fromCharCode(v); diff --git a/mods/art/themes/NU-MAYA/MATRIX.ANS b/mods/art/themes/NU-MAYA/MATRIX.ANS index 975ce4bb..456eddf8 100644 Binary files a/mods/art/themes/NU-MAYA/MATRIX.ANS and b/mods/art/themes/NU-MAYA/MATRIX.ANS differ diff --git a/mods/menu.json b/mods/menu.json index 16235591..5df725c2 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -267,7 +267,7 @@ }, "TM3" : { "items" : [ "Yarly", "Nowaii" ], - "styleColor1" : { "fg" : 30, "flags" : 1 } + "styleSGR1" : { "fg" : 30, "intensity" : 1 } }, "BT8" : { "text" : "< Back",