Fix custom/menu crash

color_alpha did not make sure that the foreground property had the right
length
This commit is contained in:
patrick96 2016-08-14 18:40:39 +02:00 committed by Michael Carlberg
parent 2b1aa99f4c
commit fea198551e

View file

@ -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)