mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-22 11:13:09 +02:00
Color: Removed FEATURE_COLOR conditional compile
- No need any more.
This commit is contained in:
parent
b04032c9d6
commit
f55afe33d7
5 changed files with 0 additions and 43 deletions
|
@ -74,14 +74,12 @@ Color::Color (const Color& other)
|
||||||
Color::Color (unsigned int c)
|
Color::Color (unsigned int c)
|
||||||
: _value (0)
|
: _value (0)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
if (!(c & _COLOR_HASFG)) _value &= ~_COLOR_FG;
|
if (!(c & _COLOR_HASFG)) _value &= ~_COLOR_FG;
|
||||||
if (!(c & _COLOR_HASBG)) _value &= ~_COLOR_BG;
|
if (!(c & _COLOR_HASBG)) _value &= ~_COLOR_BG;
|
||||||
|
|
||||||
_value = c & (_COLOR_256 | _COLOR_HASBG | _COLOR_HASFG |_COLOR_UNDERLINE |
|
_value = c & (_COLOR_256 | _COLOR_HASBG | _COLOR_HASFG |_COLOR_UNDERLINE |
|
||||||
_COLOR_INVERSE | _COLOR_BOLD | _COLOR_BRIGHT | _COLOR_BG |
|
_COLOR_INVERSE | _COLOR_BOLD | _COLOR_BRIGHT | _COLOR_BG |
|
||||||
_COLOR_FG);
|
_COLOR_FG);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -99,7 +97,6 @@ Color::Color (unsigned int c)
|
||||||
Color::Color (const std::string& spec)
|
Color::Color (const std::string& spec)
|
||||||
: _value (0)
|
: _value (0)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
// Split spec into words.
|
// Split spec into words.
|
||||||
std::vector <std::string> words;
|
std::vector <std::string> words;
|
||||||
split (words, spec, ' ');
|
split (words, spec, ' ');
|
||||||
|
@ -224,27 +221,23 @@ Color::Color (const std::string& spec)
|
||||||
// Now combine the fg and bg into a single color.
|
// Now combine the fg and bg into a single color.
|
||||||
_value = fg_value;
|
_value = fg_value;
|
||||||
blend (Color (bg_value));
|
blend (Color (bg_value));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Color::Color (color_id fg)
|
Color::Color (color_id fg)
|
||||||
: _value (0)
|
: _value (0)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
if (fg != Color::nocolor)
|
if (fg != Color::nocolor)
|
||||||
{
|
{
|
||||||
_value |= _COLOR_HASFG;
|
_value |= _COLOR_HASFG;
|
||||||
_value |= fg;
|
_value |= fg;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Color::Color (color_id fg, color_id bg)
|
Color::Color (color_id fg, color_id bg)
|
||||||
: _value (0)
|
: _value (0)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
if (bg != Color::nocolor)
|
if (bg != Color::nocolor)
|
||||||
{
|
{
|
||||||
_value |= _COLOR_HASBG;
|
_value |= _COLOR_HASBG;
|
||||||
|
@ -256,14 +249,12 @@ Color::Color (color_id fg, color_id bg)
|
||||||
_value |= _COLOR_HASFG;
|
_value |= _COLOR_HASFG;
|
||||||
_value |= fg;
|
_value |= fg;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Color::Color (color_id fg, color_id bg, bool underline, bool bold, bool bright)
|
Color::Color (color_id fg, color_id bg, bool underline, bool bold, bool bright)
|
||||||
: _value (0)
|
: _value (0)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
_value |= ((underline ? 1 : 0) << 18)
|
_value |= ((underline ? 1 : 0) << 18)
|
||||||
| ((bold ? 1 : 0) << 17)
|
| ((bold ? 1 : 0) << 17)
|
||||||
| ((bright ? 1 : 0) << 16);
|
| ((bright ? 1 : 0) << 16);
|
||||||
|
@ -279,7 +270,6 @@ Color::Color (color_id fg, color_id bg, bool underline, bool bold, bool bright)
|
||||||
_value |= _COLOR_HASFG;
|
_value |= _COLOR_HASFG;
|
||||||
_value |= fg;
|
_value |= fg;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -300,7 +290,6 @@ Color& Color::operator= (const Color& other)
|
||||||
Color::operator std::string () const
|
Color::operator std::string () const
|
||||||
{
|
{
|
||||||
std::string description;
|
std::string description;
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
if (_value & _COLOR_BOLD) description += "bold";
|
if (_value & _COLOR_BOLD) description += "bold";
|
||||||
|
|
||||||
if (_value & _COLOR_UNDERLINE)
|
if (_value & _COLOR_UNDERLINE)
|
||||||
|
@ -321,7 +310,6 @@ Color::operator std::string () const
|
||||||
|
|
||||||
description += " " + bg ();
|
description += " " + bg ();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
@ -337,7 +325,6 @@ Color::operator int () const
|
||||||
// other take precedence.
|
// other take precedence.
|
||||||
void Color::blend (const Color& other)
|
void Color::blend (const Color& other)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
if (!other.nontrivial ())
|
if (!other.nontrivial ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -389,13 +376,11 @@ void Color::blend (const Color& other)
|
||||||
_value |= (c._value & _COLOR_BG); // Apply other color.
|
_value |= (c._value & _COLOR_BG); // Apply other color.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Color::upgrade ()
|
void Color::upgrade ()
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
if (!(_value & _COLOR_256))
|
if (!(_value & _COLOR_256))
|
||||||
{
|
{
|
||||||
if (_value & _COLOR_HASFG)
|
if (_value & _COLOR_HASFG)
|
||||||
|
@ -418,7 +403,6 @@ void Color::upgrade ()
|
||||||
|
|
||||||
_value |= _COLOR_256;
|
_value |= _COLOR_256;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -435,7 +419,6 @@ void Color::upgrade ()
|
||||||
// 256 bg \033[48;5;Nm
|
// 256 bg \033[48;5;Nm
|
||||||
std::string Color::colorize (const std::string& input)
|
std::string Color::colorize (const std::string& input)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
if (!nontrivial ())
|
if (!nontrivial ())
|
||||||
return input;
|
return input;
|
||||||
|
|
||||||
|
@ -500,7 +483,6 @@ std::string Color::colorize (const std::string& input)
|
||||||
result << "m" << input << "\033[0m";
|
result << "m" << input << "\033[0m";
|
||||||
return result.str ();
|
return result.str ();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
@ -509,7 +491,6 @@ std::string Color::colorize (const std::string& input)
|
||||||
// Remove color codes from a string.
|
// Remove color codes from a string.
|
||||||
std::string Color::strip (const std::string& input)
|
std::string Color::strip (const std::string& input)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
int length = input.length ();
|
int length = input.length ();
|
||||||
bool inside = false;
|
bool inside = false;
|
||||||
std::string output;
|
std::string output;
|
||||||
|
@ -530,20 +511,13 @@ std::string Color::strip (const std::string& input)
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
#else
|
|
||||||
return input;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Color::colorize (const std::string& input, const std::string& spec)
|
std::string Color::colorize (const std::string& input, const std::string& spec)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
Color c (spec);
|
Color c (spec);
|
||||||
return c.colorize (input);
|
return c.colorize (input);
|
||||||
#else
|
|
||||||
return input;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -565,7 +539,6 @@ int Color::find (const std::string& input)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Color::fg () const
|
std::string Color::fg () const
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
int index = _value & _COLOR_FG;
|
int index = _value & _COLOR_FG;
|
||||||
|
|
||||||
if (_value & _COLOR_256)
|
if (_value & _COLOR_256)
|
||||||
|
@ -583,7 +556,6 @@ std::string Color::fg () const
|
||||||
if (allColors[i].index == index)
|
if (allColors[i].index == index)
|
||||||
return allColors[i].english_name;
|
return allColors[i].english_name;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -591,7 +563,6 @@ std::string Color::fg () const
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Color::bg () const
|
std::string Color::bg () const
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
int index = (_value & _COLOR_BG) >> 8;
|
int index = (_value & _COLOR_BG) >> 8;
|
||||||
|
|
||||||
if (_value & _COLOR_256)
|
if (_value & _COLOR_256)
|
||||||
|
@ -609,7 +580,6 @@ std::string Color::bg () const
|
||||||
if (allColors[i].index == index)
|
if (allColors[i].index == index)
|
||||||
return allColors[i].english_name;
|
return allColors[i].english_name;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define FEATURE_COLOR 1
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#define _COLOR_INVERSE 0x00400000 // Inverse attribute.
|
#define _COLOR_INVERSE 0x00400000 // Inverse attribute.
|
||||||
#define _COLOR_256 0x00200000 // 256-color mode.
|
#define _COLOR_256 0x00200000 // 256-color mode.
|
||||||
|
|
|
@ -467,7 +467,6 @@ int Context::dispatch (std::string &out)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Context::color ()
|
bool Context::color ()
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
if (determine_color_use)
|
if (determine_color_use)
|
||||||
{
|
{
|
||||||
// What the config says.
|
// What the config says.
|
||||||
|
@ -497,9 +496,6 @@ bool Context::color ()
|
||||||
|
|
||||||
// Cached result.
|
// Cached result.
|
||||||
return use_color;
|
return use_color;
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -57,7 +57,6 @@ int CmdColor::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
#ifdef FEATURE_COLOR
|
|
||||||
// Get the non-attribute, non-fancy command line arguments.
|
// Get the non-attribute, non-fancy command line arguments.
|
||||||
bool legend = false;
|
bool legend = false;
|
||||||
std::vector <std::string> words = context.cli2.getWords ();
|
std::vector <std::string> words = context.cli2.getWords ();
|
||||||
|
@ -263,10 +262,6 @@ int CmdColor::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
#else
|
|
||||||
output = "Color not supported.\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#ifndef INCLUDED_MAIN
|
#ifndef INCLUDED_MAIN
|
||||||
#define INCLUDED_MAIN
|
#define INCLUDED_MAIN
|
||||||
|
|
||||||
#define FEATURE_COLOR 1 // Enable color.
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue