mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 13:23:08 +02:00
Commands - color
- Reenabled the color command using new argument processing.
This commit is contained in:
parent
2ce0b5a1ab
commit
e92a7fdf7d
1 changed files with 26 additions and 8 deletions
|
@ -28,6 +28,9 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Color.h>
|
||||||
|
#include <text.h>
|
||||||
|
#include <i18n.h>
|
||||||
#include <CmdColor.h>
|
#include <CmdColor.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
@ -47,15 +50,21 @@ CmdColor::CmdColor ()
|
||||||
int CmdColor::execute (std::string& output)
|
int CmdColor::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
std::stringstream out;
|
|
||||||
|
|
||||||
|
// Get the non-attribute, non-fancy command line arguments.
|
||||||
|
bool legend = false;
|
||||||
|
Arguments words = context.args.extract_simple_words ();
|
||||||
|
std::vector <Triple>::iterator word;
|
||||||
|
for (word = words.begin (); word != words.end (); ++word)
|
||||||
|
if (closeEnough ("legend", word->_first))
|
||||||
|
legend = true;
|
||||||
|
|
||||||
|
std::stringstream out;
|
||||||
if (context.color ())
|
if (context.color ())
|
||||||
{
|
{
|
||||||
// If the description contains 'legend', show all the colors currently in
|
// If the description contains 'legend', show all the colors currently in
|
||||||
// use.
|
// use.
|
||||||
std::string description = context.task.get ("description");
|
if (legend)
|
||||||
if (description.find ("legend") != std::string::npos)
|
|
||||||
{
|
{
|
||||||
out << "\nHere are the colors currently in use:\n";
|
out << "\nHere are the colors currently in use:\n";
|
||||||
|
|
||||||
|
@ -89,7 +98,7 @@ int CmdColor::execute (std::string& output)
|
||||||
|
|
||||||
// If there is something in the description, then assume that is a color,
|
// If there is something in the description, then assume that is a color,
|
||||||
// and display it as a sample.
|
// and display it as a sample.
|
||||||
else if (description != "")
|
else if (words.size ())
|
||||||
{
|
{
|
||||||
Color one ("black on bright yellow");
|
Color one ("black on bright yellow");
|
||||||
Color two ("underline cyan on bright blue");
|
Color two ("underline cyan on bright blue");
|
||||||
|
@ -97,7 +106,17 @@ int CmdColor::execute (std::string& output)
|
||||||
Color four ("rgb150 on rgb020");
|
Color four ("rgb150 on rgb020");
|
||||||
Color five ("underline grey10 on grey3");
|
Color five ("underline grey10 on grey3");
|
||||||
Color six ("red on color173");
|
Color six ("red on color173");
|
||||||
Color sample (description);
|
|
||||||
|
std::string swatch;
|
||||||
|
for (word = words.begin (); word != words.end (); ++word)
|
||||||
|
{
|
||||||
|
if (word != words.begin ())
|
||||||
|
swatch += " ";
|
||||||
|
|
||||||
|
swatch += word->_first;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color sample (swatch);
|
||||||
|
|
||||||
out << "\n"
|
out << "\n"
|
||||||
<< "Use this command to see how colors are displayed by your terminal.\n\n"
|
<< "Use this command to see how colors are displayed by your terminal.\n\n"
|
||||||
|
@ -113,7 +132,7 @@ int CmdColor::execute (std::string& output)
|
||||||
<< " " << six.colorize ("task color red on color173") << "\n"
|
<< " " << six.colorize ("task color red on color173") << "\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "Your sample:" << "\n"
|
<< "Your sample:" << "\n"
|
||||||
<< " " << sample.colorize ("task color " + description) << "\n\n";
|
<< " " << sample.colorize ("task color " + swatch) << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show all supported colors. Possibly show some unsupported ones too.
|
// Show all supported colors. Possibly show some unsupported ones too.
|
||||||
|
@ -240,7 +259,6 @@ int CmdColor::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue