]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic: add minimalistic table formatter
authorLennart Poettering <lennart@poettering.net>
Wed, 11 Apr 2018 18:03:39 +0000 (20:03 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 18 Apr 2018 10:51:15 +0000 (12:51 +0200)
commit1960e73611af42b8c0032d0fa8612931c80c3295
tree730a7adc9a73f295182d4a15bd76c8ed61e97acd
parenta89e30ecb4c299e9b5df0d4afea9ecaeb4686d96
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]