* Lots of good progress with quote builder... still WIP, but nearly there

This commit is contained in:
Bryan Ashby 2015-09-16 22:31:09 -06:00
parent 20fb54422a
commit 6970e6e2ab
3 changed files with 82 additions and 8 deletions

View File

@ -568,10 +568,12 @@ function FullScreenEditorModule(options) {
//
// Clear body area
//
self.newQuoteBlock = true;
async.waterfall(
[
function clearAndDisplayArt(callback) {
console.log(self.header.height);
self.client.term.rawWrite(
ansi.goto(self.header.height + 1, 1) +
ansi.deleteLine(24 - self.header.height));
@ -692,9 +694,46 @@ function FullScreenEditorModule(options) {
self.displayQuoteBuilder();
},
appendQuoteEntry: function(formData, extraArgs) {
// :TODO: Dont' use magic # ID's here
// :TODO: Dont' use magic # ID's here
var quoteMsgView = self.viewControllers.quoteBuilder.getView(1);
if(self.newQuoteBlock) {
self.newQuoteBlock = false;
var dtFormat = self.client.currentTheme.helpers.getDateTimeFormat();
quoteMsgView.addText(
'On {0} {1} said...'.format(
moment(self.replyToMessage.modTimestamp).format(dtFormat),
self.replyToMessage.fromUserName)
);
}
var quoteText = self.viewControllers.quoteBuilder.getView(3).getItem(formData.value.quote);
self.viewControllers.quoteBuilder.getView(1).addText(quoteText);
quoteMsgView.addText(quoteText);
// :TODO: Menus need a setFocusIndex() call -- move down to next item here
},
quoteBuilderEscPressed : function(formData, extraArgs) {
// :TODO: fix magic #'s
var quoteMsgView = self.viewControllers.quoteBuilder.getView(1);
var msgView = self.viewControllers.body.getView(1);
//msgView.addText(_.trim(quoteMsgView.getData(), '\n'));
//msgView.addText(new Array(msgView.dimens.width - 1).join('-') + '\n');
msgView.addText(quoteMsgView.getData() + '\n');
quoteMsgView.setText('');
var footerName = self.getFooterName();
//self.redrawFooter( { clear : true, footerName : footerName }, function footerDisplayed(err) {
self.footerMode = 'editor';
self.switchFooter(function switched(err) {
self.viewControllers.quoteBuilder.setFocus(false);
self.viewControllers.body.redrawAll();
self.viewControllers[footerName].redrawAll();
self.viewControllers.body.switchFocus(1);
});
},
editModeMenuHelp : function(formData, extraArgs) {
self.viewControllers.footerEditorMenu.setFocus(false);

View File

@ -244,9 +244,34 @@ Message.prototype.persist = function(cb) {
);
};
Message.prototype.getQuoteLines = function(width) {
Message.prototype.getFTNQuotePrefix = function(source) {
source = source || 'fromUserName';
switch(source) {
case 'fromUserName' :
return this.fromUserName[0].toUpperCase() + this.fromUserName[1].toLowerCase();
case 'toUserName' :
return this.toUserName[0].toUpperCase() + this.toUserName[1].toLowerCase();
// :TODO: real names
}
};
Message.prototype.getQuoteLines = function(width, options) {
// :TODO: options.maxBlankLines = 1
options = options || {};
//
// Include FSC-0032 style quote prefixes?
//
// See http://ftsc.org/docs/fsc-0032.001
//
if(!_.isBoolean(options.includePrefix)) {
options.includePrefix = true;
}
var quoteLines = [];
var origLines = this.message
@ -259,7 +284,10 @@ Message.prototype.getQuoteLines = function(width) {
tabWidth : 4,
};
var quotePrefix = 'Nu> '; // :TODO: build FTN style quote prefix
var quotePrefix;
if(options.includePrefix) {
quotePrefix = ' ' + this.getFTNQuotePrefix(options.prefixSource || 'fromUserName') + '> ';
}
for(var i = 0; i < origLines.length; ++i) {
Array.prototype.push.apply(quoteLines, wordWrapText(quotePrefix + origLines[i], wrapOpts).wrapped);

View File

@ -471,7 +471,7 @@
"mci" : {
"MT1" : {
"width" : 79,
"height" : 12,
"height" : 14,
"mode" : "preview"
}
},
@ -621,7 +621,7 @@
mci: {
MT1: {
width: 79
height: 12
height: 14
argName: message
mode: edit
}
@ -685,6 +685,13 @@
}
]
}
actionKeys: [
{
keys: [ "escape" ]
action: @method:quoteBuilderEscPressed
}
]
}
}
}
@ -740,7 +747,7 @@
"mci" : {
MT1: {
width: 79
height: 12
height: 14
argName: message
mode: edit
}