From fea198551e8dbf9ad652f854af4d28c2162ab7b8 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Sun, 14 Aug 2016 18:40:39 +0200
Subject: [PATCH 1/2] Fix custom/menu crash
color_alpha did not make sure that the foreground property had the right
length
---
src/services/builder.cpp | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/services/builder.cpp b/src/services/builder.cpp
index c6f53546..86ab8e8c 100644
--- a/src/services/builder.cpp
+++ b/src/services/builder.cpp
@@ -389,22 +389,21 @@ void Builder::color_alpha(std::string alpha_)
{
auto alpha(alpha_);
std::string val = this->get_opts()->foreground;
- if (alpha.find("#") == 0) {
- if (alpha.size() == 3)
- this->color(alpha.substr(0, 3) + val.substr(val.size() - 6));
- else if (alpha.size() == 4)
- this->color(alpha + alpha.substr(1));
+ if (alpha.find("#") == std::string::npos ) {
+ alpha = "#" + alpha;
+ }
+
+ if (alpha.size() == 4) {
+ // If alpha looks like #123 then we treat as a color and ignore the fg color
+ this->color(alpha + alpha.substr(1));
return;
}
+
if (val.size() < 6 && val.size() > 2) {
val.append(val.substr(val.size() - 3));
- } else if (val.length() > 6) {
- val = "#" + val.substr(3);
}
- if (alpha.find("#") == std::string::npos) {
- alpha = "#"+ alpha;
- }
- this->color(alpha.substr(0, 3) + val.substr(val.size() - 6));
+
+ this->color((alpha.substr(0, 3) + val.substr(val.size() - 6)).substr(0, 9));
}
void Builder::color_close(bool force)
From ec9b2fb2c7b737487eb418818c43252652f7b46d Mon Sep 17 00:00:00 2001
From: patrick96
Date: Wed, 31 Aug 2016 18:34:27 +0200
Subject: [PATCH 2/2] Correct color assignment
As per request
---
src/services/builder.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/services/builder.cpp b/src/services/builder.cpp
index 86ab8e8c..fc72211b 100644
--- a/src/services/builder.cpp
+++ b/src/services/builder.cpp
@@ -394,8 +394,7 @@ void Builder::color_alpha(std::string alpha_)
}
if (alpha.size() == 4) {
- // If alpha looks like #123 then we treat as a color and ignore the fg color
- this->color(alpha + alpha.substr(1));
+ this->color(alpha);
return;
}