mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug Fix - #371 color.due clobbered by color.alternate
- Fixed bug #371 which caused task to mis-apply certain color rules, like color.alternate, which was (a) not applied first, and (b) not blended with the other color rules (thanks to Richard Querin).
This commit is contained in:
parent
58910b07ef
commit
2b2795077b
3 changed files with 67 additions and 34 deletions
|
@ -80,6 +80,9 @@
|
||||||
+ Fixed bug #370 which prevented the removal of a due date from a task,
|
+ Fixed bug #370 which prevented the removal of a due date from a task,
|
||||||
mis-identifying the task as recurring just because it had a due date
|
mis-identifying the task as recurring just because it had a due date
|
||||||
(thanks to John Florian).
|
(thanks to John Florian).
|
||||||
|
+ Fixed bug #371 which caused task to mis-apply certain color rules, like
|
||||||
|
color.alternate, which was (a) not applied first, and (b) not blended
|
||||||
|
with the other color rules (thanks to Richard Querin).
|
||||||
|
|
||||||
------ old releases ------------------------------
|
------ old releases ------------------------------
|
||||||
|
|
||||||
|
|
|
@ -73,15 +73,17 @@ Table::~Table ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/*
|
||||||
void Table::setTableColor (const Color& c)
|
void Table::setTableColor (const Color& c)
|
||||||
{
|
{
|
||||||
mColor["table"] = c;
|
mColor["table"] = c;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setTableAlternateColor (const Color& c)
|
void Table::setTableAlternateColor (const Color& c)
|
||||||
{
|
{
|
||||||
mColor["alternate"] = c;
|
alternate = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -122,12 +124,15 @@ int Table::addColumn (const std::string& col)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// TODO Obsolete - this call is not used. Consider removal.
|
||||||
|
/*
|
||||||
void Table::setColumnColor (int column, const Color& c)
|
void Table::setColumnColor (int column, const Color& c)
|
||||||
{
|
{
|
||||||
char id[12];
|
char id[12];
|
||||||
sprintf (id, "col:%d", column);
|
sprintf (id, "col:%d", column);
|
||||||
mColor[id] = c;
|
mColor[id] = c;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setColumnUnderline (int column)
|
void Table::setColumnUnderline (int column)
|
||||||
|
@ -316,38 +321,65 @@ std::string Table::getCell (const int row, const int col)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Color Table::getColor (const int row, const int col)
|
Color Table::getColor (const int index, const int row, const int col)
|
||||||
{
|
{
|
||||||
char idCell[24];
|
// Color defaults to trivial.
|
||||||
sprintf (idCell, "cell:%d,%d", row, col);
|
Color c;
|
||||||
if (mColor.find (idCell) != mColor.end ())
|
|
||||||
return mColor[idCell];
|
|
||||||
|
|
||||||
char idRow[12];
|
// For alternating rows, use Table::alternate.
|
||||||
sprintf (idRow, "row:%d", row);
|
std::map <std::string, Color>::iterator i;
|
||||||
if (mColor.find (idRow) != mColor.end ())
|
char id[24];
|
||||||
return mColor[idRow];
|
|
||||||
|
|
||||||
char idCol[12];
|
if (index % 2)
|
||||||
sprintf (idCol, "col:%d", col);
|
c = alternate;
|
||||||
if (mColor.find (idCol) != mColor.end ())
|
|
||||||
return mColor[idCol];
|
|
||||||
|
|
||||||
if (mColor.find ("table") != mColor.end ())
|
/*
|
||||||
return mColor["table"];
|
// TODO Obsolete - this is not used. Consider removal.
|
||||||
|
// Blend with a table color, if specified.
|
||||||
|
if ((i = mColor.find ("table")) != mColor.end ())
|
||||||
|
c.blend (i->second);
|
||||||
|
|
||||||
return Color ();
|
// Blend with a column color, if specified.
|
||||||
|
sprintf (id, "col:%d", col);
|
||||||
|
if ((i = mColor.find (id)) != mColor.end ())
|
||||||
|
c.blend (i->second);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Blend with a row color, if specified.
|
||||||
|
sprintf (id, "row:%d", row);
|
||||||
|
if ((i = mColor.find (id)) != mColor.end ())
|
||||||
|
c.blend (i->second);
|
||||||
|
|
||||||
|
// Blend with a cell color, if specified.
|
||||||
|
sprintf (id, "cell:%d,%d", row, col);
|
||||||
|
if ((i = mColor.find (id)) != mColor.end ())
|
||||||
|
c.blend (i->second);
|
||||||
|
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// TODO Obsolete - this is not used. Consider removal.
|
||||||
Color Table::getHeaderColor (int col)
|
Color Table::getHeaderColor (int col)
|
||||||
{
|
{
|
||||||
char idCol[12];
|
// Color defaults to trivial.
|
||||||
sprintf (idCol, "col:%d", col);
|
Color c;
|
||||||
|
|
||||||
return mColor.find (idCol) != mColor.end () ? mColor[idCol]
|
/*
|
||||||
: mColor.find ("table") != mColor.end () ? mColor["table"]
|
std::map <std::string, Color>::iterator i;
|
||||||
: Color ();
|
char id[24];
|
||||||
|
|
||||||
|
// Blend with a table color, if specified.
|
||||||
|
if ((i = mColor.find ("table")) != mColor.end ())
|
||||||
|
c.blend (i->second);
|
||||||
|
|
||||||
|
// Blend with a column color, if specified.
|
||||||
|
sprintf (id, "col:%d", col);
|
||||||
|
if ((i = mColor.find (id)) != mColor.end ())
|
||||||
|
c.blend (i->second);
|
||||||
|
*/
|
||||||
|
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -568,6 +600,7 @@ const std::string Table::formatHeaderDashedUnderline (
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::formatCell (
|
void Table::formatCell (
|
||||||
|
const int index,
|
||||||
const int row,
|
const int row,
|
||||||
const int col,
|
const int col,
|
||||||
const int width,
|
const int width,
|
||||||
|
@ -577,7 +610,7 @@ void Table::formatCell (
|
||||||
{
|
{
|
||||||
assert (width > 0);
|
assert (width > 0);
|
||||||
|
|
||||||
Color c = getColor (row, col);
|
Color c = getColor (index, row, col);
|
||||||
just justification = getJustification (row, col);
|
just justification = getJustification (row, col);
|
||||||
std::string data = getCell (row, col);
|
std::string data = getCell (row, col);
|
||||||
|
|
||||||
|
@ -1027,13 +1060,6 @@ const std::string Table::render (int maximum /* = 0 */)
|
||||||
if (mSortColumns.size ())
|
if (mSortColumns.size ())
|
||||||
sort (order);
|
sort (order);
|
||||||
|
|
||||||
// Now blend in the alternate row color.
|
|
||||||
Color alternate = mColor["alternate"];
|
|
||||||
if (alternate.nontrivial ())
|
|
||||||
for (unsigned int row = 0; row < order.size (); ++row)
|
|
||||||
if (row % 2)
|
|
||||||
setRowColor (order[row], alternate);
|
|
||||||
|
|
||||||
// If a non-zero maximum is specified, then it limits the number of rows of
|
// If a non-zero maximum is specified, then it limits the number of rows of
|
||||||
// the table that are rendered.
|
// the table that are rendered.
|
||||||
int limit = mRows;
|
int limit = mRows;
|
||||||
|
@ -1052,6 +1078,7 @@ const std::string Table::render (int maximum /* = 0 */)
|
||||||
std::vector <std::string> lines;
|
std::vector <std::string> lines;
|
||||||
std::string blank;
|
std::string blank;
|
||||||
formatCell (
|
formatCell (
|
||||||
|
row,
|
||||||
order[row],
|
order[row],
|
||||||
col,
|
col,
|
||||||
mCalculatedWidth[col],
|
mCalculatedWidth[col],
|
||||||
|
|
11
src/Table.h
11
src/Table.h
|
@ -57,7 +57,8 @@ public:
|
||||||
Table (const Table&);
|
Table (const Table&);
|
||||||
Table& operator= (const Table&);
|
Table& operator= (const Table&);
|
||||||
|
|
||||||
void setTableColor (const Color&);
|
// TODO Obsolete - this is not used. Consider removal.
|
||||||
|
// void setTableColor (const Color&);
|
||||||
void setTableAlternateColor (const Color&);
|
void setTableAlternateColor (const Color&);
|
||||||
void setTablePadding (int);
|
void setTablePadding (int);
|
||||||
void setTableIntraPadding (int);
|
void setTableIntraPadding (int);
|
||||||
|
@ -65,7 +66,8 @@ public:
|
||||||
void setTableDashedUnderline ();
|
void setTableDashedUnderline ();
|
||||||
|
|
||||||
int addColumn (const std::string&);
|
int addColumn (const std::string&);
|
||||||
void setColumnColor (int, const Color&);
|
// TODO Obsolete - this is not used. Consider removal.
|
||||||
|
// void setColumnColor (int, const Color&);
|
||||||
void setColumnUnderline (int);
|
void setColumnUnderline (int);
|
||||||
void setColumnPadding (int, int);
|
void setColumnPadding (int, int);
|
||||||
void setColumnWidth (int, int);
|
void setColumnWidth (int, int);
|
||||||
|
@ -94,7 +96,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string getCell (const int, const int);
|
std::string getCell (const int, const int);
|
||||||
Color getColor (const int, const int);
|
Color getColor (const int, const int, const int);
|
||||||
Color getHeaderColor (const int);
|
Color getHeaderColor (const int);
|
||||||
Color getHeaderUnderline (const int);
|
Color getHeaderUnderline (const int);
|
||||||
int getPadding (const int);
|
int getPadding (const int);
|
||||||
|
@ -104,7 +106,7 @@ private:
|
||||||
just getHeaderJustification (const int);
|
just getHeaderJustification (const int);
|
||||||
const std::string formatHeader (const int, const int, const int);
|
const std::string formatHeader (const int, const int, const int);
|
||||||
const std::string formatHeaderDashedUnderline (const int, const int, const int);
|
const std::string formatHeaderDashedUnderline (const int, const int, const int);
|
||||||
void formatCell (const int, const int, const int, const int, std::vector <std::string>&, std::string&);
|
void formatCell (const int, const int, const int, const int, const int, std::vector <std::string>&, std::string&);
|
||||||
void sort (std::vector <int>&);
|
void sort (std::vector <int>&);
|
||||||
void clean (std::string&);
|
void clean (std::string&);
|
||||||
void optimize (std::string&) const;
|
void optimize (std::string&) const;
|
||||||
|
@ -116,6 +118,7 @@ private:
|
||||||
std::map <std::string, Color> mColor;
|
std::map <std::string, Color> mColor;
|
||||||
std::map <std::string, Color> mUnderline;
|
std::map <std::string, Color> mUnderline;
|
||||||
bool mDashedUnderline;
|
bool mDashedUnderline;
|
||||||
|
Color alternate;
|
||||||
|
|
||||||
// Padding...
|
// Padding...
|
||||||
int mTablePadding;
|
int mTablePadding;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue