dcavalca / rpms / systemd

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