chiark / gitweb /
basic: add minimalistic table formatter
authorLennart Poettering <lennart@poettering.net>
Wed, 11 Apr 2018 18:03:39 +0000 (20:03 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
commitb616ac0d2b6b6e27e41646f8e6c9d62a1567141c
tree0652a00d95eb74da6787b399a044f05276637a8a
parentff3669adbfbfff7f8a7c95cd60f27e7ac5142ee7
basic: add minimalistic table formatter

We have plenty of code in our codebase that outputs tables to the
console, and all is homegrown and awful. Let's replace it with a generic
implementation that can do automatically what the old implementations
did manually.

Features:

1. Ellipsation (for fields overly long) and alignment (for
   fields overly short)

2. Sorting of rows

3. automatically copies formatting from the same cell in the row above

4. Heavy use of varargs to make putting together tables easy

5. can expand and compress tables, with weights

6. Has a minimal understanding of unicode wide characters in order to
   match unicode strings to character cell terminals.

7. Columns can be reordered and individually turned off.

8. pretty printing for various data types

And more.
src/basic/format-table.c [new file with mode: 0644]
src/basic/format-table.h [new file with mode: 0644]
src/basic/meson.build
src/test/meson.build
src/test/test-format-table.c [new file with mode: 0644]