mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Feature - 256-color support
- Fixed bug that caused \033[m sequences to be emitted when no color is specified, in 16-color mode.
This commit is contained in:
parent
ff3b7cf337
commit
2074c8bb27
1 changed files with 21 additions and 4 deletions
|
@ -418,18 +418,35 @@ std::string Color::colorize (const std::string& input)
|
|||
// 256 color
|
||||
if (value & _COLOR_256)
|
||||
{
|
||||
bool needTerminator = false;
|
||||
|
||||
if (value & _COLOR_UNDERLINE)
|
||||
{
|
||||
result << "\033[4m";
|
||||
needTerminator = true;
|
||||
}
|
||||
|
||||
if (!(value & _COLOR_NOFG))
|
||||
{
|
||||
result << "\033[38;5;" << (value & _COLOR_FG) << "m";
|
||||
needTerminator = true;
|
||||
}
|
||||
|
||||
if (!(value & _COLOR_NOBG))
|
||||
{
|
||||
result << "\033[48;5;" << ((value & _COLOR_BG) >> 8) << "m";
|
||||
needTerminator = true;
|
||||
}
|
||||
|
||||
result << input;
|
||||
if (needTerminator)
|
||||
result << "\033[0m";
|
||||
|
||||
return result.str ();
|
||||
}
|
||||
|
||||
// 16 color
|
||||
else
|
||||
if (value != (_COLOR_NOFG | _COLOR_NOBG))
|
||||
{
|
||||
result << "\033[";
|
||||
|
||||
|
@ -457,11 +474,11 @@ std::string Color::colorize (const std::string& input)
|
|||
result << (29 + (value & _COLOR_FG));
|
||||
}
|
||||
|
||||
result << "m";
|
||||
result << "m" << input << "\033[0m";
|
||||
return result.str ();
|
||||
}
|
||||
|
||||
result << input << "\033[0m";
|
||||
return result.str ();
|
||||
return input;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue