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

#5 in #tabular

Download history 1/week @ 2024-02-18 17/week @ 2024-02-25 6/week @ 2024-03-03 8/week @ 2024-03-10 1/week @ 2024-03-17 18/week @ 2024-03-31 124/week @ 2024-04-14 6/week @ 2024-04-21

148 downloads per month
Used in saturn-cli

BSD-3-Clause

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

docs.rs has it all.

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–6MB
~22K SLoC