mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-21 07:43:08 +02:00
- Corrected colorization rules parsing.
This commit is contained in:
parent
494ed3b964
commit
2ecf500322
2 changed files with 12 additions and 32 deletions
|
@ -11,6 +11,9 @@
|
||||||
------ reality -----------------------------------
|
------ reality -----------------------------------
|
||||||
|
|
||||||
0.9.6
|
0.9.6
|
||||||
|
5/13/208
|
||||||
|
+ Replaced color management code.
|
||||||
|
+ Improved color rules code.
|
||||||
|
|
||||||
0.9.5
|
0.9.5
|
||||||
5/12/2008
|
5/12/2008
|
||||||
|
|
|
@ -16,8 +16,8 @@ static std::map <std::string, Text::color> gsBg;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// There are three supported variants:
|
// There are three supported variants:
|
||||||
// 1) "fg"
|
// 1) "fg"
|
||||||
// 2) "on bg"
|
// 2) "bg"
|
||||||
// 3) "fg on bg"
|
// 3) "fg bg"
|
||||||
static void parseColorRule (
|
static void parseColorRule (
|
||||||
const std::string& rule,
|
const std::string& rule,
|
||||||
Text::color& fg,
|
Text::color& fg,
|
||||||
|
@ -25,41 +25,18 @@ static void parseColorRule (
|
||||||
{
|
{
|
||||||
fg = Text::nocolor;
|
fg = Text::nocolor;
|
||||||
bg = Text::nocolor;
|
bg = Text::nocolor;
|
||||||
bool error = false;
|
|
||||||
|
|
||||||
std::vector <std::string> words;
|
std::vector <std::string> words;
|
||||||
split (words, rule, ' ');
|
split (words, rule, ' ');
|
||||||
switch (words.size ())
|
|
||||||
|
std::vector <std::string>::iterator it;
|
||||||
|
for (it = words.begin (); it != words.end (); ++it)
|
||||||
{
|
{
|
||||||
case 1: // "fg" - no spaces.
|
if (it->substr (0, 3) == "on_")
|
||||||
fg = Text::colorCode (words[0]);
|
bg = Text::colorCode (*it);
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: // "on bg" - one space, "on" before.
|
|
||||||
if (words[0] == "on")
|
|
||||||
bg = Text::colorCode (words[1]);
|
|
||||||
else
|
else
|
||||||
error = true;
|
fg = Text::colorCode (*it);
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: // "fg on bg" - two spaces, "on" between them.
|
|
||||||
if (words[1] == "on")
|
|
||||||
{
|
|
||||||
fg = Text::colorCode (words[0]);
|
|
||||||
bg = Text::colorCode (words[2]);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
error = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
default:
|
|
||||||
error = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
std::cout << "Malformed color rule '" << rule << "'" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue