This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Console/Tests
Robin Chalas 839dc2693a feature #28373 [Console] Support max column width in Table (ro0NL)
This PR was squashed before being merged into the 4.2-dev branch (closes #28373).

Discussion
----------

[Console] Support max column width in Table

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #22156, #27832
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/issues/10300

Continuation of #22225 to better preserve spaces (which preserves background colors), using `wordwrap` it caused some issues.

Also the wrapping was plain wrong by not taking the current line length into account.

While at it, it comes with `Table` integration :)

Given

```php
$table = new Table($output);
$table->setColumnMaxWidth(0, 2);
$table->setRow(0, ['pre <error>foo bar baz</error> post']);
$table->render();

$table = new Table($output);
$table->setColumnMaxWidth(0, 3);
$table->setRow(0, ['pre <error>foo bar baz</error> post']);
$table->render();

$table = new Table($output);
$table->setColumnMaxWidth(0, 4);
$table->setRow(0, ['pre <error>foo bar baz</error> post']);
$table->render();
```

![image](https://user-images.githubusercontent.com/1047696/45101516-f19b5880-b12b-11e8-825f-6a1d84f68f47.png)

Commits
-------

175f68f [Console] Support max column width in Table
2018-09-11 19:20:18 +02:00
..
Command Merge branch '3.4' into 4.0 2018-07-26 11:08:35 +02:00
CommandLoader [Console] Add a factory command loader for standalone application with lazy-loading needs 2017-07-15 10:43:17 +02:00
DependencyInjection Merge branch '3.4' into 4.0 2018-05-31 12:16:04 +02:00
Descriptor Merge branch '3.2' into 3.3 2017-07-03 11:12:02 +03:00
EventListener Merge branch '2.8' into 3.4 2018-07-26 11:06:28 +02:00
Fixtures Merge branch '4.0' into 4.1 2018-07-26 11:10:45 +02:00
Formatter [Console] Support max column width in Table 2018-09-11 19:20:06 +02:00
Helper feature #28373 [Console] Support max column width in Table (ro0NL) 2018-09-11 19:20:18 +02:00
Input Merge branch '4.0' into 4.1 2018-07-26 11:10:45 +02:00
Logger Merge branch '2.8' into 3.4 2018-07-26 11:06:28 +02:00
Output Merge branch '4.0' into 4.1 2018-07-26 11:10:45 +02:00
Style Merge branch '2.8' into 3.4 2018-07-26 11:06:28 +02:00
Tester Merge branch '4.0' into 4.1 2018-07-26 11:10:45 +02:00
ApplicationTest.php Improve support for anonymous classes 2018-08-21 14:03:16 +02:00
TerminalTest.php Allow terminal dimensions to be set to 0 (unbounded) 2017-04-11 16:41:42 +01:00