mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
- Task now uses dashes (-----) to underline column headings when color is
disabled (thanks for Vincent Fleuranceau).
This commit is contained in:
parent
11225eb599
commit
4abc722eff
6 changed files with 110 additions and 3 deletions
|
@ -12,6 +12,8 @@ represents a feature release, and the Z represents a patch.
|
||||||
have been run (and therefore TDB::gc run)
|
have been run (and therefore TDB::gc run)
|
||||||
+ Task now correctly sorts on entire strings, instead of just the first
|
+ Task now correctly sorts on entire strings, instead of just the first
|
||||||
character (thanks to Andy Lester)
|
character (thanks to Andy Lester)
|
||||||
|
+ Task now uses dashes (-----) to column underlines when color is disabled
|
||||||
|
(thanks to Vincent Fleuranceau)
|
||||||
|
|
||||||
------ old releases ------------------------------
|
------ old releases ------------------------------
|
||||||
|
|
||||||
|
|
|
@ -210,6 +210,8 @@
|
||||||
<dt>color</dt>
|
<dt>color</dt>
|
||||||
<dd>
|
<dd>
|
||||||
May be "on" or "off". Determines whether task uses color.
|
May be "on" or "off". Determines whether task uses color.
|
||||||
|
When "off", task will use dashes (-----) to underline column
|
||||||
|
headings.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>
|
<dt>
|
||||||
|
|
|
@ -90,12 +90,14 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>New in version 1.4.2 (?/?/?)</h4>
|
<h4>New in version 1.4.2 (9/12/2008)</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>"task undo" can now retract a "task done" command, provided no
|
<li>"task undo" can now retract a "task done" command, provided no
|
||||||
reports have been run.
|
reports have been run.
|
||||||
<li>Task now correctly sorts on entire strings, instead of just the
|
<li>Task now correctly sorts on entire strings, instead of just the
|
||||||
first character (thanks to Andy Lester).
|
first character (thanks to Andy Lester).
|
||||||
|
<li>Task now uses dashes (-----) to underline column headings when
|
||||||
|
color is disabled (thanks to Vincent Fleuranceau).
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
Table::Table ()
|
Table::Table ()
|
||||||
: mRows (0)
|
: mRows (0)
|
||||||
, mIntraPadding (1)
|
, mIntraPadding (1)
|
||||||
|
, mDashedUnderline (false)
|
||||||
, mTablePadding (0)
|
, mTablePadding (0)
|
||||||
, mTableWidth (0)
|
, mTableWidth (0)
|
||||||
, mSuppressWS (false)
|
, mSuppressWS (false)
|
||||||
|
@ -103,6 +104,12 @@ void Table::setTableWidth (int width)
|
||||||
mTableWidth = width;
|
mTableWidth = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Table::setTableDashedUnderline ()
|
||||||
|
{
|
||||||
|
mDashedUnderline = true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Table::addColumn (const std::string& col)
|
int Table::addColumn (const std::string& col)
|
||||||
{
|
{
|
||||||
|
@ -582,7 +589,57 @@ const std::string Table::formatHeader (
|
||||||
fg, bg,
|
fg, bg,
|
||||||
Text::colorize (
|
Text::colorize (
|
||||||
decoration, Text::nocolor,
|
decoration, Text::nocolor,
|
||||||
pad + preJust+ data + postJust + pad) + intraPad);
|
pad + preJust + data + postJust + pad) + intraPad);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// data One Data to be rendered
|
||||||
|
// width 8 Max data width for column/specified width
|
||||||
|
// padding 1 Extra padding around data
|
||||||
|
// intraPadding 0 Extra padding between columns only
|
||||||
|
// justification right Alignment withing padding
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// "------- "
|
||||||
|
// ------- data
|
||||||
|
// ^ ^ padding
|
||||||
|
// ^ intraPadding
|
||||||
|
// ^^^^^^^^ width
|
||||||
|
// ^ ^ fg/bg
|
||||||
|
//
|
||||||
|
const std::string Table::formatHeaderDashedUnderline (
|
||||||
|
int col,
|
||||||
|
int width,
|
||||||
|
int padding)
|
||||||
|
{
|
||||||
|
assert (width > 0);
|
||||||
|
|
||||||
|
Text::color fg = getHeaderFg (col);
|
||||||
|
Text::color bg = getHeaderBg (col);
|
||||||
|
Text::color decoration = getHeaderUnderline (col);
|
||||||
|
|
||||||
|
std::string data = "";
|
||||||
|
for (int i = 0; i < width; ++i)
|
||||||
|
data += '-';
|
||||||
|
|
||||||
|
std::string pad = "";
|
||||||
|
std::string intraPad = "";
|
||||||
|
std::string attrOn = "";
|
||||||
|
std::string attrOff = "";
|
||||||
|
|
||||||
|
for (int i = 0; i < padding; ++i)
|
||||||
|
pad += " ";
|
||||||
|
|
||||||
|
// Place the value within the available space - justify.
|
||||||
|
if (col < (signed) mColumns.size () - 1)
|
||||||
|
for (int i = 0; i < getIntraPadding (); ++i)
|
||||||
|
intraPad += " ";
|
||||||
|
|
||||||
|
return Text::colorize (
|
||||||
|
fg, bg,
|
||||||
|
Text::colorize (
|
||||||
|
decoration, Text::nocolor,
|
||||||
|
pad + data + pad) + intraPad);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -861,13 +918,24 @@ const std::string Table::render ()
|
||||||
|
|
||||||
// Print column headers in column order.
|
// Print column headers in column order.
|
||||||
std::string output;
|
std::string output;
|
||||||
|
std::string underline;
|
||||||
for (size_t col = 0; col < mColumns.size (); ++col)
|
for (size_t col = 0; col < mColumns.size (); ++col)
|
||||||
|
{
|
||||||
output += formatHeader (
|
output += formatHeader (
|
||||||
col,
|
col,
|
||||||
mCalculatedWidth[col],
|
mCalculatedWidth[col],
|
||||||
mColumnPadding[col]);
|
mColumnPadding[col]);
|
||||||
|
|
||||||
|
if (mDashedUnderline)
|
||||||
|
underline += formatHeaderDashedUnderline (
|
||||||
|
col,
|
||||||
|
mCalculatedWidth[col],
|
||||||
|
mColumnPadding[col]);
|
||||||
|
}
|
||||||
|
|
||||||
output += "\n";
|
output += "\n";
|
||||||
|
if (underline.length ())
|
||||||
|
output += underline + "\n";
|
||||||
|
|
||||||
// Determine row order, according to sort options.
|
// Determine row order, according to sort options.
|
||||||
std::vector <int> order;
|
std::vector <int> order;
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
void setTablePadding (int);
|
void setTablePadding (int);
|
||||||
void setTableIntraPadding (int);
|
void setTableIntraPadding (int);
|
||||||
void setTableWidth (int);
|
void setTableWidth (int);
|
||||||
|
void setTableDashedUnderline ();
|
||||||
|
|
||||||
int addColumn (const std::string&);
|
int addColumn (const std::string&);
|
||||||
void setColumnColor (int, Text::color, Text::color);
|
void setColumnColor (int, Text::color, Text::color);
|
||||||
|
@ -98,6 +99,7 @@ private:
|
||||||
just getJustification (const int, const int);
|
just getJustification (const int, const int);
|
||||||
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);
|
||||||
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, std::vector <std::string>&, std::string&);
|
||||||
void optimize (std::string&);
|
void optimize (std::string&);
|
||||||
void sort (std::vector <int>&);
|
void sort (std::vector <int>&);
|
||||||
|
@ -110,6 +112,7 @@ private:
|
||||||
std::map <std::string, std::string> mFg;
|
std::map <std::string, std::string> mFg;
|
||||||
std::map <std::string, std::string> mBg;
|
std::map <std::string, std::string> mBg;
|
||||||
std::map <std::string, std::string> mUnderline;
|
std::map <std::string, std::string> mUnderline;
|
||||||
|
bool mDashedUnderline;
|
||||||
|
|
||||||
// Padding...
|
// Padding...
|
||||||
int mTablePadding;
|
int mTablePadding;
|
||||||
|
|
|
@ -143,7 +143,7 @@ void handleList (TDB& tdb, T& task, Config& conf)
|
||||||
if (showAge) table.addColumn ("Age");
|
if (showAge) table.addColumn ("Age");
|
||||||
table.addColumn ("Description");
|
table.addColumn ("Description");
|
||||||
|
|
||||||
if (conf.get ("color", true))
|
if (conf.get (std::string ("color"), true))
|
||||||
{
|
{
|
||||||
table.setColumnUnderline (0);
|
table.setColumnUnderline (0);
|
||||||
table.setColumnUnderline (1);
|
table.setColumnUnderline (1);
|
||||||
|
@ -153,6 +153,8 @@ void handleList (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (5);
|
table.setColumnUnderline (5);
|
||||||
if (showAge) table.setColumnUnderline (6);
|
if (showAge) table.setColumnUnderline (6);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
@ -291,6 +293,8 @@ void handleSmallList (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (2);
|
table.setColumnUnderline (2);
|
||||||
table.setColumnUnderline (3);
|
table.setColumnUnderline (3);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
@ -414,6 +418,8 @@ void handleCompleted (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (1);
|
table.setColumnUnderline (1);
|
||||||
table.setColumnUnderline (2);
|
table.setColumnUnderline (2);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
@ -493,6 +499,8 @@ void handleInfo (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (0);
|
table.setColumnUnderline (0);
|
||||||
table.setColumnUnderline (1);
|
table.setColumnUnderline (1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
@ -710,6 +718,8 @@ void handleLongList (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (7);
|
table.setColumnUnderline (7);
|
||||||
if (showAge) table.setColumnUnderline (8);
|
if (showAge) table.setColumnUnderline (8);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
@ -913,6 +923,8 @@ void handleReportSummary (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (2);
|
table.setColumnUnderline (2);
|
||||||
table.setColumnUnderline (3);
|
table.setColumnUnderline (3);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnJustification (1, Table::right);
|
table.setColumnJustification (1, Table::right);
|
||||||
table.setColumnJustification (2, Table::right);
|
table.setColumnJustification (2, Table::right);
|
||||||
|
@ -1056,6 +1068,8 @@ void handleReportNext (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (5);
|
table.setColumnUnderline (5);
|
||||||
if (showAge) table.setColumnUnderline (6);
|
if (showAge) table.setColumnUnderline (6);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
@ -1275,6 +1289,8 @@ void handleReportHistory (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (4);
|
table.setColumnUnderline (4);
|
||||||
table.setColumnUnderline (5);
|
table.setColumnUnderline (5);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnJustification (2, Table::right);
|
table.setColumnJustification (2, Table::right);
|
||||||
table.setColumnJustification (3, Table::right);
|
table.setColumnJustification (3, Table::right);
|
||||||
|
@ -1462,6 +1478,8 @@ void handleReportGHistory (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (0);
|
table.setColumnUnderline (0);
|
||||||
table.setColumnUnderline (1);
|
table.setColumnUnderline (1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
// Determine the longest line.
|
// Determine the longest line.
|
||||||
int maxLine = 0;
|
int maxLine = 0;
|
||||||
|
@ -1623,6 +1641,8 @@ void handleReportUsage (const TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (0);
|
table.setColumnUnderline (0);
|
||||||
table.setColumnUnderline (1);
|
table.setColumnUnderline (1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnJustification (1, Table::right);
|
table.setColumnJustification (1, Table::right);
|
||||||
table.sortOn (1, Table::descendingNumeric);
|
table.sortOn (1, Table::descendingNumeric);
|
||||||
|
@ -1681,6 +1701,8 @@ std::string renderMonths (
|
||||||
table.setColumnUnderline (i + 6);
|
table.setColumnUnderline (i + 6);
|
||||||
table.setColumnUnderline (i + 7);
|
table.setColumnUnderline (i + 7);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnJustification (i + 0, Table::right);
|
table.setColumnJustification (i + 0, Table::right);
|
||||||
table.setColumnJustification (i + 1, Table::right);
|
table.setColumnJustification (i + 1, Table::right);
|
||||||
|
@ -1896,6 +1918,8 @@ void handleReportActive (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (3);
|
table.setColumnUnderline (3);
|
||||||
table.setColumnUnderline (4);
|
table.setColumnUnderline (4);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
@ -2011,6 +2035,8 @@ void handleReportOverdue (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (3);
|
table.setColumnUnderline (3);
|
||||||
table.setColumnUnderline (4);
|
table.setColumnUnderline (4);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
@ -2126,6 +2152,8 @@ void handleReportOldest (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (5);
|
table.setColumnUnderline (5);
|
||||||
if (showAge) table.setColumnUnderline (6);
|
if (showAge) table.setColumnUnderline (6);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
@ -2269,6 +2297,8 @@ void handleReportNewest (TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnUnderline (5);
|
table.setColumnUnderline (5);
|
||||||
if (showAge) table.setColumnUnderline (6);
|
if (showAge) table.setColumnUnderline (6);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
table.setTableDashedUnderline ();
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue