Skip to content

Commit

Permalink
Fix the ASCII table rendering for data with colored strings
Browse files Browse the repository at this point in the history
The colored output works via control characters that are part of the
strings that are put in the columns of the table. This resulted in an
incorrect column length computation as the `color_codes` feature is
required to correctly support terminal color codes.
I decided to additionally enable `wide_characters` support in case we
ever start using (or are already using?) wide characters [0] in the
data/output (e.g., emojis). That feature only requires an additional
dependency on `unicode-width` that is already in `Cargo.lock`.

Colors are, e.g., used in the output of "butido db submit $SUBMIT".

[0]: https://en.wikipedia.org/wiki/Wide_character

Signed-off-by: Michael Weiss <michael.weiss@eviden.com>
  • Loading branch information
primeos-work committed Jul 3, 2024
1 parent cbfc0b6 commit c6a58ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ maintenance = { status = "passively-maintained" }
[dependencies]
anyhow = "1"
aquamarine = "0.5"
ascii_table = "4"
ascii_table = { version = "4", features = ["color_codes", "wide_characters"] }
bytesize = "1"
chrono = "0.4"
clap = { version = "4", features = ["cargo"] }
Expand Down

0 comments on commit c6a58ac

Please sign in to comment.