* 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: { SM4: {
width: 14 width: 14
justify: right justify: left
} }
SM5: { SM5: {
width: 14 width: 14
justify: right justify: left
} }
SM6: { SM6: {
width: 14 width: 14
justify: right justify: left
} }
BT7: { BT7: {
focusTextStyle: first lower focusTextStyle: first lower
@ -748,15 +748,15 @@
} }
SM3: { SM3: {
width: 14 width: 14
justify: right justify: left
} }
SM4: { SM4: {
width: 14 width: 14
justify: right justify: left
} }
SM5: { SM5: {
width: 14 width: 14
justify: right justify: left
} }
ET6: { ET6: {
width: 26 width: 26
@ -826,7 +826,7 @@
mci: { mci: {
SM1: { SM1: {
width: 14 width: 14
justify: right justify: left
focusTextStyle: first lower focusTextStyle: first lower
} }

View File

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

View File

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

View File

@ -32,7 +32,7 @@ function TextView(options) {
} }
this.fillChar = miscUtil.valueWithDefault(options.fillChar, ' ').substr(0, 1); 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.resizable = miscUtil.valueWithDefault(options.resizable, true);
this.horizScroll = miscUtil.valueWithDefault(options.horizScroll, true); this.horizScroll = miscUtil.valueWithDefault(options.horizScroll, true);

View File

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