]> git.ipfire.org Git - thirdparty/systemd.git/commit
format-table: add new string cell type that accepts ANSI sequences
authorLennart Poettering <lennart@poettering.net>
Thu, 15 Jan 2026 07:51:05 +0000 (08:51 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Jan 2026 20:32:49 +0000 (21:32 +0100)
commitf42dc5ea18e920c70a8571309bfd66757f5e01cb
tree0ce00ef25bae9c744850d8146650c427b43868c1
parentadcc87f802f0607e8bbf0b53693279d2743d3016
format-table: add new string cell type that accepts ANSI sequences

For various usecases it's useful that we can embed ANSI sequences in
cells of tables. For example, I hope we can eventually switch "systemctl
status" output to use the table formatter, and multiple of its fields
contain ANSI sequences (since they pack multiple different pieces
information into the same field, and highlight parts of it to
communicate relevance of distinct parts).

Add a distinct cell type for this, which gets special processing when we
output to a terminal that doesn't support ANSI sequences, and to JSON:
we strip the sequences.
src/shared/format-table.c
src/shared/format-table.h
src/test/test-format-table.c