From b067845242d50ae240ee3a6e8e42dfb2fbf327e4 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 31 Mar 2015 00:37:32 -0700 Subject: [PATCH] readme. comments. temporary workaround for non-autoPadding list-table. --- README.md | 36 ++++++++++++++++++------------------ lib/widget.js | 10 ++++++++++ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 65e5e76..70ca158 100644 --- a/README.md +++ b/README.md @@ -1068,22 +1068,22 @@ A stylized table of text elements. - inherits all from Box. - __setRows/setData(rows)__ - set rows in table. array of arrays of strings. - ``` - table.setData([ - [ 'Animals', 'Foods' ], - [ 'Elephant', 'Apple' ], - [ 'Bird', 'Orange' ] - ]); - ``` +``` js + table.setData([ + [ 'Animals', 'Foods' ], + [ 'Elephant', 'Apple' ], + [ 'Bird', 'Orange' ] + ]); +``` -#### ListTable (from Box) +#### ListTable (from List) A stylized table of text elements with a list. ##### Options: -- inherits all from Box. +- inherits all from List. - __rows/data__ - array of array of strings representing rows. - __pad__ - spaces to attempt to pad on the sides of each cell. `2` by default: one space on each side. @@ -1092,23 +1092,23 @@ A stylized table of text elements with a list. ##### Properties: -- inherits all from Box. +- inherits all from List. ##### Events: -- inherits all from Box. +- inherits all from List. ##### Methods: - inherits all from Box. - __setRows/setData(rows)__ - set rows in table. array of arrays of strings. - ``` - table.setData([ - [ 'Animals', 'Foods' ], - [ 'Elephant', 'Apple' ], - [ 'Bird', 'Orange' ] - ]); - ``` +``` js + table.setData([ + [ 'Animals', 'Foods' ], + [ 'Elephant', 'Apple' ], + [ 'Bird', 'Orange' ] + ]); +``` #### Terminal (from Box) diff --git a/lib/widget.js b/lib/widget.js index c9e7fc8..00da132 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -3272,6 +3272,15 @@ Element.prototype._getShrinkBox = function(xi, xl, yi, yl, get) { xl = mxl; if (!this.screen.autoPadding) { xl += this.padding.left + this.padding.right; + // XXX Temporary workaround until we decide to make autoPadding default. + // See widget-listtable.js for an example of why this is necessary. + // XXX Maybe just to this for all this being that this would affect + // width shrunken normal shrunken lists as well. + // if (this._isList) { + if (this.type === 'list-table') { + xl -= this.padding.left + this.padding.right; + xl += this.iright; + } } else { //xl += this.padding.right; xl += this.iright; @@ -4659,6 +4668,7 @@ List.prototype.appendItem = function(item) { } // if (this.shrink) { + // XXX NOTE: Maybe just do this on all shrinkage once autoPadding is default? if (this.shrink && this.options.normalShrink) { delete options.right; options.width = 'shrink';