From 42ddabd875ebfaae8e85cf7d7f73135198380246 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Wed, 2 Sep 2015 23:11:17 -0600 Subject: [PATCH] * Minor work on post view FSE / related --- core/fse.js | 43 +++++++++++++++++++++--------- core/menu_util.js | 8 ++++++ core/multi_line_edit_text_view.js | 29 +++++++++++++++++++- core/text_view.js | 5 ++++ core/view_controller.js | 2 +- mods/art/msg_area_view_header.ans | Bin 581 -> 624 bytes mods/menu.json | 43 +++++++++++++----------------- 7 files changed, 91 insertions(+), 39 deletions(-) diff --git a/core/fse.js b/core/fse.js index 8dc5aa3a..621560bc 100644 --- a/core/fse.js +++ b/core/fse.js @@ -346,10 +346,10 @@ function FullScreenEditorModule(options) { }, function setInitialData(callback) { - switch(self.editorMode) { + switch(self.editorMode) { case 'view' : if(self.message) { - self.initHeaderFromMessage(); + self.initHeaderViewMode(); var bodyMessageView = self.viewControllers.body.getView(1); if(bodyMessageView && _.has(self, 'message.message')) { @@ -426,21 +426,38 @@ function FullScreenEditorModule(options) { } }; - this.initHeaderFromMessage = function() { + this.initHeaderViewMode = function() { assert(_.isObject(self.message)); - var fromView = self.viewControllers.header.getView(1); // TL - var toView = self.viewControllers.header.getView(2); // TL - var subjView = self.viewControllers.header.getView(3); // TL - var tsView = self.viewControllers.header.getView(5); // TL - - fromView.setText(self.message.fromUserName); - toView.setText(self.message.toUserName); - subjView.setText(self.message.subject); - - tsView.setText(moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat())); + function setHeaderText(id, text) { + var v = self.viewControllers.header.getView(id); + if(v) { + v.setText(text); + } + } + /* TL1 - From + TL2 - To + TL3 - Subject + + TL5 - Date/Time (TODO: format) + TL6 - Message number + TL7 - Mesage total (in area) + TL8 - View Count + TL9 - Hash tags + TL10 - Message ID + TL11 - Reply to message ID*/ + setHeaderText(1, self.message.fromUserName); + setHeaderText(2, self.message.toUserName); + setHeaderText(3, self.message.subject); + setHeaderText(5, moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat())); + setHeaderText(6, '1'); // :TODO: Message number + setHeaderText(7, '100'); // :TODO: Message total + setHeaderText(8, self.message.viewCount); + setHeaderText(9, 'TODO hash tags'); + setHeaderText(10, self.message.messageId); + setHeaderText(11, self.message.replyToMessageId); }; this.displayHelp = function() { diff --git a/core/menu_util.js b/core/menu_util.js index 0f9159aa..3c9363be 100644 --- a/core/menu_util.js +++ b/core/menu_util.js @@ -145,12 +145,20 @@ function getFormConfigByIDAndMap(menuConfig, formId, mciMap, cb) { Log.trace( { mciKey : mciReqKey }, 'Looking for MCI configuration key'); + // + // Exact, explicit match? + // if(_.isObject(formForId[mciReqKey])) { + Log.trace( { mciKey : mciReqKey }, 'Using exact configuration key match'); cb(null, formForId[mciReqKey]); return; } + // + // Generic match + // if(_.has(formForId, 'mci') || _.has(formForId, 'submit')) { + Log.trace('Using generic configuration'); cb(null, formForId); return; } diff --git a/core/multi_line_edit_text_view.js b/core/multi_line_edit_text_view.js index b0590882..c00556fe 100644 --- a/core/multi_line_edit_text_view.js +++ b/core/multi_line_edit_text_view.js @@ -124,6 +124,14 @@ function MultiLineEditTextView(options) { }[sgrFor] || self.getSGR(); }; + this.isEditMode = function() { + return 'edit' === self.mode; + }; + + this.isPreviewMode = function() { + return 'preview' === self.mode; + }; + // :TODO: Most of the calls to this could be avoided via incrementRow(), decrementRow() that keeps track or such this.getTextLinesIndex = function(row) { if(!_.isNumber(row)) { @@ -1050,6 +1058,10 @@ MultiLineEditTextView.prototype.getData = function() { }; MultiLineEditTextView.prototype.setPropertyValue = function(propName, value) { + switch(propName) { + case 'mode' : this.mode = value; break; + } + MultiLineEditTextView.super_.prototype.setPropertyValue.call(this, propName, value); }; @@ -1064,6 +1076,16 @@ var HANDLED_SPECIAL_KEYS = [ 'delete line', ]; +/* +var EDIT_MODE_KEYS = [ + 'line feed', 'insert', 'tab', 'backspace', 'del', 'delete line' +]; +*/ + +var PREVIEW_MODE_KEYS = [ + 'up', 'down', 'page up', 'page down' +]; + MultiLineEditTextView.prototype.onKeyPress = function(ch, key) { var self = this; var handled; @@ -1071,13 +1093,18 @@ MultiLineEditTextView.prototype.onKeyPress = function(ch, key) { if(key) { HANDLED_SPECIAL_KEYS.forEach(function aKey(specialKey) { if(self.isKeyMapped(specialKey, key.name)) { + + if(self.isPreviewMode() && -1 === PREVIEW_MODE_KEYS.indexOf(specialKey)) { + return; + } + self[_.camelCase('keyPress ' + specialKey)](); handled = true; } }); } - if(ch && strUtil.isPrintable(ch)) { + if(self.isEditMode() && ch && strUtil.isPrintable(ch)) { this.keyPressCharacter(ch); } diff --git a/core/text_view.js b/core/text_view.js index 861f2cb3..bea8570c 100644 --- a/core/text_view.js +++ b/core/text_view.js @@ -127,9 +127,14 @@ TextView.prototype.setText = function(text) { this.text = strUtil.stylizeString(this.text, this.hasFocus ? this.focusTextStyle : this.textStyle); + /* if(this.resizable) { this.dimens.width = this.text.length + widthDelta; } + */ + if(this.autoScale.width) { + this.dimens.width = this.text.length + widthDelta; + } this.redraw(); }; diff --git a/core/view_controller.js b/core/view_controller.js index 40b1c349..5e1f4622 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -232,7 +232,7 @@ function ViewController(options) { return; } - var mciConf = config.mci[mci]; + var mciConf = config.mci[mci]; self.setViewPropertiesFromMCIConf(view, mciConf); diff --git a/mods/art/msg_area_view_header.ans b/mods/art/msg_area_view_header.ans index 75cc9af4b3b708c55fa549c532655f823df42b8b..ef755c9c3c6d916a9e2920cbe9f0d2d427bf239e 100644 GIT binary patch delta 63 zcmX@g@_}VT8l$eUnX_MMu7Y&5p|!C=t`(4BkgFQvV+Iva&<6=907cBDqb(Xk+XEPp|!C=ZVfM&_T+_(-jiQ3CNLhE?9HSK0MFP9CIA2c diff --git a/mods/menu.json b/mods/menu.json index 7c748c4e..b92621b0 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -372,29 +372,23 @@ }, "form" : { "0" : { - "TLTLTLTL" : { - "mci" : { - "TL1" : { - "width" : 36 - }, - "TL2" : { - "width" : 36 - }, - "TL3" : { - "width" : 65 - }, - "TL5" : { - "width" : 19 - }, - "MA5" : { - "width" : 19, - "textOverflow" : "..." - } - /*, - "TL4" : { - "width" : 19, - "textOverflow" : "..." - }*/ + "mci" : { + "TL1" : { + "width" : 36 + }, + "TL2" : { + "width" : 36 + }, + "TL3" : { + "width" : 39, + "textOverflow" : "..." + }, + "TL5" : { + "width" : 19 + }, + "MA5" : { + "width" : 19, + "textOverflow" : "..." } } }, @@ -403,7 +397,8 @@ "mci" : { "MT1" : { "width" : 79, - "height" : 17 + "height" : 17, + "mode" : "preview" } }, "submit" : {