Skip to content

Commit

Permalink
Use forced width attribution as fallback only to avoid scrappiong man…
Browse files Browse the repository at this point in the history
…ual widths
  • Loading branch information
schlessera committed Aug 22, 2018
1 parent 766653b commit 554b262
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/cli/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function display() {
* @return array
*/
public function getDisplayLines() {
$this->_renderer->setWidths($this->_width);
$this->_renderer->setWidths($this->_width, $fallback = true);
$border = $this->_renderer->border();

$out = array();
Expand Down
11 changes: 9 additions & 2 deletions lib/cli/table/Ascii.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ class Ascii extends Renderer {
/**
* Set the widths of each column in the table.
*
* @param array $widths The widths of the columns.
* @param array $widths The widths of the columns.
* @param bool $fallback Whether to use these values as fallback only.
*/
public function setWidths(array $widths) {
public function setWidths(array $widths, $fallback = false) {
if ($fallback) {
foreach ( $this->_widths as $index => $value ) {
$widths[$index] = $value;
}
}
$this->_widths = $widths;

if ( is_null( $this->_constraintWidth ) ) {
$this->_constraintWidth = (int) Shell::columns();
Expand Down
10 changes: 8 additions & 2 deletions lib/cli/table/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ public function __construct(array $widths = array()) {
/**
* Set the widths of each column in the table.
*
* @param array $widths The widths of the columns.
* @param array $widths The widths of the columns.
* @param bool $fallback Whether to use these values as fallback only.
*/
public function setWidths(array $widths) {
public function setWidths(array $widths, $fallback = false) {
if ($fallback) {
foreach ( $this->_widths as $index => $value ) {
$widths[$index] = $value;
}
}
$this->_widths = $widths;
}

Expand Down

0 comments on commit 554b262

Please sign in to comment.