* Very very early work on FSE module

This commit is contained in:
Bryan Ashby 2015-06-25 22:34:33 -06:00
parent f56546cae5
commit 32fdbab88d
7 changed files with 117 additions and 56 deletions

View File

@ -380,7 +380,6 @@ function defaultEofFromExtension(ext) {
// :TODO: change to display(art, options, cb)
// cb(err, mci)
// :TODO: display({ art : art, client : client, ...}, cb)
function display(options, cb) {
assert(_.isObject(options));
assert(_.isObject(options.client));
@ -445,7 +444,11 @@ function display(options, cb) {
// options.client.term.write(ansi.blinkNormal());
}
cb(null, mciMap);
var extraInfo = {
height : parser.row - 1
};
cb(null, mciMap, extraInfo);
}
options.client.on('cursor position report', cprListener);
@ -454,6 +457,7 @@ function display(options, cb) {
var nextPauseTermHeight = options.client.term.termHeight;
var continous = false;
/*
parser.on('row update', function rowUpdate(row) {
if(row >= nextPauseTermHeight) {

View File

@ -42,8 +42,8 @@ function MenuModule(options) {
switch(artAsset.type) {
case 'art' :
theme.displayThemeArt(dispOptions, function displayed(err, mciMap) {
cb(err, mciMap);
theme.displayThemeArt(dispOptions, function displayed(err, themeArtData) {
cb(err, { mciMap : themeArtData.mciMap, height : themeArtData.extraInfo.height } );
});
break;
@ -76,8 +76,8 @@ function MenuModule(options) {
},
function displayMenuArt(callback) {
if(_.isString(self.menuConfig.art)) {
self.displayArtAsset(self.menuConfig.art, function displayed(err, mciMap) {
mciData.menu = mciMap;
self.displayArtAsset(self.menuConfig.art, function displayed(err, artData) {
mciData.menu = artData.mciMap;
callback(err);
});
} else {
@ -165,13 +165,10 @@ MenuModule.prototype.standardMCIReadyHandler = function(mciData) {
// * Standard/prefdefined MCI entries must load both (e.g. %BN is expected to resolve)
//
var self = this;
self.viewControllers = {};
//var vcOpts = { client : self.client };
_.forEach(mciData, function entry(mciMap, name) {
assert('menu' === name || 'prompt' === name);
self.viewControllers[name] = new ViewController( { client : self.client } );
self.addViewController(name, new ViewController( { client : self.client } ));
});
var viewsReady = function(err) {

View File

@ -158,8 +158,8 @@ function displayThemeArt(options, cb) {
font : options.font,
};
art.display(dispOptions, function displayed(err, mciMap) {
cb(err, mciMap, artInfo);
art.display(dispOptions, function displayed(err, mciMap, extraInfo) {
cb(err, { mciMap : mciMap, artInfo : artInfo, extraInfo : extraInfo } );
});
}
});

View File

@ -39,7 +39,8 @@ function ViewController(options) {
//
// Process key presses treating form submit mapped
// keys special. Everything else is forwarded on to
// the focused View, if any. //
// the focused View, if any.
//
if(key) {
var submitViewId = self.submitKeyMap[key.name];
if(submitViewId) {
@ -412,6 +413,19 @@ ViewController.prototype.setViewOrder = function(order) {
}
};
ViewController.prototype.redrawAll = function(initialFocusId) {
this.client.term.write(ansi.hideCursor());
for(var id in this.views) {
if(initialFocusId === id) {
continue; // will draw @ focus
}
this.views[id].redraw();
}
this.client.term.write(ansi.showCursor());
};
ViewController.prototype.loadFromPromptConfig = function(options, cb) {
assert(_.isObject(options));
assert(_.isObject(options.mciMap));
@ -459,14 +473,7 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) {
callback(null);
},
function drawAllViews(callback) {
self.client.term.write(ansi.hideCursor());
for(var id in self.views) {
if(initialFocusId === id) {
continue; // will draw @ focus
}
self.views[id].redraw();
}
self.redrawAll(initialFocusId);
callback(null);
},
function setInitialViewFocus(callback) {
@ -609,14 +616,7 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) {
callback(null);
},
function drawAllViews(callback) {
self.client.term.write(ansi.hideCursor());
for(var id in self.views) {
if(initialFocusId === id) {
continue; // will draw @ focus
}
self.views[id].redraw();
}
self.redrawAll(initialFocusId);
callback(null);
},
function setInitialViewFocus(callback) {

View File

@ -1,11 +1,12 @@
/* jslint node: true */
'use strict';
var MenuModule = require('../core/menu_module.js').MenuModule;
var MenuModule = require('../core/menu_module.js').MenuModule;
var ViewController = require('../core/view_controller.js').ViewController;
var async = require('async');
var assert = require('assert');
var _ = require('lodash');
var async = require('async');
var assert = require('assert');
var _ = require('lodash');
exports.getModule = FullScreenEditorModule;
@ -18,36 +19,95 @@ exports.moduleInfo = {
function FullScreenEditorModule(options) {
MenuModule.call(this, options);
var self = this;
var args = options.menuConfig.args;
var self = this;
this.menuConfig = options.menuConfig;
this.editorType = this.menuConfig.config.editorType;
/*
this.initSequence = function() {
var mciData = { };
async.waterfall(
[
function beforeDisplayArt(callback) {
self.beforeArt();
callback(null);
},
function displayHeader(callback) {
if(_.isString(args.art.header)) {
self.displayArtAsset(args.art.header, function hdrDisplayed(err, mciMap) {
function displayMainArt(callback) {
if(_.isString(self.menuConfig.art)) {
self.displayArtAsset(self.menuConfig.art, function frameDisplayed(err, artData) {
mciData.main = artData;
callback(err);
});
} else {
callback(null); // :TODO: should probably throw error... can't do much without this
}
},
function afterArtDisplayed(callback) {
self.mciReady(mciData);
callback(null);
}
],
function complete(err) {
}
);
};
this.mciReadyHandlerNetMail = function(mciData) {
var vc = self.addViewController('main', new ViewController( { client : self.client } ));
// :TODO: This can probably come from the normal mci configuration...
// additional mci stuff could be in config{} block. This should all be easily user-defined
var mciConfig = {
ET1 : {
width : 20,
text : 'Hello, World'
},
ET2 : {
width : 10,
text : 'This is a longer string',
},
MT3 : {
width : 80,
height : 17,
focus : true,
text : 'Ermergerd!\nHuzzah!'
}
};
var initialFocusedId = 3; // editor
async.waterfall(
[
function createViews(callback) {
vc.createViewsFromMCI(mciData.main.mciMap, function viewsCreated(err) {
callback(err);
});
},
function applyThemeCustomization(callback) {
console.log('applyThemeCustomization...')
// :TODO: menuUtil.applyThemeCustomization() ...
// this should update local hard coded mci stuff for example to change colors, widths, blah blah
callback(null);
},
function displayBody(callback) {
function applyViewConfiguration(callback) {
console.log('applyViewConfiguration...')
vc.applyViewConfig( { mci : mciConfig }, function configApplied(err, info) {
callback(err);
});
},
function displayFooter(callback) {
function drawAllViews(callback) {
vc.redrawAll(initialFocusedId);
callback(null);
},
function setInitialFocus(callback) {
vc.switchFocus(initialFocusedId); // editor
}
]
);
};
*/
}
require('util').inherits(FullScreenEditorModule, MenuModule);
@ -56,3 +116,7 @@ FullScreenEditorModule.prototype.enter = function(client) {
FullScreenEditorModule.super_.prototype.enter.call(this, client);
};
FullScreenEditorModule.prototype.mciReady = function(mciData) {
this['mciReadyHandler' + _.capitalize(this.editorType)](mciData);
};

View File

@ -432,14 +432,10 @@
},
"demoFullScreenEditor" : {
"module" : "fse",
"art" : "demo_fse.ans",
"art" : "demo_fse_local_user.ans",
"options" : { "cls" : true },
"args" : {
"art" : {
"header" : "MSGHDR",
"body" : "MSGBODY",
"footer" : "MSGFTR"
}
"config" : {
"editorType" : "netMail"
}
}