mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-06 08:27:25 +02:00
ViewTask
- 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:
parent
32566c9844
commit
9c2aea6d62
2 changed files with 53 additions and 32 deletions
|
@ -307,6 +307,25 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
||||||
max_lines = cells[c].size ();
|
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)
|
for (unsigned int i = 0; i < max_lines; ++i)
|
||||||
{
|
{
|
||||||
out += left_margin + (odd ? extra_odd : extra_even);
|
out += left_margin + (odd ? extra_odd : extra_even);
|
||||||
|
|
|
@ -40,43 +40,45 @@ public:
|
||||||
~ViewTask ();
|
~ViewTask ();
|
||||||
|
|
||||||
// View specifications.
|
// View specifications.
|
||||||
void add (Column* column) { _columns.push_back (column); }
|
void add (Column* column) { _columns.push_back (column); }
|
||||||
void width (int width) { _width = width; }
|
void width (int width) { _width = width; }
|
||||||
void leftMargin (int margin) { _left_margin = margin; }
|
void leftMargin (int margin) { _left_margin = margin; }
|
||||||
void colorHeader (Color& c) { _header = c; }
|
void colorHeader (Color& c) { _header = c; }
|
||||||
void colorOdd (Color& c) { _odd = c; }
|
void colorOdd (Color& c) { _odd = c; }
|
||||||
void colorEven (Color& c) { _even = c; }
|
void colorEven (Color& c) { _even = c; }
|
||||||
void intraPadding (int padding) { _intra_padding = padding; }
|
void intraPadding (int padding) { _intra_padding = padding; }
|
||||||
void intraColorOdd (Color& c) { _intra_odd = c; }
|
void intraColorOdd (Color& c) { _intra_odd = c; }
|
||||||
void intraColorEven (Color& c) { _intra_even = c; }
|
void intraColorEven (Color& c) { _intra_even = c; }
|
||||||
void extraPadding (int padding) { _extra_padding = padding; }
|
void extraPadding (int padding) { _extra_padding = padding; }
|
||||||
void extraColorOdd (Color& c) { _extra_odd = c; }
|
void extraColorOdd (Color& c) { _extra_odd = c; }
|
||||||
void extraColorEven (Color& c) { _extra_even = c; }
|
void extraColorEven (Color& c) { _extra_even = c; }
|
||||||
void truncateLines (int n) { _truncate_lines = n; }
|
void truncateLines (int n) { _truncate_lines = n; }
|
||||||
void truncateRows (int n) { _truncate_rows = n; }
|
void truncateRows (int n) { _truncate_rows = n; }
|
||||||
int lines () { return _lines; }
|
void addBreak (const std::string& attr) { _breaks.push_back (attr); }
|
||||||
int rows () { return _rows; }
|
int lines () { return _lines; }
|
||||||
|
int rows () { return _rows; }
|
||||||
|
|
||||||
// View rendering.
|
// View rendering.
|
||||||
std::string render (std::vector <Task>&, std::vector <int>&);
|
std::string render (std::vector <Task>&, std::vector <int>&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector <Column*> _columns;
|
std::vector <Column*> _columns;
|
||||||
int _width;
|
std::vector <std::string> _breaks;
|
||||||
int _left_margin;
|
int _width;
|
||||||
Color _header;
|
int _left_margin;
|
||||||
Color _odd;
|
Color _header;
|
||||||
Color _even;
|
Color _odd;
|
||||||
int _intra_padding;
|
Color _even;
|
||||||
Color _intra_odd;
|
int _intra_padding;
|
||||||
Color _intra_even;
|
Color _intra_odd;
|
||||||
int _extra_padding;
|
Color _intra_even;
|
||||||
Color _extra_odd;
|
int _extra_padding;
|
||||||
Color _extra_even;
|
Color _extra_odd;
|
||||||
int _truncate_lines;
|
Color _extra_even;
|
||||||
int _truncate_rows;
|
int _truncate_lines;
|
||||||
int _lines;
|
int _truncate_rows;
|
||||||
int _rows;
|
int _lines;
|
||||||
|
int _rows;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue