systemd/SOURCES/0132-format-table-always-underline-header-line.patch

42 lines
1.6 KiB
Diff
Raw Permalink Normal View History

2021-04-06 13:35:55 +00:00
From cb35bd029dedf39b7be4945d57176a5b1aa03da9 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 8 Nov 2018 21:39:28 +0100
Subject: [PATCH] format-table: always underline header line
(cherry picked from commit 30d98de00c68440ff4d77d851b4b3323c34027da)
Related: #1689832
---
src/basic/format-table.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/basic/format-table.c b/src/basic/format-table.c
index 809a4be284..3fcb97475c 100644
--- a/src/basic/format-table.c
+++ b/src/basic/format-table.c
@@ -1343,15 +1343,22 @@ int table_print(Table *t, FILE *f) {
field = buffer;
}
+ if (row == t->data) /* underline header line fully, including the column separator */
+ fputs(ansi_underline(), f);
+
if (j > 0)
fputc(' ', f); /* column separator */
- if (d->color && colors_enabled())
+ if (d->color && colors_enabled()) {
+ if (row == t->data) /* first undo header underliner */
+ fputs(ANSI_NORMAL, f);
+
fputs(d->color, f);
+ }
fputs(field, f);
- if (d->color && colors_enabled())
+ if (colors_enabled() && (d->color || row == t->data))
fputs(ANSI_NORMAL, f);
}