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 75cc9af4..ef755c9c 100644 Binary files a/mods/art/msg_area_view_header.ans and b/mods/art/msg_area_view_header.ans differ 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" : {