diff --git a/core/art.js b/core/art.js index 6f2766a5..fa5da30e 100644 --- a/core/art.js +++ b/core/art.js @@ -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) { diff --git a/core/menu_module.js b/core/menu_module.js index 000a0631..563ab3c7 100644 --- a/core/menu_module.js +++ b/core/menu_module.js @@ -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; diff --git a/core/view.js b/core/view.js index a251a039..091ce0ee 100644 --- a/core/view.js +++ b/core/view.js @@ -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; diff --git a/core/view_controller.js b/core/view_controller.js index 5a87e85e..24f5c026 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -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) { diff --git a/mods/menu.json b/mods/menu.json index 5df725c2..917a24e9 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -19,6 +19,22 @@ NOte that @draw & @art should check theme first. @draw:myMethod -> theme/draw.js::myMethod(opts) + priority: + @draw:location.js/myMethod -> outside of theme + @draw:myMethod -> checks theme -> local first + + -OR- just inside themes for customization... + e.g; + { + "myTheme" { + "views" : { + "VerticalMenuView" : { + "draw" : "@method:location.js/myMethod" + } + } + } + } + } } */ @@ -99,40 +115,64 @@ "form" : { "0" : { "BT12BT13ET1ET10ET2ET3ET4ET5ET6ET7ET8ET9TL11" : { + // + // :TODO: defaults { width : XX, ... } kinda thing would be nice // // "beforeViewsDraw" : "@method:location.js/myBeforeViewsDraw" -> myBeforeViewsDraw(views) "mci" : { "ET1" : { "focus" : true, - "argName" : "username" + "argName" : "username", + "width" : 15, + "maxLength" : "@config:users.usernameMax" }, "ET2" : { - "argName" : "realName", - "maxLength" : "@config:users.usernameMax" + "width" : 15, + "argName" : "realName", + "width" : 15, + "maxLength" : 32 + }, + "ET3" : { + "argName" : "age", + "width" : 3, + "maxLength" : 3 + }, + "ET4" : { + "argName" : "sex", + "width" : 1, + "maxLength" : 1 + }, + "ET5" : { + "argName" : "location", + "width" : 15, + "maxLength" : 32 }, - "ET3" : { "argName" : "age" }, - "ET4" : { "argName" : "sex" }, - "ET5" : { "argName" : "location" }, "ET6" : { "argName" : "affils", - "maxLength" : 30 + "width" : 15, + "maxLength" : 32 }, "ET7" : { "argName" : "email", + "width" : 15, "maxLength" : 255 }, "ET8" : { "argName" : "web", + "width" : 15, "maxLength" : 255 }, "ET9" : { - "argName" : "password", - "password" : true + "argName" : "password", + "password" : true, + "width" : 15, + "maxLength" : "@config:users.passwordMax" }, "ET10" : { - "argName" : "passwordConfirm", - "password" : true, - "maxLength" : "@config:users.passwordMax" + "argName" : "passwordConfirm", + "password" : true, + "width" : 15, + "maxLength" : "@config:users.passwordMax" }, "BT12" : { "submit" : true, @@ -170,6 +210,7 @@ }, "newUserActive" : { "art" : "STATS", + "prompt" : "pause", "options" : { // :TODO: implement MCI codes for this "cls" : true @@ -266,8 +307,9 @@ "items" : [ "Razor 1911", "DrinkOrDie", "TRSI" ] }, "TM3" : { - "items" : [ "Yarly", "Nowaii" ], - "styleSGR1" : { "fg" : 30, "intensity" : 1 } + "items" : [ "Yarly", "Nowaii" ], + "styleSGR1" : { "fg" : 30, "intensity" : 1 }, + "hotkeys" : { "Y" : 0, "N" : 1 } }, "BT8" : { "text" : "< Back", diff --git a/mods/prompt.json b/mods/prompt.json index 1ea11ddd..e7de80cc 100644 --- a/mods/prompt.json +++ b/mods/prompt.json @@ -11,5 +11,59 @@ "password" : true } } + }, + "pause" : { + "art" : "pause" + /* + "mci" : { + // :TODO: Need special pause for a key MCI + // e.g. %PA -> themed prompt + } + + ...or maybe pause should just be special: + { + ... + "pause" true + // uses theme pause which can be art/inline/etc. + + } + + ... better, a special prompt + + GetKeyView + * showKey : false + + */ + }, + "standard" : { + "pause" : { + "art" : "pause" + } + }, + "custom" : { + } + /* + see notes in menu_module.js also + ...how to allow for this to come from the theme first??? + same as custom vc drawing/etc.? ... + + { + "theme" : { + "inlineArt" : { + "something" : "%MC and |01Pipe codes here" + } + } + } + + "pause" : { + "art" : "@inline:simplePrompt", + // support pipe codes & MCI + "simplePrompt" : "--------/ Pause /----------------", + "mci" : { + + } + } + */ + } \ No newline at end of file