General bug fixes

This commit is contained in:
Nathan Byrd 2022-01-28 10:33:04 -06:00
parent 1bc9830202
commit 10c9ea9554
4 changed files with 19 additions and 65 deletions

View File

@ -21,7 +21,8 @@ function ButtonView(options) {
util.inherits(ButtonView, TextView); util.inherits(ButtonView, TextView);
ButtonView.prototype.onKeyPress = function(ch, key) { ButtonView.prototype.onKeyPress = function(ch, key) {
if(this.isKeyMapped('accept', key.name) || ' ' === ch) { let actionForKeyName = key ? key.name : ch;
if(this.isKeyMapped('accept', actionForKeyName) || ' ' === ch) {
this.submitData = 'accept'; this.submitData = 'accept';
this.emit('action', 'accept'); this.emit('action', 'accept');
delete this.submitData; delete this.submitData;
@ -29,16 +30,6 @@ ButtonView.prototype.onKeyPress = function(ch, key) {
ButtonView.super_.prototype.onKeyPress.call(this, 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() { ButtonView.prototype.getData = function() {
return this.submitData || null; return this.submitData || null;

View File

@ -791,10 +791,10 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
}); });
}, },
function prepareViewStates(callback) { function prepareViewStates(callback) {
var header = self.viewControllers.header; let from = self.viewControllers.header.getView(MciViewIds.header.from);
var from = header.getView(MciViewIds.header.from); if (from !== undefined) {
from.acceptsFocus = false; from.acceptsFocus = false;
//from.setText(self.client.user.username); }
// :TODO: make this a method // :TODO: make this a method
var body = self.viewControllers.body.getView(MciViewIds.body.message); 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 fromView = self.viewControllers.header.getView(MciViewIds.header.from);
const area = getMessageAreaByTag(self.messageAreaTag); const area = getMessageAreaByTag(self.messageAreaTag);
if(area && area.realNames) {
fromView.setText(self.client.user.properties[UserProps.RealName] || self.client.user.username); if(fromView !== undefined) {
} else { if(area && area.realNames) {
fromView.setText(self.client.user.username); fromView.setText(self.client.user.properties[UserProps.RealName] || self.client.user.username);
} else {
fromView.setText(self.client.user.username);
}
} }
if(self.replyToMessage) { if(self.replyToMessage) {
@ -914,7 +917,10 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
} }
initHeaderViewMode() { initHeaderViewMode() {
this.setHeaderText(MciViewIds.header.from, this.message.fromUserName); // Only set header text for from view if it is on the form
if (self.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.to, this.message.toUserName);
this.setHeaderText(MciViewIds.header.subject, this.message.subject); this.setHeaderText(MciViewIds.header.subject, this.message.subject);

View File

@ -44,49 +44,6 @@ function TextView(options) {
this.textMaskChar = options.textMaskChar; 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) { this.drawText = function(s) {
// //
@ -125,7 +82,7 @@ function TextView(options) {
this.client.term.write( this.client.term.write(
padStr( padStr(
textToDraw, textToDraw,
this.dimens.width + 1, this.dimens.width,
renderedFillChar, //this.fillChar, renderedFillChar, //this.fillChar,
this.justify, this.justify,
this.hasFocus ? this.getFocusSGR() : this.getSGR(), this.hasFocus ? this.getFocusSGR() : this.getSGR(),

View File

@ -154,7 +154,7 @@ View.prototype.setHeight = function(height) {
View.prototype.setWidth = function(width) { View.prototype.setWidth = function(width) {
width = parseInt(width) || 1; 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; this.dimens.width = width;
}; };