mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
View
- Integrated new longestWord helper function.
This commit is contained in:
parent
1d0ad3838b
commit
9268e552d8
2 changed files with 6 additions and 31 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <ColDescription.h>
|
#include <ColDescription.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
|
||||||
format = context.config.get ("dateformat");
|
format = context.config.get ("dateformat");
|
||||||
|
|
||||||
minimum = Date::length (format);
|
minimum = Date::length (format);
|
||||||
|
minimum = longestWord (description);
|
||||||
maximum = description.length ();
|
maximum = description.length ();
|
||||||
|
|
||||||
std::vector <Att> annos;
|
std::vector <Att> annos;
|
||||||
|
@ -77,16 +79,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
|
||||||
else if (_style == "desc")
|
else if (_style == "desc")
|
||||||
{
|
{
|
||||||
maximum = description.length ();
|
maximum = description.length ();
|
||||||
minimum = 0;
|
minimum = longestWord (description);
|
||||||
|
|
||||||
Nibbler nibbler (description);
|
|
||||||
std::string word;
|
|
||||||
while (nibbler.getUntilWS (word))
|
|
||||||
{
|
|
||||||
nibbler.skipWS ();
|
|
||||||
if (word.length () > minimum)
|
|
||||||
minimum = word.length ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The text <date> <anno> ...
|
// The text <date> <anno> ...
|
||||||
|
@ -96,7 +89,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
|
||||||
if (format == "")
|
if (format == "")
|
||||||
format = context.config.get ("dateformat");
|
format = context.config.get ("dateformat");
|
||||||
|
|
||||||
minimum = Date::length (format);
|
minimum = max (Date::length (format), longestWord (description));
|
||||||
maximum = description.length ();
|
maximum = description.length ();
|
||||||
|
|
||||||
std::vector <Att> annos;
|
std::vector <Att> annos;
|
||||||
|
@ -121,16 +114,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
|
||||||
|
|
||||||
// <description> + ' ' + '[' + <count> + ']'
|
// <description> + ' ' + '[' + <count> + ']'
|
||||||
maximum = description.length () + 3 + format ((int)annos.size ()).length ();
|
maximum = description.length () + 3 + format ((int)annos.size ()).length ();
|
||||||
minimum = 0;
|
minimum = longestWord (description);
|
||||||
|
|
||||||
Nibbler nibbler (description);
|
|
||||||
std::string word;
|
|
||||||
while (nibbler.getUntilWS (word))
|
|
||||||
{
|
|
||||||
nibbler.skipWS ();
|
|
||||||
if (word.length () > minimum)
|
|
||||||
minimum = word.length ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -60,17 +60,8 @@ void ColumnProject::measure (Task& task, int& minimum, int& maximum)
|
||||||
else if (_style != "default")
|
else if (_style != "default")
|
||||||
throw std::string ("Unrecognized column format '") + _type + "." + _style + "'";
|
throw std::string ("Unrecognized column format '") + _type + "." + _style + "'";
|
||||||
|
|
||||||
minimum = 0;
|
minimum = longestWord (project);
|
||||||
maximum = project.length ();
|
maximum = project.length ();
|
||||||
|
|
||||||
Nibbler nibbler (project);
|
|
||||||
std::string word;
|
|
||||||
while (nibbler.getUntilWS (word))
|
|
||||||
{
|
|
||||||
nibbler.skipWS ();
|
|
||||||
if (word.length () > minimum)
|
|
||||||
minimum = word.length ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue