diff --git a/core/button_view.js b/core/button_view.js index edb32e12..2aebf347 100644 --- a/core/button_view.js +++ b/core/button_view.js @@ -21,7 +21,7 @@ function ButtonView(options) { util.inherits(ButtonView, TextView); ButtonView.prototype.onKeyPress = function(ch, key) { - if(this.isKeyMapped('accept', key.name) || ' ' === ch) { + if(this.isKeyMapped('accept', (key ? key.name : ch)) || ' ' === ch) { this.submitData = 'accept'; this.emit('action', 'accept'); delete this.submitData; @@ -29,16 +29,6 @@ ButtonView.prototype.onKeyPress = function(ch, key) { ButtonView.super_.prototype.onKeyPress.call(this, ch, key); } }; -/* -ButtonView.prototype.onKeyPress = function(ch, key) { - // allow space = submit - if(' ' === ch) { - this.emit('action', 'accept'); - } - - ButtonView.super_.prototype.onKeyPress.call(this, ch, key); -}; -*/ ButtonView.prototype.getData = function() { return this.submitData || null; diff --git a/core/fse.js b/core/fse.js index 9fa0e97b..361bbeff 100644 --- a/core/fse.js +++ b/core/fse.js @@ -791,10 +791,10 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul }); }, function prepareViewStates(callback) { - var header = self.viewControllers.header; - var from = header.getView(MciViewIds.header.from); - from.acceptsFocus = false; - //from.setText(self.client.user.username); + let from = self.viewControllers.header.getView(MciViewIds.header.from); + if (from) { + from.acceptsFocus = false; + } // :TODO: make this a method var body = self.viewControllers.body.getView(MciViewIds.body.message); @@ -825,10 +825,13 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul { const fromView = self.viewControllers.header.getView(MciViewIds.header.from); const area = getMessageAreaByTag(self.messageAreaTag); - if(area && area.realNames) { - fromView.setText(self.client.user.properties[UserProps.RealName] || self.client.user.username); - } else { - fromView.setText(self.client.user.username); + + if(fromView !== undefined) { + if(area && area.realNames) { + fromView.setText(self.client.user.properties[UserProps.RealName] || self.client.user.username); + } else { + fromView.setText(self.client.user.username); + } } if(self.replyToMessage) { @@ -914,7 +917,10 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul } initHeaderViewMode() { - this.setHeaderText(MciViewIds.header.from, this.message.fromUserName); + // Only set header text for from view if it is on the form + if (this.viewControllers.header.getView(MciViewIds.header.from) !== undefined) { + this.setHeaderText(MciViewIds.header.from, this.message.fromUserName); + } this.setHeaderText(MciViewIds.header.to, this.message.toUserName); this.setHeaderText(MciViewIds.header.subject, this.message.subject); diff --git a/core/mask_edit_text_view.js b/core/mask_edit_text_view.js index abd04cb1..c9163273 100644 --- a/core/mask_edit_text_view.js +++ b/core/mask_edit_text_view.js @@ -132,7 +132,7 @@ MaskEditTextView.prototype.onKeyPress = function(ch, key) { this.text = this.text.substr(0, this.text.length - 1); this.clientBackspace(); } else { - while(this.patternArrayPos > 0) { + while(this.patternArrayPos >= 0) { if(_.isRegExp(this.patternArray[this.patternArrayPos])) { this.text = this.text.substr(0, this.text.length - 1); this.client.term.write(ansi.goto(this.position.row, this.getEndOfTextColumn() + 1)); diff --git a/core/text_view.js b/core/text_view.js index 2a5c93c5..cbecb54f 100644 --- a/core/text_view.js +++ b/core/text_view.js @@ -44,49 +44,6 @@ function TextView(options) { this.textMaskChar = options.textMaskChar; } - /* - this.drawText = function(s) { - - // - // |<- this.maxLength - // ABCDEFGHIJK - // |ABCDEFG| ^_ this.text.length - // ^-- this.dimens.width - // - let textToDraw = _.isString(this.textMaskChar) ? - new Array(s.length + 1).join(this.textMaskChar) : - stylizeString(s, this.hasFocus ? this.focusTextStyle : this.textStyle); - - if(textToDraw.length > this.dimens.width) { - if(this.hasFocus) { - if(this.horizScroll) { - textToDraw = textToDraw.substr(textToDraw.length - this.dimens.width, textToDraw.length); - } - } else { - if(textToDraw.length > this.dimens.width) { - if(this.textOverflow && - this.dimens.width > this.textOverflow.length && - textToDraw.length - this.textOverflow.length >= this.textOverflow.length) - { - textToDraw = textToDraw.substr(0, this.dimens.width - this.textOverflow.length) + this.textOverflow; - } else { - textToDraw = textToDraw.substr(0, this.dimens.width); - } - } - } - } - - this.client.term.write(padStr( - textToDraw, - this.dimens.width + 1, - this.fillChar, - this.justify, - this.hasFocus ? this.getFocusSGR() : this.getSGR(), - this.getStyleSGR(1) || this.getSGR() - ), false); - }; -*/ - this.drawText = function(s) { // @@ -125,7 +82,7 @@ function TextView(options) { this.client.term.write( padStr( textToDraw, - this.dimens.width + 1, + this.dimens.width, renderedFillChar, //this.fillChar, this.justify, this.hasFocus ? this.getFocusSGR() : this.getSGR(), diff --git a/core/view.js b/core/view.js index c31ccca1..fc62bb53 100644 --- a/core/view.js +++ b/core/view.js @@ -154,7 +154,7 @@ View.prototype.setHeight = function(height) { View.prototype.setWidth = function(width) { width = parseInt(width) || 1; - width = Math.min(width, this.client.term.termWidth); + width = Math.min(width, this.client.term.termWidth - this.position.col); this.dimens.width = width; };