* WIP pause prompt
* prompt.json::prompts::pause is now a standard/required prompt * CT for current time MCI * Fix up config/theme defaults.dateTimeFormat -> dateFormat & timeFormat
This commit is contained in:
parent
7f4c97329d
commit
8b5152d66f
|
@ -445,7 +445,7 @@ function display(options, cb) {
|
|||
}
|
||||
|
||||
var extraInfo = {
|
||||
height : parser.row - 1
|
||||
height : parser.row - 1,
|
||||
};
|
||||
|
||||
cb(null, mciMap, extraInfo);
|
||||
|
|
|
@ -91,8 +91,11 @@ function getDefaultConfig() {
|
|||
defaults : {
|
||||
theme : 'NU-MAYA', // :TODO: allow "*" here
|
||||
passwordChar : '*', // TODO: move to user ?
|
||||
dateTimeFormat : {
|
||||
dateFormat : {
|
||||
short : 'MM/DD/YYYY',
|
||||
},
|
||||
timeFormat : {
|
||||
short : 'h:mm tt',
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -95,6 +95,22 @@ function displayBanner(term) {
|
|||
function connectEntry(client) {
|
||||
var term = client.term;
|
||||
|
||||
/*
|
||||
theme.displayThemeArt({client : client, name : 'DM-ENIG.ANS'}, function onArt() {
|
||||
return;
|
||||
});
|
||||
*/
|
||||
/*
|
||||
var iconv = require('iconv-lite');
|
||||
var art1 = require('fs').readFileSync('/home/nuskooler/dev/enigma-bbs/mods/art/DM-ENIG.ANS');
|
||||
console.log(typeof art1);
|
||||
art1 = iconv.decode(art1, 'cp437');
|
||||
console.log(typeof art1)
|
||||
term.output.write(art1);
|
||||
//term.output.write(require('iconv-lite').encode(art1, 'CP437'));
|
||||
return;
|
||||
*/
|
||||
|
||||
// :TODO: Enthral for example queries cursor position & checks if it worked. This might be good
|
||||
// :TODO: How to detect e.g. if show/hide cursor can work? Probably can if CPR is avail
|
||||
|
||||
|
@ -130,14 +146,6 @@ function connectEntry(client) {
|
|||
//
|
||||
displayBanner(term);
|
||||
|
||||
/*
|
||||
var art1 = require('fs').readFileSync('/home/nuskooler/dev/enigma-bbs/mods/themes/NU-MAYA/APPLY1.ANS');
|
||||
term.rawWrite(art1);
|
||||
theme.displayThemeArt({client : client, name : 'APPLY1.ANS'}, function onArt() {
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
setTimeout(function onTimeout() {
|
||||
client.gotoMenuModule( { name : Config.firstMenu });
|
||||
}, 500);
|
||||
|
|
|
@ -52,13 +52,13 @@ JSONCache.prototype.getJSON = function(fileName, cb) {
|
|||
var filePath = paths.join(Config.paths.mods, fileName);
|
||||
|
||||
if(filePath in this.cache) {
|
||||
cb(null, this.cache[filePath]);
|
||||
cb(null, this.cache[filePath], false);
|
||||
} else {
|
||||
this.reCacheJSONFromFile(filePath, function fileCached(err, json) {
|
||||
if(!err) {
|
||||
self.gaze.add(filePath);
|
||||
}
|
||||
cb(err, json);
|
||||
cb(err, json, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -54,7 +54,10 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
|||
|
||||
ND : this.client.runtime.id.toString(),
|
||||
|
||||
// :TODO: change to CD for 'Current Date'
|
||||
DT : moment().format(this.client.currentTheme.helpers.getDateFormat()),
|
||||
CT : moment().format(this.client.currentTheme.helpers.getTimeFormat()),
|
||||
|
||||
|
||||
OS : {
|
||||
linux : 'Linux',
|
||||
|
|
|
@ -228,7 +228,7 @@ MenuModule.prototype.finishedLoading = function() {
|
|||
|
||||
if('end' === self.menuConfig.pause || true === self.menuConfig.pause) {
|
||||
// :TODO: really need a client.term.pause() that uses the correct art/etc.
|
||||
self.client.waitForKeyPress(function kp(ch, key) {
|
||||
theme.displayThemePause( { client : self.client }, function keyPressed() {
|
||||
nextAction();
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -43,7 +43,7 @@ function getMenuConfig(name, cb) {
|
|||
},
|
||||
function loadPromptJSON(callback) {
|
||||
if(_.isString(menuConfig.prompt)) {
|
||||
jsonCache.getJSON('prompt.json', function loaded(err, promptJson) {
|
||||
jsonCache.getJSON('prompt.json', function loaded(err, promptJson, reCached) {
|
||||
callback(err, promptJson);
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
|
||||
var Config = require('./config.js').config;
|
||||
var art = require('./art.js');
|
||||
var ansi = require('./ansi_term.js');
|
||||
var miscUtil = require('./misc_util.js');
|
||||
var Log = require('./logger.js').log;
|
||||
var jsonCache = require('./json_cache.js');
|
||||
|
||||
var fs = require('fs');
|
||||
var paths = require('path');
|
||||
|
@ -18,6 +20,7 @@ exports.getThemeArt = getThemeArt;
|
|||
exports.getRandomTheme = getRandomTheme;
|
||||
exports.initAvailableThemes = initAvailableThemes;
|
||||
exports.displayThemeArt = displayThemeArt;
|
||||
exports.displayThemePause = displayThemePause;
|
||||
|
||||
// :TODO: use JSONCache here... may need to fancy it up a bit in order to have events for after re-cache, e.g. to update helpers below:
|
||||
function loadTheme(themeID, cb) {
|
||||
|
@ -56,10 +59,20 @@ function loadTheme(themeID, cb) {
|
|||
getDateFormat : function(style) {
|
||||
style = style || 'short';
|
||||
|
||||
var format = Config.defaults.dateTimeFormat[style] || 'MM/DD/YYYY';
|
||||
var format = Config.defaults.dateFormat[style] || 'MM/DD/YYYY';
|
||||
|
||||
if(_.has(theme, 'customization.defaults.dateTimeFormat')) {
|
||||
return theme.customization.defaults.dateTimeFormat[style] || format;
|
||||
if(_.has(theme, 'customization.defaults.dateFormat')) {
|
||||
return theme.customization.defaults.dateFormat[style] || format;
|
||||
}
|
||||
return format;
|
||||
},
|
||||
getTimeFormat : function(style) {
|
||||
style = style || 'short';
|
||||
|
||||
var format = Config.defaults.timeFormat[style] || 'h:mm tt';
|
||||
|
||||
if(_.has(theme, 'customization.defaults.timeFormat')) {
|
||||
return theme.customization.defaults.timeFormat[style] || format;
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
@ -175,3 +188,70 @@ function displayThemeArt(options, cb) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
function displayThemePause(options, cb) {
|
||||
//
|
||||
// options.client
|
||||
// options clearPrompt
|
||||
//
|
||||
assert(_.isObject(options.client));
|
||||
|
||||
if(!_.isBoolean(options.clearPrompt)) {
|
||||
options.clearPrompt = true;
|
||||
}
|
||||
|
||||
// :TODO: Support animated pause prompts. Probably via MCI with AnimatedView
|
||||
// :TODO: support prompts with a height > 1
|
||||
// :TODO: Prompt should support MCI codes in general
|
||||
// ...this will be more complex due to cursor movement. Will need to track where teh cusor
|
||||
// was before the prompt + filling MCI, then move back and erase correct # of lines
|
||||
|
||||
async.waterfall(
|
||||
[
|
||||
function loadPromptJSON(callback) {
|
||||
jsonCache.getJSON('prompt.json', function loaded(err, promptJson) {
|
||||
if(err) {
|
||||
callback(err);
|
||||
} else {
|
||||
if(_.has(promptJson, [ 'prompts', 'pause' ] )) {
|
||||
callback(null, promptJson.prompts.pause);
|
||||
} else {
|
||||
callback(new Error('Missing standard \'pause\' prompt'))
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
function displayPausePrompt(pausePrompt, callback) {
|
||||
displayThemeArt( { client : options.client, name : pausePrompt.art }, function pauseDisplayed(err, mciMap, extraInfo) {
|
||||
if(extraInfo) {
|
||||
pauseHeight = extraInfo.height;
|
||||
}
|
||||
callback(null);
|
||||
});
|
||||
},
|
||||
function pauseForUserInput(callback) {
|
||||
options.client.waitForKeyPress(function keyPressed() {
|
||||
callback(null);
|
||||
});
|
||||
},
|
||||
function clearPauseArt(callback) {
|
||||
if(options.clearPrompt) {
|
||||
options.client.term.write(ansi.up(1) + ansi.deleteLine());
|
||||
}
|
||||
callback(null);
|
||||
}
|
||||
, function debugPause(callback) {
|
||||
setTimeout(function to() {
|
||||
callback(null);
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
],
|
||||
function complete(err) {
|
||||
if(err) {
|
||||
Log.error(err);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
}
|
||||
},
|
||||
"pause" : {
|
||||
//
|
||||
// Any menu 'pause' will use this prompt
|
||||
//
|
||||
"art" : "pause"
|
||||
/*
|
||||
"mci" : {
|
||||
|
@ -37,7 +40,7 @@
|
|||
* echoKey : false
|
||||
|
||||
*/
|
||||
},
|
||||
}/*,
|
||||
"standard" : {
|
||||
// any menu 'pause' will display this, pause for a key, then erase and move on
|
||||
"pause" : {
|
||||
|
@ -47,7 +50,7 @@
|
|||
},
|
||||
"custom" : {
|
||||
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
see notes in menu_module.js also
|
||||
...how to allow for this to come from the theme first???
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"general" : {
|
||||
"passwordChar" : "φ"
|
||||
},
|
||||
"dateTimeFormat" : {
|
||||
"dateFormat" : {
|
||||
"short" : "YYYY-MMM-DD"
|
||||
},
|
||||
"mci" : {
|
||||
|
|
Loading…
Reference in New Issue