From b6d65a434b0ca8618a99282360f1886461d77c24 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 20 Mar 2017 09:06:16 -0400 Subject: [PATCH] util: Added helper function to properly manage table header color/underline --- src/util.cpp | 29 +++++++++++++++++++++++++++++ src/util.h | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 090ecf188..0aba1d928 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -303,3 +303,32 @@ const char* optionalBlankLine () } //////////////////////////////////////////////////////////////////////////////// +void setHeaderUnderline (Table& table) +{ + // If an alternating row color is specified, notify the table. + if (context.color ()) + { + Color alternate (context.config.get ("color.alternate")); + table.colorOdd (alternate); + table.intraColorOdd (alternate); + + if (context.config.getBoolean ("fontunderline")) + { + table.colorHeader (Color ("underline " + context.config.get ("color.label"))); + } + else + { + table.colorHeader (Color (context.config.get ("color.label"))); + table.underlineHeaders (); + } + } + else + { + if (context.config.getBoolean ("fontunderline")) + table.colorHeader (Color ("underline")); + else + table.underlineHeaders (); + } +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/util.h b/src/util.h index d12d80af8..d1257ea5d 100644 --- a/src/util.h +++ b/src/util.h @@ -37,7 +37,7 @@ #else #include #endif -#include +#include // util.cpp int confirm4 (const std::string&); @@ -63,6 +63,7 @@ const std::vector extractParents ( bool nontrivial (const std::string&); int strippedLength (const std::string&); const char* optionalBlankLine (); +void setHeaderUnderline (Table&); #endif ////////////////////////////////////////////////////////////////////////////////