{"id":21383079,"url":"https://github.com/knaeckekami/barbecue","last_synced_at":"2025-07-13T13:31:51.440Z","repository":{"id":53607252,"uuid":"299068487","full_name":"knaeckeKami/barbecue","owner":"knaeckeKami","description":"Render text tables for CLI-based dart applications","archived":false,"fork":false,"pushed_at":"2023-12-30T23:08:06.000Z","size":129,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-01T23:14:46.334Z","etag":null,"topics":["cli","dart","picnic","table"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knaeckeKami.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-27T16:07:06.000Z","updated_at":"2023-12-01T14:40:43.000Z","dependencies_parsed_at":"2023-02-09T20:45:16.722Z","dependency_job_id":null,"html_url":"https://github.com/knaeckeKami/barbecue","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knaeckeKami%2Fbarbecue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knaeckeKami%2Fbarbecue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knaeckeKami%2Fbarbecue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knaeckeKami%2Fbarbecue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knaeckeKami","download_url":"https://codeload.github.com/knaeckeKami/barbecue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225886628,"owners_count":17539839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","dart","picnic","table"],"created_at":"2024-11-22T11:19:42.170Z","updated_at":"2024-11-22T11:19:43.366Z","avatar_url":"https://github.com/knaeckeKami.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# barbecue\n\n\n[![pub package](https://img.shields.io/pub/v/barbecue.svg?label=barbecue)](https://pub.dartlang.org/packages/barbecue)\n[![Build Status](https://github.com/knaeckeKami/barbecue/workflows/Build/badge.svg)](https://github.com/knaeckeKami/barbecue/actions)\n[![codecov](https://codecov.io/gh/knaeckeKami/barbecue/branch/master/graph/badge.svg)](https://codecov.io/gh/knaeckeKami/barbecue)\n\nRender text tables for CLI-based dart applications.\n\nPorted from Kotlin to Dart from Jake Wharton's [picnic](https://github.com/JakeWharton/picnic).\n\nFeatures:\n\n - Borders (with custom styling)\n - Padding\n - Styling on table- row- or cell-level\n - Text alignment (bottom/middle/top - left/middle/right)\n - Row and column spans\n - ANSI Colors and backgrounds! (see example)\n - LIMITED support for emojis and other wide characters\n \n## Examples\n\nSimple example:\n\n```dart\n\nprint(Table(\n      tableStyle: TableStyle(border: true),\n      header: TableSection(rows: [\n        Row(\n          cells: [\n            Cell(\"ID\"),\n            Cell(\"Name\"),\n            Cell(\"Role\"),\n          ],\n          cellStyle: CellStyle(borderBottom: true),\n        ),\n      ]),\n      body: TableSection(\n        cellStyle: CellStyle(paddingRight: 2),\n        rows: [\n          Row(cells: [\n            Cell(\"42\", style: CellStyle(alignment: TextAlignment.TopRight)),\n            Cell(\"John Doe\"),\n            Cell(\"Secret Agent\")\n          ]),\n          Row(cells: [\n            Cell(\"4711\"),\n            Cell(\"Leanna E. Distefano\"),\n            Cell(\"Customer Support\")\n          ]),\n          Row(cells: [Cell(\"1337\"), Cell(\"Patrice Miller\"), Cell(\"Accountant\")])\n        ],\n      )).render());\n```\n\nPrints:\n\n```\n┌─────────────────────────────────────────────┐\n│ID    Name                 Role              │\n├─────────────────────────────────────────────┤\n│  42  John Doe             Secret Agent      │\n│4711  Leanna E. Distefano  Customer Support  │\n│1337  Patrice Miller       Accountant        │\n└─────────────────────────────────────────────┘\n```\n\n### Text Align + Spans + ASCII style border\n\n```dart\n\nTable(\n    cellStyle: CellStyle(\n        borderBottom: true,\n        borderRight: true,\n        borderLeft: true,\n        borderTop: true,\n        alignment: TextAlignment.TopLeft),\n    body: TableSection(\n      rows: [\n        Row(\n          cells: [\n            Cell(\"Real Planets\",\n                rowSpan: 8,\n                style: CellStyle(alignment: TextAlignment.MiddleCenter)),\n            Cell(\"Mercury\")\n          ],\n        ),\n        Row(\n          cells: [Cell(\"Venus\")],\n        ),\n        Row(\n          cells: [Cell(\"Earth\")],\n        ),\n        Row(\n          cells: [Cell(\"Mars\")],\n        ),\n        Row(\n          cells: [Cell(\"Jupiter\")],\n        ),\n        Row(\n          cells: [Cell(\"Saturn\")],\n        ),\n        Row(\n          cells: [Cell(\"Uranus\")],\n        ),\n        Row(\n          cells: [Cell(\"Neptune\")],\n        ),\n        Row(\n          cells: [Cell(\"Very Fake Planets\", rowSpan: 1), Cell(\"Pluto\")],\n        ),\n      ],\n    ),\n  ).render(border: TextBorder.ASCII)\n\n```\n\nreturns\n\n```\n+-----------------+-------+\n|                 |Mercury|\n|                 +-------+\n|                 |Venus  |\n|                 +-------+\n|                 |Earth  |\n|                 +-------+\n|                 |Mars   |\n|  Real Planets   +-------+\n|                 |Jupiter|\n|                 +-------+\n|                 |Saturn |\n|                 +-------+\n|                 |Uranus |\n|                 +-------+\n|                 |Neptune|\n+-----------------+-------+\n|Very Fake Planets|Pluto  |\n+-----------------+-------+\n\n```\n\n### ANSI colors\n\n\n```dart\n  final strings = [\"look\", \"at\", \"all\", \"these\", \"colors\"];\n  var i = 0;\n  print(Table(\n    tableStyle: TableStyle(border: true),\n    body: TableSection(\n        cellStyle: CellStyle(\n          borderRight: true,\n        ),\n        rows: [\n          Row(\n            cells: [\n              for (final pen in [\n                AnsiPen()\n                  ..red(bold: true),\n                AnsiPen()\n                  ..green(bold: true),\n                AnsiPen()..blue(),\n                AnsiPen()\n                  ..black()\n                  ..white(bg: true),\n                AnsiPen()..xterm(190)\n              ])\n                Cell(pen(strings[i++]))\n            ],\n          ),\n        ]),\n  ).render());\n\n\n```\nprints \n\n![image](https://i.imgur.com/1HYQdbV.png)\n\n\n# Emojis and other wide characters\n\nBy default, the layout algorithm assumes a real monospaced font, where every character is the exact same\nwidth as other characters. Most modern \"Mono\" fonts don't work like that.\n\nSee for example this \"monospaced\" block:\n\n```\n😊😊😊\n123\n```\n\nIn a fully monospaced font, the first line with the emojis would be exactly as wide as the second line.\nChances are, that you see this block rendered like this (this depends on the font used):\n\n![emoji rendering](assets/emoji_glyph_render_1.png)\n\nText based table layouts don't work if some characters are wider than others.\nLuckily, most fonts used in terminals just render most emojis twice as wide as other characters:\nSomething like:\n\n```\n😊😊😊|\n123456|\n```\n\nWill likely render like that in your terminal:\n\n![emoji rendering](assets/emoji_glyph_render_2.png)\n\n\nWith the assumption that emojis are rendered twice as wide, we can build a valid text-table again.\nUnfortunately, this is not going to work with all fonts, and not with all characters.\n\nSome characters are rendered with a fractional width of a default character.\n\nSee for example bold unicode characters:\n\n```\n𝗛𝗲𝗮𝗱𝗲𝗿|\n123456|\n```\n\nFor emojis and other wide characters, you can use the experimental EmojiAwareLayout.\n\nExample:\n\n```dart\n  final table = Table(\n        body: TableSection(rows: [\n      Row(cells: [\n        Cell('🤡',\n            columnSpan: 4,\n            style: CellStyle(alignment: TextAlignment.MiddleCenter)),\n      ]),\n      Row(cells: [\n        Cell(\n          '1',\n        ),\n        Cell(\n          '2',\n        ),\n        Cell(\n          '3',\n        ),\n        Cell(\n          '4',\n        ),\n      ])\n    ]));\n  final tableString = table.render(layoutFactory: (cell) =\u003e EmojiAwareLayout(cell));\n```\n\nYour milage may wary. It is recommended not to use any unicode full-width or half-width characters\nwith barbecue, as there are many platform, font or even terminal specific differences in how\ntheir glyphs are rendered, and this breaks the monospace-assumption of this package.\n\nThere is no way of drawing text tables if the glyphs are rendered with fractional widths of 1.5x.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknaeckekami%2Fbarbecue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknaeckekami%2Fbarbecue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknaeckekami%2Fbarbecue/lists"}