From 6fdc3114f3e14fc0d33390ac4bde1c2f1a7d8209 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Mon, 14 Mar 2022 18:46:58 +0100
Subject: [PATCH] builder: Never enable over/underline without color
You cannot make polybar emit only the %{+o} tag without a color so that
codepath was unused.
---
include/components/builder.hpp | 6 ++----
src/components/builder.cpp | 30 ++++++------------------------
2 files changed, 8 insertions(+), 28 deletions(-)
diff --git a/include/components/builder.hpp b/include/components/builder.hpp
index 1efc0c5f..19a911f6 100644
--- a/include/components/builder.hpp
+++ b/include/components/builder.hpp
@@ -33,9 +33,9 @@ class builder {
void background_close();
void color(rgba color);
void color_close();
- void overline(const rgba& color = rgba{});
+ void overline(const rgba& color);
void overline_close();
- void underline(const rgba& color = rgba{});
+ void underline(const rgba& color);
void underline_close();
void control(tags::controltag tag);
void action(mousebtn index, string action);
@@ -49,9 +49,7 @@ class builder {
protected:
void append(const string& text);
- void overline_color(rgba color);
void overline_color_close();
- void underline_color(rgba color);
void underline_color_close();
void tag_open(tags::syntaxtag tag, const string& value);
diff --git a/src/components/builder.cpp b/src/components/builder.cpp
index fc85b110..54e0294e 100644
--- a/src/components/builder.cpp
+++ b/src/components/builder.cpp
@@ -245,15 +245,6 @@ void builder::color_close() {
tag_close(syntaxtag::F);
}
-/**
- * Insert tag to alter the current overline color
- */
-void builder::overline_color(rgba color) {
- auto hex = color_util::simplify_hex(color);
- tag_open(syntaxtag::o, hex);
- tag_open(attribute::OVERLINE);
-}
-
/**
* Close underline color tag
*/
@@ -261,15 +252,6 @@ void builder::overline_color_close() {
tag_close(syntaxtag::o);
}
-/**
- * Insert tag to alter the current underline color
- */
-void builder::underline_color(rgba color) {
- auto hex = color_util::simplify_hex(color);
- tag_open(syntaxtag::u, hex);
- tag_open(attribute::UNDERLINE);
-}
-
/**
* Close underline color tag
*/
@@ -278,12 +260,12 @@ void builder::underline_color_close() {
}
/**
- * Insert tag to enable the overline attribute
+ * Insert tag to enable the overline attribute with the given color
*/
void builder::overline(const rgba& color) {
if (color.has_color()) {
- overline_color(color);
- } else {
+ auto hex = color_util::simplify_hex(color);
+ tag_open(syntaxtag::o, hex);
tag_open(attribute::OVERLINE);
}
}
@@ -296,12 +278,12 @@ void builder::overline_close() {
}
/**
- * Insert tag to enable the underline attribute
+ * Insert tag to enable the underline attribute with the given color
*/
void builder::underline(const rgba& color) {
if (color.has_color()) {
- underline_color(color);
- } else {
+ auto hex = color_util::simplify_hex(color);
+ tag_open(syntaxtag::u, hex);
tag_open(attribute::UNDERLINE);
}
}