* styleColor -> styleSGR1, styleSGR2

This commit is contained in:
Bryan Ashby 2015-04-30 16:41:43 -06:00
parent 04c85d2311
commit e8346779da
6 changed files with 28 additions and 44 deletions

View File

@ -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');

View File

@ -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());

View File

@ -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;

View File

@ -184,21 +184,24 @@ function ViewController(options) {
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);

Binary file not shown.

View File

@ -267,7 +267,7 @@
},
"TM3" : {
"items" : [ "Yarly", "Nowaii" ],
"styleColor1" : { "fg" : 30, "flags" : 1 }
"styleSGR1" : { "fg" : 30, "intensity" : 1 }
},
"BT8" : {
"text" : "< Back",