mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 04:13:07 +02:00
Color
- Corrected some cases where rc.color was not obeyed.
This commit is contained in:
parent
df652d2ec7
commit
409fa216b8
3 changed files with 41 additions and 19 deletions
|
@ -26,11 +26,14 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <ViewTask.h>
|
#include <ViewTask.h>
|
||||||
|
#include <Context.h>
|
||||||
#include <Timer.h>
|
#include <Timer.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <utf8.h>
|
#include <utf8.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
|
extern Context context;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ViewTask::ViewTask ()
|
ViewTask::ViewTask ()
|
||||||
: _width (0)
|
: _width (0)
|
||||||
|
@ -204,10 +207,10 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
||||||
std::string extra = std::string (_extra_padding, ' ');
|
std::string extra = std::string (_extra_padding, ' ');
|
||||||
std::string intra = std::string (_intra_padding, ' ');
|
std::string intra = std::string (_intra_padding, ' ');
|
||||||
|
|
||||||
std::string extra_odd = _extra_odd.colorize (extra);
|
std::string extra_odd = context.color () ? _extra_odd.colorize (extra) : extra;
|
||||||
std::string extra_even = _extra_even.colorize (extra);
|
std::string extra_even = context.color () ? _extra_even.colorize (extra) : extra;
|
||||||
std::string intra_odd = _intra_odd.colorize (intra);
|
std::string intra_odd = context.color () ? _intra_odd.colorize (intra) : intra;
|
||||||
std::string intra_even = _intra_even.colorize (intra);
|
std::string intra_even = context.color () ? _intra_even.colorize (intra) : intra;
|
||||||
|
|
||||||
for (int i = 0; i < max_lines; ++i)
|
for (int i = 0; i < max_lines; ++i)
|
||||||
{
|
{
|
||||||
|
@ -249,8 +252,12 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
||||||
|
|
||||||
// Alternate rows based on |s % 2|
|
// Alternate rows based on |s % 2|
|
||||||
bool odd = (s % 2) ? true : false;
|
bool odd = (s % 2) ? true : false;
|
||||||
Color row_color = odd ? _odd : _even;
|
Color row_color;
|
||||||
row_color.blend (rule_color);
|
if (context.color ())
|
||||||
|
{
|
||||||
|
row_color = odd ? _odd : _even;
|
||||||
|
row_color.blend (rule_color);
|
||||||
|
}
|
||||||
|
|
||||||
for (int c = 0; c < _columns.size (); ++c)
|
for (int c = 0; c < _columns.size (); ++c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,11 +26,14 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
|
#include <Context.h>
|
||||||
#include <Timer.h>
|
#include <Timer.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <utf8.h>
|
#include <utf8.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
|
extern Context context;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ViewText::ViewText ()
|
ViewText::ViewText ()
|
||||||
: _width (0)
|
: _width (0)
|
||||||
|
@ -64,7 +67,8 @@ void ViewText::set (int row, int col, const std::string& value, Color color)
|
||||||
{
|
{
|
||||||
_data[row][col] = value;
|
_data[row][col] = value;
|
||||||
|
|
||||||
if (color.nontrivial ())
|
if (color.nontrivial () &&
|
||||||
|
! context.color ())
|
||||||
_color[row][col] = color;
|
_color[row][col] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +78,8 @@ void ViewText::set (int row, int col, int value, Color color)
|
||||||
std::string string_value = format (value);
|
std::string string_value = format (value);
|
||||||
_data[row][col] = string_value;
|
_data[row][col] = string_value;
|
||||||
|
|
||||||
if (color.nontrivial ())
|
if (color.nontrivial () &&
|
||||||
|
! context.color ())
|
||||||
_color[row][col] = color;
|
_color[row][col] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +89,8 @@ void ViewText::set (int row, int col, float value, int width, int precision, Col
|
||||||
std::string string_value = format ((float)value, width, precision);
|
std::string string_value = format ((float)value, width, precision);
|
||||||
_data[row][col] = string_value;
|
_data[row][col] = string_value;
|
||||||
|
|
||||||
if (color.nontrivial ())
|
if (color.nontrivial () &&
|
||||||
|
! context.color ())
|
||||||
_color[row][col] = color;
|
_color[row][col] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,10 +185,10 @@ std::string ViewText::render ()
|
||||||
std::string extra = std::string (_extra_padding, ' ');
|
std::string extra = std::string (_extra_padding, ' ');
|
||||||
std::string intra = std::string (_intra_padding, ' ');
|
std::string intra = std::string (_intra_padding, ' ');
|
||||||
|
|
||||||
std::string extra_odd = _extra_odd.colorize (extra);
|
std::string extra_odd = context.color () ? _extra_odd.colorize (extra) : extra;
|
||||||
std::string extra_even = _extra_even.colorize (extra);
|
std::string extra_even = context.color () ? _extra_even.colorize (extra) : extra;
|
||||||
std::string intra_odd = _intra_odd.colorize (intra);
|
std::string intra_odd = context.color () ? _intra_odd.colorize (intra) : intra;
|
||||||
std::string intra_even = _intra_even.colorize (intra);
|
std::string intra_even = context.color () ? _intra_even.colorize (intra) : intra;
|
||||||
|
|
||||||
for (int i = 0; i < max_lines; ++i)
|
for (int i = 0; i < max_lines; ++i)
|
||||||
{
|
{
|
||||||
|
@ -228,8 +234,11 @@ std::string ViewText::render ()
|
||||||
Color cell_color;
|
Color cell_color;
|
||||||
for (int col = 0; col < _columns.size (); ++col)
|
for (int col = 0; col < _columns.size (); ++col)
|
||||||
{
|
{
|
||||||
cell_color = row_color;
|
if (context.color ())
|
||||||
cell_color.blend (_color[row][col]);
|
{
|
||||||
|
cell_color = row_color;
|
||||||
|
cell_color.blend (_color[row][col]);
|
||||||
|
}
|
||||||
|
|
||||||
cells.push_back (std::vector <std::string> ());
|
cells.push_back (std::vector <std::string> ());
|
||||||
_columns[col]->render (cells[col], _data[row][col], widths[col], cell_color);
|
_columns[col]->render (cells[col], _data[row][col], widths[col], cell_color);
|
||||||
|
@ -256,10 +265,15 @@ std::string ViewText::render ()
|
||||||
out += cells[col][i];
|
out += cells[col][i];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cell_color = row_color;
|
if (context.color ())
|
||||||
cell_color.blend (_color[row][col]);
|
{
|
||||||
|
cell_color = row_color;
|
||||||
|
cell_color.blend (_color[row][col]);
|
||||||
|
|
||||||
out += cell_color.colorize (std::string (widths[col], ' '));
|
out += cell_color.colorize (std::string (widths[col], ' '));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
out += std::string (widths[col], ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,8 @@ static void colorizeRecurring (Task& task, const std::string& rule, Color& c)
|
||||||
void autoColorize (Task& task, Color& c)
|
void autoColorize (Task& task, Color& c)
|
||||||
{
|
{
|
||||||
// The special tag 'nocolor' overrides all auto and specific colorization.
|
// The special tag 'nocolor' overrides all auto and specific colorization.
|
||||||
if (task.hasTag ("nocolor"))
|
if (!context.color () ||
|
||||||
|
task.hasTag ("nocolor"))
|
||||||
{
|
{
|
||||||
c = Color ();
|
c = Color ();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue