-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Table width does not take paddings into account / lacks cell wrapping #22156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
The latter 2 define the total table width, and can pre-calculate proper column widths. |
chalasr
pushed a commit
that referenced
this issue
Sep 4, 2018
This PR was squashed before being merged into the 4.2-dev branch (closes #22225). Discussion ---------- [Console] Support formatted text cutting | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes/no | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> allows cutting a formatted text to a certain width. Actually needed if we want to support max. column widths in tables (see #22156) ```php $text = 'pre <error>foo bar baz</error> post'; dump('BEFORE'); $output->writeln(wordwrap($output->getFormatter()->format($text), 3, "\n", true), OutputInterface::OUTPUT_RAW); dump('AFTER'); $output->writeln($output->getFormatter()->format($text, 3), OutputInterface::OUTPUT_RAW); ```  Commits ------- 09f8ad9 [Console] Support formatted text cutting
chalasr
pushed a commit
that referenced
this issue
Sep 11, 2018
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 | symfony/symfony-docs#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(); ```  Commits ------- 175f68f [Console] Support max column width in Table
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Given
It renders
For the min-width example i expected a perfectly fitting table :)
The default-width example works as documented, and
setColumnWidth
wont help, because that's actuallysetMinColumnWidth
(also documented i believe :))Imo. we're missing a
setMaxColumnWidth
or something to control text wrapping. Im not sure we should ever exceed the max. (terminal) width unless we cant wrap any further of course.Any thoughts?
The text was updated successfully, but these errors were encountered: