* Fix justification 'right' vs 'left': They were flipped (durp!). Right aligned is now really that, etc. You may need to update your theme.hjson/similar!

This commit is contained in:
Bryan Ashby 2018-01-15 16:08:35 -07:00
parent ac1433e84b
commit a8d5e84779
5 changed files with 23 additions and 25 deletions

View File

@ -722,15 +722,15 @@
}
SM4: {
width: 14
justify: right
justify: left
}
SM5: {
width: 14
justify: right
justify: left
}
SM6: {
width: 14
justify: right
justify: left
}
BT7: {
focusTextStyle: first lower
@ -748,15 +748,15 @@
}
SM3: {
width: 14
justify: right
justify: left
}
SM4: {
width: 14
justify: right
justify: left
}
SM5: {
width: 14
justify: right
justify: left
}
ET6: {
width: 26
@ -826,7 +826,7 @@
mci: {
SM1: {
width: 14
justify: right
justify: left
focusTextStyle: first lower
}

View File

@ -122,10 +122,10 @@ function quote(s) {
function getPadAlign(align) {
return {
'<' : 'right',
'>' : 'left',
'<' : 'left',
'>' : 'right',
'^' : 'center',
}[align] || '<';
}[align] || '>';
}
function formatString(value, tokens) {

View File

@ -135,23 +135,21 @@ function stylizeString(s, style) {
return s;
}
// Based on http://www.webtoolkit.info/
// :TODO: Look into lodash padLeft, padRight, etc.
function pad(s, len, padChar, dir, stringSGR, padSGR, useRenderLen) {
len = miscUtil.valueWithDefault(len, 0);
padChar = miscUtil.valueWithDefault(padChar, ' ');
dir = miscUtil.valueWithDefault(dir, 'right');
stringSGR = miscUtil.valueWithDefault(stringSGR, '');
padSGR = miscUtil.valueWithDefault(padSGR, '');
useRenderLen = miscUtil.valueWithDefault(useRenderLen, true);
function pad(s, len, padChar, justify, stringSGR, padSGR, useRenderLen) {
len = len || 0;
padChar = padChar || ' ';
justify = justify || 'left';
stringSGR = stringSGR || '';
padSGR = padSGR || '';
useRenderLen = _.isUndefined(useRenderLen) ? true : useRenderLen;
const renderLen = useRenderLen ? renderStringLength(s) : s.length;
const padlen = len >= renderLen ? len - renderLen : 0;
switch(dir) {
switch(justify) {
case 'L' :
case 'left' :
s = padSGR + new Array(padlen).join(padChar) + stringSGR + s;
s = `${stringSGR}${s}${padSGR}${Array(padlen).join(padChar)}`;
break;
case 'C' :
@ -160,13 +158,13 @@ function pad(s, len, padChar, dir, stringSGR, padSGR, useRenderLen) {
{
const right = Math.ceil(padlen / 2);
const left = padlen - right;
s = padSGR + new Array(left + 1).join(padChar) + stringSGR + s + padSGR + new Array(right + 1).join(padChar);
s = `${padSGR}${Array(left + 1).join(padChar)}${stringSGR}${s}${padSGR}${Array(right + 1).join(padChar)}`;
}
break;
case 'R' :
case 'right' :
s = stringSGR + s + padSGR + new Array(padlen).join(padChar);
s = `${padSGR}${Array(padlen).join(padChar)}${stringSGR}${s}`;
break;
default : break;

View File

@ -32,7 +32,7 @@ function TextView(options) {
}
this.fillChar = miscUtil.valueWithDefault(options.fillChar, ' ').substr(0, 1);
this.justify = options.justify || 'right';
this.justify = options.justify || 'left';
this.resizable = miscUtil.valueWithDefault(options.resizable, true);
this.horizScroll = miscUtil.valueWithDefault(options.horizScroll, true);

View File

@ -14,7 +14,7 @@ exports.VerticalMenuView = VerticalMenuView;
function VerticalMenuView(options) {
options.cursor = options.cursor || 'hide';
options.justify = options.justify || 'right'; // :TODO: default to center
options.justify = options.justify || 'left';
MenuView.call(this, options);