- When supplied with a vector of attribute names, can insert spacing into the
  rendered output when values change.  These we call listing breaks.
This commit is contained in:
Paul Beckingham 2014-07-10 21:34:17 -04:00
parent 32566c9844
commit 9c2aea6d62
2 changed files with 53 additions and 32 deletions

View file

@ -307,6 +307,25 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
max_lines = cells[c].size ();
}
// Listing breaks are simply blank lines inserted when a column value
// changes.
if (s > 0 &&
_breaks.size () > 0)
{
std::vector <std::string>::iterator b;
for (b = _breaks.begin (); b != _breaks.end (); ++b)
{
if (data[sequence[s - 1]].get (*b) != data[sequence[s]].get (*b))
{
out += "\n";
++_lines;
// Only want one \n, regardless of how many values change.
break;
}
}
}
for (unsigned int i = 0; i < max_lines; ++i)
{
out += left_margin + (odd ? extra_odd : extra_even);

View file

@ -54,6 +54,7 @@ public:
void extraColorEven (Color& c) { _extra_even = c; }
void truncateLines (int n) { _truncate_lines = n; }
void truncateRows (int n) { _truncate_rows = n; }
void addBreak (const std::string& attr) { _breaks.push_back (attr); }
int lines () { return _lines; }
int rows () { return _rows; }
@ -62,6 +63,7 @@ public:
private:
std::vector <Column*> _columns;
std::vector <std::string> _breaks;
int _width;
int _left_margin;
Color _header;