- 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:
Paul Beckingham 2011-05-13 18:03:06 -04:00
parent 291818c33d
commit 4f8c503a04
2 changed files with 17 additions and 7 deletions

View file

@ -25,7 +25,6 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream> // TODO Remove
#include <Context.h>
#include <ColString.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)
{
std::string stripped = Color::strip (value);
maximum = stripped.length ();
if (_style == "left" ||
_style == "right" ||
_style == "default")
{
std::string stripped = Color::strip (value);
maximum = stripped.length ();
minimum = longestWord (stripped);
}
else if (_style == "left_fixed" ||
_style == "right_fixed")
minimum = maximum = strippedLength (value);
else
throw std::string ("Unrecognized column format 'string.") + _style + "'";
}
@ -94,6 +97,14 @@ void ColumnString::render (
for (i = raw.begin (); i != raw.end (); ++i)
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));
}
}
////////////////////////////////////////////////////////////////////////////////