mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
ColDescription: Minimized use of wrapText
- This is a high-use measure/render method pair, and needs to be quick.
This commit is contained in:
parent
fa035c3fde
commit
31f0804207
1 changed files with 17 additions and 22 deletions
|
@ -174,12 +174,12 @@ void ColumnDescription::render (
|
|||
// ...
|
||||
if (_style == "default" ||
|
||||
_style == "combined")
|
||||
{
|
||||
if (task.annotation_count)
|
||||
{
|
||||
std::map <std::string, std::string> annos;
|
||||
task.getAnnotations (annos);
|
||||
if (annos.size ())
|
||||
{
|
||||
for (auto& i : annos)
|
||||
for (const auto& i : annos)
|
||||
{
|
||||
ISO8601d dt (strtol (i.first.substr (11).c_str (), NULL, 10));
|
||||
description += "\n" + std::string (_indent, ' ') + dt.toString (_dateformat) + " " + i.second;
|
||||
|
@ -189,7 +189,7 @@ void ColumnDescription::render (
|
|||
std::vector <std::string> raw;
|
||||
wrapText (raw, description, width, _hyphenate);
|
||||
|
||||
for (auto& i : raw)
|
||||
for (const auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
}
|
||||
|
||||
|
@ -199,18 +199,18 @@ void ColumnDescription::render (
|
|||
std::vector <std::string> raw;
|
||||
wrapText (raw, description, width, _hyphenate);
|
||||
|
||||
for (auto& i : raw)
|
||||
for (const auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
}
|
||||
|
||||
// This is a description <date> <anno> ...
|
||||
else if (_style == "oneline")
|
||||
{
|
||||
if (task.annotation_count)
|
||||
{
|
||||
std::map <std::string, std::string> annos;
|
||||
task.getAnnotations (annos);
|
||||
if (annos.size ())
|
||||
{
|
||||
for (auto& i : annos)
|
||||
for (const auto& i : annos)
|
||||
{
|
||||
ISO8601d dt (strtol (i.first.substr (11).c_str (), NULL, 10));
|
||||
description += " " + dt.toString (_dateformat) + " " + i.second;
|
||||
|
@ -220,7 +220,7 @@ void ColumnDescription::render (
|
|||
std::vector <std::string> raw;
|
||||
wrapText (raw, description, width, _hyphenate);
|
||||
|
||||
for (auto& i : raw)
|
||||
for (const auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
}
|
||||
|
||||
|
@ -237,31 +237,26 @@ void ColumnDescription::render (
|
|||
// This is a description [2]
|
||||
else if (_style == "count")
|
||||
{
|
||||
std::map <std::string, std::string> annos;
|
||||
task.getAnnotations (annos);
|
||||
|
||||
if (annos.size ())
|
||||
description += " [" + format ((int) annos.size ()) + "]";
|
||||
if (task.annotation_count)
|
||||
description += " [" + format (task.annotation_count) + "]";
|
||||
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, description, width, _hyphenate);
|
||||
|
||||
for (auto& i : raw)
|
||||
for (const auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
}
|
||||
|
||||
// This is a des... [2]
|
||||
else if (_style == "truncated_count")
|
||||
{
|
||||
std::map <std::string, std::string> annos;
|
||||
task.getAnnotations (annos);
|
||||
int len = utf8_width (description);
|
||||
|
||||
std::string annos_count;
|
||||
int len_annos = 0;
|
||||
|
||||
if (annos.size ())
|
||||
if (task.annotation_count)
|
||||
{
|
||||
annos_count = " [" + format ((int) annos.size ()) + "]";
|
||||
annos_count = " [" + format (task.annotation_count) + "]";
|
||||
len_annos = utf8_width (annos_count);
|
||||
len += len_annos;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue