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,
|
||||
mis-identifying the task as recurring just because it had a due date
|
||||
(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 ------------------------------
|
||||
|
||||
|
|
|
@ -73,15 +73,17 @@ Table::~Table ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
void Table::setTableColor (const Color& c)
|
||||
{
|
||||
mColor["table"] = 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)
|
||||
{
|
||||
char id[12];
|
||||
sprintf (id, "col:%d", column);
|
||||
mColor[id] = c;
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
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];
|
||||
sprintf (idCell, "cell:%d,%d", row, col);
|
||||
if (mColor.find (idCell) != mColor.end ())
|
||||
return mColor[idCell];
|
||||
// Color defaults to trivial.
|
||||
Color c;
|
||||
|
||||
char idRow[12];
|
||||
sprintf (idRow, "row:%d", row);
|
||||
if (mColor.find (idRow) != mColor.end ())
|
||||
return mColor[idRow];
|
||||
// For alternating rows, use Table::alternate.
|
||||
std::map <std::string, Color>::iterator i;
|
||||
char id[24];
|
||||
|
||||
char idCol[12];
|
||||
sprintf (idCol, "col:%d", col);
|
||||
if (mColor.find (idCol) != mColor.end ())
|
||||
return mColor[idCol];
|
||||
if (index % 2)
|
||||
c = alternate;
|
||||
|
||||
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)
|
||||
{
|
||||
char idCol[12];
|
||||
sprintf (idCol, "col:%d", col);
|
||||
// Color defaults to trivial.
|
||||
Color c;
|
||||
|
||||
return mColor.find (idCol) != mColor.end () ? mColor[idCol]
|
||||
: mColor.find ("table") != mColor.end () ? mColor["table"]
|
||||
: Color ();
|
||||
/*
|
||||
std::map <std::string, Color>::iterator i;
|
||||
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 (
|
||||
const int index,
|
||||
const int row,
|
||||
const int col,
|
||||
const int width,
|
||||
|
@ -577,7 +610,7 @@ void Table::formatCell (
|
|||
{
|
||||
assert (width > 0);
|
||||
|
||||
Color c = getColor (row, col);
|
||||
Color c = getColor (index, row, col);
|
||||
just justification = getJustification (row, col);
|
||||
std::string data = getCell (row, col);
|
||||
|
||||
|
@ -1027,13 +1060,6 @@ const std::string Table::render (int maximum /* = 0 */)
|
|||
if (mSortColumns.size ())
|
||||
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
|
||||
// the table that are rendered.
|
||||
int limit = mRows;
|
||||
|
@ -1052,6 +1078,7 @@ const std::string Table::render (int maximum /* = 0 */)
|
|||
std::vector <std::string> lines;
|
||||
std::string blank;
|
||||
formatCell (
|
||||
row,
|
||||
order[row],
|
||||
col,
|
||||
mCalculatedWidth[col],
|
||||
|
|
11
src/Table.h
11
src/Table.h
|
@ -57,7 +57,8 @@ public:
|
|||
Table (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 setTablePadding (int);
|
||||
void setTableIntraPadding (int);
|
||||
|
@ -65,7 +66,8 @@ public:
|
|||
void setTableDashedUnderline ();
|
||||
|
||||
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 setColumnPadding (int, int);
|
||||
void setColumnWidth (int, int);
|
||||
|
@ -94,7 +96,7 @@ public:
|
|||
|
||||
private:
|
||||
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 getHeaderUnderline (const int);
|
||||
int getPadding (const int);
|
||||
|
@ -104,7 +106,7 @@ private:
|
|||
just getHeaderJustification (const int);
|
||||
const std::string formatHeader (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 clean (std::string&);
|
||||
void optimize (std::string&) const;
|
||||
|
@ -116,6 +118,7 @@ private:
|
|||
std::map <std::string, Color> mColor;
|
||||
std::map <std::string, Color> mUnderline;
|
||||
bool mDashedUnderline;
|
||||
Color alternate;
|
||||
|
||||
// Padding...
|
||||
int mTablePadding;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue