Skip to content

Commit

Permalink
feature #25301 [Console] Add box style table (maidmaid)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Console] Add box style table

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | /
| License       | MIT
| Doc PR        | /

> Box-drawing characters, also known as line-drawing characters, are a form of semigraphics widely used in text user interfaces to draw various geometric frames and boxes. https://en.wikipedia.org/wiki/Box-drawing_character

Box-drawing characters are done for the `TableStyle`; use them!

Result:

![screenshot from 2017-12-04 17-09-56](https://user-images.githubusercontent.com/4578773/33540267-0e4052fe-d916-11e7-8401-eb3be59e8025.png)

Commits
-------

360a984 Add box style table
  • Loading branch information
fabpot committed Dec 11, 2017
2 parents 721d370 + 360a984 commit 8a12eb3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Symfony/Component/Console/Helper/Table.php
Expand Up @@ -637,11 +637,18 @@ private static function initStyles()
->setCellHeaderFormat('%s')
;

$box = (new TableStyle())
->setHorizontalBorderChar('─')
->setVerticalBorderChar('│')
->setCrossingChar('┼')
;

return array(
'default' => new TableStyle(),
'borderless' => $borderless,
'compact' => $compact,
'symfony-style-guide' => $styleGuide,
'box' => $box,
);
}

Expand Down
16 changes: 16 additions & 0 deletions src/Symfony/Component/Console/Tests/Helper/TableTest.php
Expand Up @@ -136,6 +136,22 @@ public function renderProvider()
80-902734-1-6 And Then There Were None Agatha Christie
=============== ========================== ==================
TABLE
),
array(
array('ISBN', 'Title', 'Author'),
$books,
'box',
<<<'TABLE'
┼───────────────┼──────────────────────────┼──────────────────┼
│ ISBN │ Title │ Author │
┼───────────────┼──────────────────────────┼──────────────────┼
│ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │
│ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens │
│ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien │
│ 80-902734-1-6 │ And Then There Were None │ Agatha Christie │
┼───────────────┼──────────────────────────┼──────────────────┼
TABLE
),
array(
Expand Down

0 comments on commit 8a12eb3

Please sign in to comment.