* Message view prev/next

* Message view up/down movement
* Some new experimental MCI codes
* Put cursor @ top of document in MLTEV preview mode
* Fix fse finishedLoading()
* Menus can have names, clients have current status
This commit is contained in:
Bryan Ashby 2015-09-07 00:12:01 -06:00
parent 1f3948d84c
commit 6517f50e0c
8 changed files with 64 additions and 90 deletions

View File

@ -78,9 +78,9 @@ function FullScreenEditorModule(options) {
// editorType : email | area // editorType : email | area
// editorMode : view | edit | quote // editorMode : view | edit | quote
// //
// extraArgs: // extraArgs - view mode
// messageAreaName // messageAreaName
// messageNumber / messageTotal // messageIndex / messageTotal
// //
// //
this.editorType = config.editorType; this.editorType = config.editorType;
@ -88,7 +88,7 @@ function FullScreenEditorModule(options) {
if(_.isObject(options.extraArgs)) { if(_.isObject(options.extraArgs)) {
this.messageAreaName = options.extraArgs.messageAreaName || Message.WellKnownAreaNames.Private; this.messageAreaName = options.extraArgs.messageAreaName || Message.WellKnownAreaNames.Private;
this.messageNumber = options.extraArgs.messageNumber || 0; this.messageIndex = options.extraArgs.messageIndex || 0;
this.messageTotal = options.extraArgs.messageTotal || 0; this.messageTotal = options.extraArgs.messageTotal || 0;
} }
@ -154,6 +154,7 @@ function FullScreenEditorModule(options) {
var bodyMessageView = self.viewControllers.body.getView(1); var bodyMessageView = self.viewControllers.body.getView(1);
if(bodyMessageView && _.has(self, 'message.message')) { if(bodyMessageView && _.has(self, 'message.message')) {
bodyMessageView.setText(self.message.message); bodyMessageView.setText(self.message.message);
//bodyMessageView.redraw();
} }
} }
@ -493,7 +494,7 @@ function FullScreenEditorModule(options) {
setHeaderText(MCICodeIds.ViewModeHeader.To, self.message.toUserName); setHeaderText(MCICodeIds.ViewModeHeader.To, self.message.toUserName);
setHeaderText(MCICodeIds.ViewModeHeader.Subject, self.message.subject); setHeaderText(MCICodeIds.ViewModeHeader.Subject, self.message.subject);
setHeaderText(MCICodeIds.ViewModeHeader.DateTime, moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat())); setHeaderText(MCICodeIds.ViewModeHeader.DateTime, moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat()));
setHeaderText(MCICodeIds.ViewModeHeader.MsgNum, self.messageNumber.toString()); setHeaderText(MCICodeIds.ViewModeHeader.MsgNum, (self.messageIndex + 1).toString());
setHeaderText(MCICodeIds.ViewModeHeader.MsgTotal, self.messageTotal.toString()); setHeaderText(MCICodeIds.ViewModeHeader.MsgTotal, self.messageTotal.toString());
setHeaderText(MCICodeIds.ViewModeHeader.ViewCount, self.message.viewCount); setHeaderText(MCICodeIds.ViewModeHeader.ViewCount, self.message.viewCount);
setHeaderText(MCICodeIds.ViewModeHeader.HashTags, 'TODO hash tags'); setHeaderText(MCICodeIds.ViewModeHeader.HashTags, 'TODO hash tags');

View File

@ -29,6 +29,8 @@ function MCIViewFactory(client) {
this.client = client; this.client = client;
} }
// :TODO: This portion should be made more generic so pipe code formatting can use it!
// e..g MCIPrint() -> enigmaToAnsi() ->
MCIViewFactory.prototype.getPredefinedViewLabel = function(code) { MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
var self = this; var self = this;
@ -38,6 +40,10 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
return area ? area.desc : ''; return area ? area.desc : '';
} }
function getCurrentMenuDescription() {
return _.has(self, 'client.currentMenuModule.menuConfig.desc') ? self.client.currentMenuModule.menuConfig.desc : '';
}
try { try {
return { return {
BN : Config.general.boardName, BN : Config.general.boardName,
@ -57,10 +63,13 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
UF : this.client.user.properties.affiliation, UF : this.client.user.properties.affiliation,
UT : this.client.user.properties.theme_id, UT : this.client.user.properties.theme_id,
MS : moment(this.client.user.properties.account_created).format(this.client.currentTheme.helpers.getDateFormat()), MS : moment(this.client.user.properties.account_created).format(this.client.currentTheme.helpers.getDateFormat()),
CS : this.client.currentStatus,
MD : getCurrentMenuDescription(),
MA : getMessageAreaDescription(), MA : getMessageAreaDescription(),
SH : this.client.term.termHeight.toString(), SH : this.client.term.termHeight.toString(),
SW : this.client.term.termWidth.toString(), SW : this.client.term.termWidth.toString(),

View File

@ -24,7 +24,7 @@ function MenuModule(options) {
this.menuConfig = options.menuConfig; this.menuConfig = options.menuConfig;
this.menuConfig.options = options.menuConfig.options || {}; this.menuConfig.options = options.menuConfig.options || {};
this.menuMethods = {}; // methods called from @method's this.menuMethods = {}; // methods called from @method's
this.initViewControllers(); this.initViewControllers();
this.initSequence = function() { this.initSequence = function() {
@ -138,16 +138,6 @@ function MenuModule(options) {
menuUtil.handleAction(self.client, null, self.menuConfig); menuUtil.handleAction(self.client, null, self.menuConfig);
} }
}; };
this.setMenuStatus = function(status) {
self.menuStatus = status;
};
if(_.isString(this.menuConfig.status)) {
self.setMenuStatus(self.menuConfig.status);
} else {
self.setMenuStatus('Browsing menus');
}
} }
require('util').inherits(MenuModule, PluginModule); require('util').inherits(MenuModule, PluginModule);
@ -158,6 +148,12 @@ MenuModule.prototype.enter = function(client) {
this.client = client; this.client = client;
assert(_.isObject(client)); assert(_.isObject(client));
if(_.isString(this.menuConfig.status)) {
this.client.currentStatus = this.menuConfig.status;
} else {
this.client.currentStatus = 'Browsing menus';
}
this.initSequence(); this.initSequence();
}; };

View File

@ -1049,8 +1049,14 @@ MultiLineEditTextView.prototype.setFocus = function(focused) {
MultiLineEditTextView.prototype.setText = function(text) { MultiLineEditTextView.prototype.setText = function(text) {
//text = require('fs').readFileSync('/home/nuskooler/Downloads/test_text.txt', { encoding : 'utf-8'}); //text = require('fs').readFileSync('/home/nuskooler/Downloads/test_text.txt', { encoding : 'utf-8'});
this.textLines = [ ];
this.insertRawText(text); this.insertRawText(text);
this.cursorEndOfDocument();
if(this.isEditMode()) {
this.cursorEndOfDocument();
} else if(this.isPreviewMode()) {
this.cursorStartOfDocument();
}
}; };
MultiLineEditTextView.prototype.getData = function() { MultiLineEditTextView.prototype.getData = function() {

Binary file not shown.

View File

@ -255,6 +255,7 @@
"messageArea" : { "messageArea" : {
"module" : "msg_area", "module" : "msg_area",
"art" : "MSGAREA", "art" : "MSGAREA",
"desc" : "Message Area",
"options" : { "cls" : true }, "options" : { "cls" : true },
"prompt" : "menuCommand", "prompt" : "menuCommand",
"submit" : [ "submit" : [
@ -439,13 +440,15 @@
"HM1" : { "HM1" : {
// (P)rev/(N)ext/Post/(R)eply/(Q)uit/(?)Help // (P)rev/(N)ext/Post/(R)eply/(Q)uit/(?)Help
// (#)Jump/(L)Index (msg list)/Last // (#)Jump/(L)Index (msg list)/Last
// :TODO: Continue, Save, Discard, Clear, Quote, Help
"items" : [ "Prev", "Next", "Reply", "Quit", "Help" ] "items" : [ "Prev", "Next", "Reply", "Quit", "Help" ]
} }
}, },
"submit" : { "submit" : {
"*" : [ "*" : [
{
"value" : { "1" : 0 },
"action" : "@method:prevMessage"
},
{ {
"value" : { "1" : 1 }, "value" : { "1" : 1 },
"action" : "@method:nextMessage" "action" : "@method:nextMessage"
@ -457,9 +460,15 @@
] ]
}, },
"actionKeys" : [ "actionKeys" : [
/*
{ {
"keys" : [ "escape" ], "keys" : [ "escape" ],
"action" : "@method:editModeEscPressed" // :TODO: fixme "action" : "@method:editModeEscPressed" // :TODO: fixme
},
*/
{
"keys" : [ "down arrow", "up arrow", "page up", "page down" ],
"action" : "@method:movementKeyPressed"
} }
] ]
} }

View File

@ -34,31 +34,33 @@ function AreaViewFSEModule(options) {
this.messageList = this.messageList || []; this.messageList = this.messageList || [];
this.messageIndex = this.messageIndex || 0; this.messageIndex = this.messageIndex || 0;
this.messageNumber = this.messageIndex + 1;
this.messageTotal = this.messageList.length; this.messageTotal = this.messageList.length;
//assert(_.isString(options.extraArgs.messageAreaName), 'messageAreaName must be supplied!');
//assert(options.extraArgs.messageId, 'messageId must be supplied!');
//assert(_.isString(options.extraArgs.messageUuid), 'messageUuid must be supplied!');
//this.messageUuid = options.extraArgs.messageUuid;
/*
this.loadMessage = function(uuid) {
var msg = new Message();
msg.load( { uuid : uuid, user : self.client.user }, function loaded(err) {
// :TODO: Hrm... if error...
self.setMessage(msg);
});
};
*/
this.menuMethods.nextMessage = function(formData, extraArgs) { this.menuMethods.nextMessage = function(formData, extraArgs) {
// :TODO: Next shouldn't even be a option if this is not the case:
if(self.messageIndex + 1 < self.messageList.length) { if(self.messageIndex + 1 < self.messageList.length) {
self.messageNumber++; // :TODO: should consolidate index + number? self.messageIndex++;
self.loadMessageByUuid(self.messageList[self.messageIndex++].messageUuid);
}
self.loadMessageByUuid(self.messageList[self.messageIndex].messageUuid);
}
};
this.menuMethods.prevMessage = function(formData, extraArgs) {
if(self.messageIndex > 0) {
self.messageIndex--;
self.loadMessageByUuid(self.messageList[self.messageIndex].messageUuid);
}
};
this.menuMethods.movementKeyPressed = function(formData, extraArgs) {
var bodyView = self.viewControllers.body.getView(1);
switch(formData.key.name) {
case 'down arrow' : bodyView.scrollDocumentUp(); break;
case 'up arrow' : bodyView.scrollDocumentDown(); break;
case 'page up' : bodyView.keyPressPageUp(); break;
case 'page down' : bodyView.keyPressPageDown(); break;
}
}; };
this.loadMessageByUuid = function(uuid) { this.loadMessageByUuid = function(uuid) {
@ -71,18 +73,8 @@ function AreaViewFSEModule(options) {
require('util').inherits(AreaViewFSEModule, FullScreenEditorModule); require('util').inherits(AreaViewFSEModule, FullScreenEditorModule);
/*
AreaViewFSEModule.prototype.enter = function(client) {
AreaViewFSEModule.super_.prototype.enter.call(this, client);
};
*/
AreaViewFSEModule.prototype.finishedLoading = function() { AreaViewFSEModule.prototype.finishedLoading = function() {
//AreaViewFSEModule.super_.prototype.finishedLoading.call(this);
if(this.messageList.length) { if(this.messageList.length) {
console.log('loading from index ' + this.messageIndex)
this.loadMessageByUuid(this.messageList[this.messageIndex].messageUuid); this.loadMessageByUuid(this.messageList[this.messageIndex].messageUuid);
} }
}; };

View File

@ -44,10 +44,8 @@ exports.moduleInfo = {
function MessageListModule(options) { function MessageListModule(options) {
MenuModule.call(this, options); MenuModule.call(this, options);
var self = this; var self = this;
var config = this.menuConfig.config;
var config = this.menuConfig.config;
// config.listType : public | private
this.listType = config.listType || 'public'; this.listType = config.listType || 'public';
@ -56,52 +54,16 @@ function MessageListModule(options) {
this.menuMethods = { this.menuMethods = {
selectMessage : function(formData, extraArgs) { selectMessage : function(formData, extraArgs) {
if(1 === formData.submitId) { if(1 === formData.submitId) {
/*
extraArgs.messageAreaName
extraArgs.messageList
extraArgs.messageListIndex
*/
var selected = self.messageList[formData.value.message];
//console.log(selected);
var modOpts = { var modOpts = {
name : 'messageAreaViewPost', // :TODO: should come from config? name : 'messageAreaViewPost', // :TODO: should come from config?
extraArgs : { extraArgs : {
messageAreaName : self.messageAreaName, messageAreaName : self.messageAreaName,
messageList : self.messageList, messageList : self.messageList,
messageListIndex : formData.value.message, messageIndex : formData.value.message,
} }
}; };
self.client.gotoMenuModule(modOpts); self.client.gotoMenuModule(modOpts);
/*
//
// Load full Message object
//
var msg = new Message();
msg.load( { uuid : selected.messageUuid, user : self.client.user }, function loaded(err) {
if(err) {
// :TODO: Now what?!
console.log(err)
} else {
var modOpts = {
// :TODO: get this name from config
name : 'messageAreaViewPost',
extraArgs : {
message : msg,
messageAreaName : self.messageAreaName,
messageNumber : formData.value.message + 1,
messageTotal : self.messageList.length,
},
};
self.client.gotoMenuModule(modOpts);
}
});
*/
} }
} }
}; };
@ -122,7 +84,6 @@ MessageListModule.prototype.enter = function(client) {
MessageListModule.prototype.mciReady = function(mciData, cb) { MessageListModule.prototype.mciReady = function(mciData, cb) {
var self = this; var self = this;
var vc = self.viewControllers.msgList = new ViewController( { client : self.client } ); var vc = self.viewControllers.msgList = new ViewController( { client : self.client } );
async.series( async.series(