mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
View
- Implemented new string formats: left_fixed and right_fixed, which do not word-wrap. This is used for the history report.
This commit is contained in:
parent
291818c33d
commit
4f8c503a04
2 changed files with 17 additions and 7 deletions
|
@ -25,7 +25,6 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <iostream> // TODO Remove
|
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <ColString.h>
|
#include <ColString.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
@ -58,13 +57,17 @@ void ColumnString::setReport (const std::string& value)
|
||||||
//
|
//
|
||||||
void ColumnString::measure (const std::string& value, int& minimum, int& maximum)
|
void ColumnString::measure (const std::string& value, int& minimum, int& maximum)
|
||||||
{
|
{
|
||||||
std::string stripped = Color::strip (value);
|
|
||||||
maximum = stripped.length ();
|
|
||||||
|
|
||||||
if (_style == "left" ||
|
if (_style == "left" ||
|
||||||
_style == "right" ||
|
_style == "right" ||
|
||||||
_style == "default")
|
_style == "default")
|
||||||
|
{
|
||||||
|
std::string stripped = Color::strip (value);
|
||||||
|
maximum = stripped.length ();
|
||||||
minimum = longestWord (stripped);
|
minimum = longestWord (stripped);
|
||||||
|
}
|
||||||
|
else if (_style == "left_fixed" ||
|
||||||
|
_style == "right_fixed")
|
||||||
|
minimum = maximum = strippedLength (value);
|
||||||
else
|
else
|
||||||
throw std::string ("Unrecognized column format 'string.") + _style + "'";
|
throw std::string ("Unrecognized column format 'string.") + _style + "'";
|
||||||
}
|
}
|
||||||
|
@ -94,6 +97,14 @@ void ColumnString::render (
|
||||||
for (i = raw.begin (); i != raw.end (); ++i)
|
for (i = raw.begin (); i != raw.end (); ++i)
|
||||||
lines.push_back (color.colorize (rightJustify (*i, width)));
|
lines.push_back (color.colorize (rightJustify (*i, width)));
|
||||||
}
|
}
|
||||||
|
else if (_style == "left_fixed")
|
||||||
|
{
|
||||||
|
lines.push_back (leftJustify (value, width));
|
||||||
|
}
|
||||||
|
else if (_style == "right_fixed")
|
||||||
|
{
|
||||||
|
lines.push_back (rightJustify (value, width));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
@ -551,13 +550,13 @@ int handleReportGHistoryAnnual (std::string& outs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int widthOfBar = context.getWidth () - 5; // 5 == strlen ("2008 ")
|
int widthOfBar = context.getWidth () - 5; // 5 == strlen ("YYYY ")
|
||||||
|
|
||||||
// Now build the view.
|
// Now build the view.
|
||||||
ViewText view;
|
ViewText view;
|
||||||
view.width (context.getWidth ());
|
view.width (context.getWidth ());
|
||||||
view.add (Column::factory ("string", "Year"));
|
view.add (Column::factory ("string", "Year"));
|
||||||
view.add (Column::factory ("string", "Number Added/Completed/Deleted"));
|
view.add (Column::factory ("string.left_fixed", "Number Added/Completed/Deleted"));
|
||||||
|
|
||||||
Color color_add (context.config.get ("color.history.add"));
|
Color color_add (context.config.get ("color.history.add"));
|
||||||
Color color_done (context.config.get ("color.history.done"));
|
Color color_done (context.config.get ("color.history.done"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue