Merge branch '2.2.0' of tasktools.org:task into 2.2.0

This commit is contained in:
Paul Beckingham 2012-12-03 07:45:41 -05:00
commit d89ee4d19c
18 changed files with 350 additions and 69 deletions

View file

@ -211,6 +211,7 @@ std::string Config::_defaults =
"color.blocking=white on color6 # Color of blocking tasks\n"
"#color.completed=on blue # Color of completed tasks\n"
"#color.deleted=on blue # Color of deleted tasks\n"
"#color.uda.estimate=on green # Color of UDA\n"
#else
"color.header=yellow # Color of header messages\n"
"color.footnote=yellow # Color of footnote messages\n"
@ -265,12 +266,13 @@ std::string Config::_defaults =
"color.blocking=black on bright white # Color of blocking tasks\n"
"#color.completed=on blue # Color of completed tasks\n"
"#color.deleted=on blue # Color of deleted tasks\n"
"#color.uda.estimate=on green # Color of UDA\n"
#endif
"\n"
"# Here is the rule precedence order, highest to lowest.\n"
"# Note that these are just the color rule names, without the leading 'color.'\n"
"# and any trailing '.value'.\n"
"rule.precedence.color=due.today,active,blocking,blocked,overdue,due,scheduled,keyword.,project.,tag.,recurring,pri.,tagged,completed,deleted\n"
"rule.precedence.color=due.today,active,blocking,blocked,overdue,due,scheduled,keyword.,project.,tag.,uda.,recurring,pri.,tagged,completed,deleted\n"
"\n"
"# Shadow file support\n"
"#shadow.file=/tmp/shadow.txt # Location of shadow file\n"

View file

@ -56,12 +56,14 @@ static const char* relatives[] =
"eow",
"eoww",
"eocw",
"eocm",
"eom",
"eoq",
"eoy",
"sow",
"soww",
"socw",
"socm",
"som",
"soq",
"soy",
@ -828,7 +830,8 @@ bool Date::isRelativeDate (const std::string& input)
found == "eocw" ||
found == "sow" ||
found == "soww" ||
found == "socw")
found == "socw" ||
found == "socm")
{
if (found == "eow" || found == "eoww")
dow = 5;
@ -847,6 +850,9 @@ bool Date::isRelativeDate (const std::string& input)
else
today += (dow - today.dayOfWeek ()) * 86400;
if (found == "socm")
today -= (today.day () - 1) * 86400;
int m, d, y;
today.toMDY (m, d, y);
Date then (m, d, y);
@ -878,7 +884,7 @@ bool Date::isRelativeDate (const std::string& input)
_t = then._t - 86400;
return true;
}
else if (found == "eom")
else if (found == "eom" || found == "eocm")
{
Date then (today.month (),
daysInMonth (today.month (), today.year ()),

View file

@ -1576,26 +1576,37 @@ void TDB2::revert ()
{
context.debug ("TDB::undo - task found in completed.data");
// If task now belongs back in pending.data
if (prior.find ("status:\"pending\"") != std::string::npos ||
prior.find ("status:\"waiting\"") != std::string::npos ||
prior.find ("status:\"recurring\"") != std::string::npos)
// Either revert if there was a prior state, or remove the task.
if (prior != "")
{
c.erase (task);
p.push_back (prior);
File::write (completed._file._data, c);
File::write (pending._file._data, p);
File::write (undo._file._data, u);
std::cout << STRING_TDB2_REVERTED << "\n";
context.debug ("TDB::undo - task belongs in pending.data");
*task = prior;
if (task->find ("status:\"pending\"") != std::string::npos ||
task->find ("status:\"waiting\"") != std::string::npos ||
task->find ("status:\"recurring\"") != std::string::npos)
{
c.erase (task);
p.push_back (prior);
File::write (completed._file._data, c);
File::write (pending._file._data, p);
File::write (undo._file._data, u);
std::cout << STRING_TDB2_REVERTED << "\n";
context.debug ("TDB::undo - task belongs in pending.data");
}
else
{
File::write (completed._file._data, c);
File::write (undo._file._data, u);
std::cout << STRING_TDB2_REVERTED << "\n";
context.debug ("TDB::undo - task belongs in completed.data");
}
}
else
{
*task = prior;
c.erase (task);
File::write (completed._file._data, c);
File::write (undo._file._data, u);
std::cout << STRING_TDB2_REVERTED << "\n";
context.debug ("TDB::undo - task belongs in completed.data");
context.debug ("TDB::undo - task removed");
}
std::cout << STRING_TDB2_UNDO_COMPLETE << "\n";

View file

@ -42,7 +42,7 @@ extern Context context;
CmdColumns::CmdColumns ()
{
_keyword = "columns";
_usage = "task columns";
_usage = "task columns [substring]";
_description = STRING_CMD_COLUMNS_USAGE;
_read_only = true;
_displays_id = false;
@ -51,6 +51,12 @@ CmdColumns::CmdColumns ()
////////////////////////////////////////////////////////////////////////////////
int CmdColumns::execute (std::string& output)
{
// Obtain the arguments from the description. That way, things like '--'
// have already been handled.
std::vector <std::string> words = context.a3.extract_words ();
if (words.size () > 1)
throw std::string (STRING_CMD_COLUMNS_ARGS);
// Include all columns in the table.
std::vector <std::string> names;
std::map <std::string, Column*>::const_iterator col;
@ -73,15 +79,19 @@ int CmdColumns::execute (std::string& output)
std::vector <std::string>::iterator name;
for (name = names.begin (); name != names.end (); ++name)
{
const std::vector <std::string> styles = context.columns[*name]->styles ();
const std::vector <std::string> examples = context.columns[*name]->examples ();
for (unsigned int i = 0; i < styles.size (); ++i)
if (words.size () == 0 ||
find (*name, words[0], false) != std::string::npos)
{
int row = formats.addRow ();
formats.set (row, 0, i == 0 ? *name : "");
formats.set (row, 1, styles[i] + (i == 0 ? "*" : ""));
formats.set (row, 2, i < examples.size () ? examples[i] : "");
const std::vector <std::string> styles = context.columns[*name]->styles ();
const std::vector <std::string> examples = context.columns[*name]->examples ();
for (unsigned int i = 0; i < styles.size (); ++i)
{
int row = formats.addRow ();
formats.set (row, 0, i == 0 ? *name : "");
formats.set (row, 1, styles[i] + (i == 0 ? "*" : ""));
formats.set (row, 2, i < examples.size () ? examples[i] : "");
}
}
}

View file

@ -229,6 +229,7 @@ int CmdShow::execute (std::string& output)
if (i->substr (0, 14) != "color.keyword." &&
i->substr (0, 14) != "color.project." &&
i->substr (0, 10) != "color.tag." &&
i->substr (0, 10) != "color.uda." &&
i->substr (0, 8) != "holiday." &&
i->substr (0, 7) != "report." &&
i->substr (0, 6) != "alias." &&

View file

@ -388,6 +388,7 @@
#define STRING_CMD_COLUMNS_USAGE "All supported columns and formatting styles"
#define STRING_CMD_COLUMNS_NOTE "* Means default format, and therefore optional. For example, 'due' and 'due.formatted' are equivalent."
#define STRING_CMD_COLUMNS_USAGE2 "Displays only a list of supported columns"
#define STRING_CMD_COLUMNS_ARGS "You can only specify one search string."
#define STRING_CMD_DENO_USAGE "Deletes an annotation"
#define STRING_CMD_DENO_WORDS "An annotation pattern must be provided."
@ -550,6 +551,7 @@
// Date
#define STRING_DATE_INVALID_FORMAT "'{1}' is not a valid date in the '{2}' format."
#define STRING_DATE_BAD_WEEKSTART "The 'weekstart' configuration variable may only contain 'Sunday' or 'Monday'."
#define STRING_DATE_TOO_MUCH "The date is too far into the future."
#define STRING_DATE_JANUARY_LONG "january"
#define STRING_DATE_FEBRUARY_LONG "february"

View file

@ -398,8 +398,8 @@
#define STRING_CMD_COLUMNS_USAGE "Todas las columnas y estilos de formato soportados"
#define STRING_CMD_COLUMNS_NOTE "* Significa formato por defecto, y por lo tanto opcional. Por ejemplo 'due' y 'due.formatted' son equivalentes."
#define STRING_CMD_COLUMNS_USAGE2 "Muestra una lista de columnas (solo nombres) soportadas"
#define STRING_CMD_COLUMNS_ARGS "Solo puede especificar un término de búsqueda."
#define STRING_CMD_DENO_USAGE "Elimina una anotación"
#define STRING_CMD_DENO_WORDS "Se debe proporcionar un patrón de anotación."
@ -565,6 +565,7 @@
// Date
#define STRING_DATE_INVALID_FORMAT "'{1}' no es una fecha válida según el formato '{2}'."
#define STRING_DATE_BAD_WEEKSTART "La variable de configuración 'weekstart' solamente puede contener 'Sunday' (domingo) o 'Monday' (lunes)."
#define STRING_DATE_TOO_MUCH "The date is too far into the future."
#define STRING_DATE_JANUARY_LONG "enero"
#define STRING_DATE_FEBRUARY_LONG "febrero"

View file

@ -211,6 +211,13 @@ static void colorizeKeyword (Task& task, const std::string& rule, const Color& b
}
}
////////////////////////////////////////////////////////////////////////////////
static void colorizeUDA (Task& task, const std::string& rule, const Color& base, Color& c)
{
if (task.has (rule.substr (10)))
c.blend (base);
}
////////////////////////////////////////////////////////////////////////////////
static void colorizeDue (Task& task, const Color& base, Color& c)
{
@ -313,6 +320,7 @@ void autoColorize (Task& task, Color& c)
else if (r->substr (0, 10) == "color.tag.") colorizeTag (task, *r, base, c);
else if (r->substr (0, 14) == "color.project.") colorizeProject (task, *r, base, c);
else if (r->substr (0, 14) == "color.keyword.") colorizeKeyword (task, *r, base, c);
else if (r->substr (0, 10) == "color.uda.") colorizeUDA (task, *r, base, c);
}
}
}