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);
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.emit('action', 'accept');
delete this.submitData;
@ -29,16 +30,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;

View File

@ -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 !== undefined) {
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 (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.subject, this.message.subject);

View File

@ -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(),

View File

@ -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;
};