mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
View
- Implemented due.countdown. - Fixed formatting bug in description.truncated. - Fixed bug in start.indicator.
This commit is contained in:
parent
f9ab8f2a1c
commit
d0cbf43478
6 changed files with 69 additions and 13 deletions
|
@ -99,15 +99,6 @@ void ColumnDate::measure (Task& task, int& minimum, int& maximum)
|
|||
Date now;
|
||||
minimum = maximum = Duration (now - date).format ().length ();
|
||||
}
|
||||
else if (_style == "short")
|
||||
{
|
||||
}
|
||||
else if (_style == "countdown")
|
||||
{
|
||||
}
|
||||
else if (_style == "remaining")
|
||||
{
|
||||
}
|
||||
else
|
||||
throw std::string ("Unrecognized column format '") + _type + "." + _style + "'";
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ void ColumnDescription::render (
|
|||
{
|
||||
int len = description.length ();
|
||||
if (len > width)
|
||||
lines.push_back (color.colorize (description.substr (0, len - 3) + "..."));
|
||||
lines.push_back (color.colorize (description.substr (0, width - 3) + "..."));
|
||||
else
|
||||
lines.push_back (color.colorize (leftJustify (description, width)));
|
||||
}
|
||||
|
|
|
@ -25,7 +25,14 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
#include <ColDue.h>
|
||||
#include <Date.h>
|
||||
#include <Duration.h>
|
||||
#include <text.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnDue::ColumnDue ()
|
||||
|
@ -40,3 +47,57 @@ ColumnDue::~ColumnDue ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnDue::setStyle (const std::string& value)
|
||||
{
|
||||
_style = value;
|
||||
|
||||
if (_style == "countdown" && _label == "Due")
|
||||
_label = "Countdown";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnDue::measure (Task& task, int& minimum, int& maximum)
|
||||
{
|
||||
minimum = maximum = 0;
|
||||
|
||||
if (task.has (_attribute))
|
||||
{
|
||||
if (_style == "countdown")
|
||||
{
|
||||
Date date ((time_t) strtol (task.get (_attribute).c_str (), NULL, 10));
|
||||
Date now;
|
||||
minimum = maximum = Duration (now - date).format ().length ();
|
||||
}
|
||||
else
|
||||
ColumnDate::measure (task, minimum, maximum);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnDue::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_attribute))
|
||||
{
|
||||
if (_style == "countdown")
|
||||
{
|
||||
Date date ((time_t) strtol (task.get (_attribute).c_str (), NULL, 10));
|
||||
Date now;
|
||||
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (
|
||||
Duration (now - date).format (), width)));
|
||||
}
|
||||
else
|
||||
ColumnDate::render (lines, task, width, color);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -34,6 +34,10 @@ class ColumnDue : public ColumnDate
|
|||
public:
|
||||
ColumnDue ();
|
||||
~ColumnDue ();
|
||||
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -63,8 +63,7 @@ void ColumnStart::measure (Task& task, int& minimum, int& maximum)
|
|||
if (task.has (_attribute))
|
||||
{
|
||||
if (_style == "active")
|
||||
{
|
||||
}
|
||||
minimum = maximum = context.config.get ("active.indicator").length ();
|
||||
else
|
||||
ColumnDate::measure (task, minimum, maximum);
|
||||
}
|
||||
|
|
|
@ -104,7 +104,8 @@ int main (int argc, char** argv)
|
|||
// view.add (Column::factory ("status"));
|
||||
view.add (Column::factory ("status.short"));
|
||||
// view.add (Column::factory ("due"));
|
||||
view.add (Column::factory ("due.julian"));
|
||||
// view.add (Column::factory ("due.julian"));
|
||||
view.add (Column::factory ("due.countdown"));
|
||||
// view.add (Column::factory ("due.epoch"));
|
||||
// view.add (Column::factory ("due.iso"));
|
||||
view.add (Column::factory ("start.active"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue