From e8346779da5a961bb09bf8f91db577eb96ea8b61 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 30 Apr 2015 16:41:43 -0600 Subject: [PATCH] * styleColor -> styleSGR1, styleSGR2 --- core/mci_view_factory.js | 30 +++++------------------------ core/toggle_menu_view.js | 6 ++++-- core/view.js | 5 ++--- core/view_controller.js | 29 +++++++++++++++------------- mods/art/themes/NU-MAYA/MATRIX.ANS | Bin 3317 -> 3327 bytes mods/menu.json | 2 +- 6 files changed, 28 insertions(+), 44 deletions(-) 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 975ce4bb45b9b9c202f6318a60521d510f458504..456eddf81ec9dcd2e1a1b87f1dd2881c0a151e61 100644 GIT binary patch delta 99 zcmew=`CoFwb!JY3Tz$@iEgIgHIgTw~|W|Ct#X#Y_yXjSX^D!+Z@jj5LAb n)+WZ*#>Sh4S*IcE+rS~q1vbSHXo}(HD;&R>8S5rr;86ttmP#BR delta 89 zcmew_`Biemb!K)$183=I1MA5Tm?b$3je%@q^W4phER2l8hSnyAxvF8lh8jki($OZy h*2ddu+ssK?57;69k 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",