daandemeyer / rpms / systemd

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