* Some code cleanup

* Lots of notes/thoughts
This commit is contained in:
Bryan Ashby 2015-04-30 22:29:24 -06:00
parent e8346779da
commit 3f92a7949d
6 changed files with 157 additions and 41 deletions

View file

@ -452,8 +452,18 @@ function display(options, cb) {
parser.on('mci', function mciEncountered(mciInfo) {
/*
if('PA' === mciInfo.mci) {
// :TODO: can't do this until this thing is pausable anyway...
options.client.waitForKeyPress(function kp(k) {
console.log('got a key: ' + k);
});
return;
}
*/
// :TODO: ensure generatedId's do not conflict with any |id|
var id = _.isUndefined(mciInfo.id) ? generatedId++ : mciInfo.id;
var id = !_.isNumber(mciInfo.id) ? generatedId++ : mciInfo.id;
var mapKey = mciInfo.mci + id;
var mapEntry = mciMap[mapKey];
if(mapEntry) {

View file

@ -50,6 +50,13 @@ function MenuModule(options) {
// :TODO: fetch and render via method/generator
break;
case 'inline' :
if(_.isString(assetSpec.asset)) {
// :TODO: think about this more in relation to themes, etc. How can this come
// from a theme (with override from menu.json) ???
}
break;
default :
cb(new Error('Unsupported art asset type'));
break;

View file

@ -56,13 +56,20 @@ function View(options) {
}
// :TODO: Don't allow width/height > client.term
if(options.dimens && options.dimens.height) {
this.dimens.height = options.dimens.height;
if(_.isObject(options.dimens)) {
if(_.isNumber(options.dimens.height)) {
this.dimens.height = options.dimens.height;
}
if(_.isNumber(options.dimens.width)) {
this.dimens.width = options.dimens.width;
}
} else {
options.dimens = { width : 1, height : 1 };
}
if(options.dimens && options.dimens.width) {
this.dimens.width = options.dimens.width;
}
options.dimens.width = options.dimens.width || 1;
options.dimens.height = options.dimens.height || 1;
this.ansiSGR = options.ansiSGR || ansi.getSGRFromGraphicRendition( { fg : 39, bg : 49 }, true);
this.ansiFocusSGR = options.ansiFocusSGR || this.ansiSGR;

View file

@ -184,23 +184,15 @@ function ViewController(options) {
setViewProp('maxLength');
setViewProp('width', function(v) { view.dimens.width = parseInt(v, 10); });
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;
}
});
setViewProp('styleSGR2', function(v) {
if(_.isObject(v)) {
view.styleSGR2 = ansi.getSGRFromGraphicRendition(v, true);
} else if(_.isString(v)) {
view.styleSGR2 = v;
}
});
['styleSGR1', 'styleSGR2'].forEach(function styleSgr(style) {
setViewProp(style, function(v) {
if(_.isObject(v)) {
view.styleSGR1 = ansi.getSGRFromGraphicRendition(v, true);
} else if(_.isString(v)) {
view.styleSGR1 = v;
}
});
});
setViewProp('fillChar', function(v) {
if(_.isNumber(v)) {
@ -397,10 +389,14 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) {
});
},
function applyViewConfiguration(callback) {
self.applyViewConfig(promptConfig, function configApplied(err, info) {
initialFocusId = info.initialFocusId;
callback(err);
});
if(_.isObject(promptConfig.mci)) {
self.applyViewConfig(promptConfig, function configApplied(err, info) {
initialFocusId = info.initialFocusId;
callback(err);
});
} else {
callback(null);
}
},
function prepareFormSubmission(callback) {