5 unstable releases
0.3.0 | Sep 20, 2023 |
---|---|
0.2.2 | Sep 16, 2023 |
0.2.1 | Jul 19, 2021 |
0.2.0 | Jun 30, 2021 |
0.1.0 | Jun 29, 2021 |
#11 in #tabular
45 downloads per month
Used in saturn-cli
21KB
408 lines
ttygrid: reactive layouts for terminal tables
ttygrid makes your tables into reactive layouts. You feed it your contents and the columns you want to show, and it will calculate what to show based on the length of text in the table column, and the "priority", an ascending number indicating display priority within the table.
The result is something like this with the demo source here. Padding is allocated for all columns so the tables are presented nicely and orderly.
ttygrid does not work with stream I/O. Terminal I/O only!. At this point, you must detect if you are a TTY before invoking ttygrid calls.
ttygrid uses crossterm underneath the hood to detect the width of the terminal as well as manage colors when they are desired.
Usage
Author
Erik Hollensbe github@hollensbe.org
lib.rs
:
ttygrid provides functionality for displaying table-ized text to users with appropriate padding and width management. With ttygrid, you merely need to feed it your data, some information about the precedence (called a "priority") of each column, and it will automatically determine what to show to the user based on the available display width. See crate::grid! for more information.
Here is a demo to see the results in action.
It is not intended for streaming (aka, not tty) situations. It probably only works on unix right now too.
The demo example
some basic capabilities and should be reviewed for understanding this library; as well as
learning the macros.
Much of this library relies on the macros, not the types directly. Please review those for the most comprehensive documentation.
Dependencies
~1–5.5MB
~22K SLoC