mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-01 11:20:19 +02:00
Bug Fix - color
- Fixed bug that failed to upgrade from 16- to 256-color mode when a color like "black on rgb003" was parsed.
This commit is contained in:
parent
c090367eb8
commit
3abce22f0c
1 changed files with 16 additions and 22 deletions
|
@ -96,7 +96,8 @@ Color::Color (const std::string& spec)
|
||||||
: value (0)
|
: value (0)
|
||||||
{
|
{
|
||||||
// By converting underscores to spaces, we inherently support the old "on_red"
|
// By converting underscores to spaces, we inherently support the old "on_red"
|
||||||
// style of specifying background colors.
|
// style of specifying background colors. We consider underscores to be
|
||||||
|
// deprecated.
|
||||||
std::string modifiable_spec = spec;
|
std::string modifiable_spec = spec;
|
||||||
std::replace (modifiable_spec.begin (), modifiable_spec.end (), '_', ' ');
|
std::replace (modifiable_spec.begin (), modifiable_spec.end (), '_', ' ');
|
||||||
|
|
||||||
|
@ -112,24 +113,10 @@ Color::Color (const std::string& spec)
|
||||||
{
|
{
|
||||||
word = lowerCase (trim (*it));
|
word = lowerCase (trim (*it));
|
||||||
|
|
||||||
if (word == "bold")
|
if (word == "bold") value |= _COLOR_BOLD;
|
||||||
{
|
else if (word == "bright") value |= _COLOR_BRIGHT;
|
||||||
value |= _COLOR_BOLD;
|
else if (word == "underline") value |= _COLOR_UNDERLINE;
|
||||||
value &= ~_COLOR_256;
|
else if (word == "on") bg = true;
|
||||||
}
|
|
||||||
else if (word == "bright")
|
|
||||||
{
|
|
||||||
value |= _COLOR_BRIGHT;
|
|
||||||
value &= ~_COLOR_256;
|
|
||||||
}
|
|
||||||
else if (word == "underline")
|
|
||||||
{
|
|
||||||
value |= _COLOR_UNDERLINE;
|
|
||||||
}
|
|
||||||
else if (word == "on")
|
|
||||||
{
|
|
||||||
bg = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// X where X is one of black, red, blue ...
|
// X where X is one of black, red, blue ...
|
||||||
else if ((index = find (word)) != -1)
|
else if ((index = find (word)) != -1)
|
||||||
|
@ -154,6 +141,8 @@ Color::Color (const std::string& spec)
|
||||||
if (index < 0 || index > 23)
|
if (index < 0 || index > 23)
|
||||||
throw std::string ("The color '") + *it + "' is not recognized.";
|
throw std::string ("The color '") + *it + "' is not recognized.";
|
||||||
|
|
||||||
|
upgrade ();
|
||||||
|
|
||||||
if (bg)
|
if (bg)
|
||||||
{
|
{
|
||||||
value |= _COLOR_HASBG;
|
value |= _COLOR_HASBG;
|
||||||
|
@ -185,6 +174,9 @@ Color::Color (const std::string& spec)
|
||||||
throw std::string ("The color '") + *it + "' is not recognized.";
|
throw std::string ("The color '") + *it + "' is not recognized.";
|
||||||
|
|
||||||
index = 16 + r*36 + g*6 + b;
|
index = 16 + r*36 + g*6 + b;
|
||||||
|
|
||||||
|
upgrade ();
|
||||||
|
|
||||||
if (bg)
|
if (bg)
|
||||||
{
|
{
|
||||||
value |= _COLOR_HASBG;
|
value |= _COLOR_HASBG;
|
||||||
|
@ -206,6 +198,8 @@ Color::Color (const std::string& spec)
|
||||||
if (index < 0 || index > 255)
|
if (index < 0 || index > 255)
|
||||||
throw std::string ("The color '") + *it + "' is not recognized.";
|
throw std::string ("The color '") + *it + "' is not recognized.";
|
||||||
|
|
||||||
|
upgrade ();
|
||||||
|
|
||||||
if (bg)
|
if (bg)
|
||||||
{
|
{
|
||||||
value |= _COLOR_HASBG;
|
value |= _COLOR_HASBG;
|
||||||
|
@ -352,7 +346,7 @@ void Color::blend (const Color& other)
|
||||||
|
|
||||||
// Upgrade either color, if necessary.
|
// Upgrade either color, if necessary.
|
||||||
if (!(value & _COLOR_256)) upgrade ();
|
if (!(value & _COLOR_256)) upgrade ();
|
||||||
if (!(value & _COLOR_256)) c.upgrade ();
|
if (!(c.value & _COLOR_256)) c.upgrade ();
|
||||||
|
|
||||||
// 256 <-- 256.
|
// 256 <-- 256.
|
||||||
if (c.value & _COLOR_HASFG)
|
if (c.value & _COLOR_HASFG)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue