Merge branch 'master' into 2.3.0

Conflicts:
	AUTHORS
	CMakeLists.txt
	INSTALL
	NEWS
	cmake.h.in
	doc/man/task-faq.5.in
	package-config/osx/README
	scripts/utils/verify_l10n
	src/API.h
	src/Config.cpp
	src/Context.cpp
	src/DOM.cpp
	src/Hooks.cpp
	src/TransportShell.h
	src/commands/CmdDiagnostics.cpp
	src/commands/CmdShell.cpp
	src/commands/CmdVersion.cpp
	src/en-US.h
	src/shell/Readline.h
	src/wcwidth6.cpp
	test/CMakeLists.txt
	test/color.uda.t
	test/duration.t.cpp
	test/hook.on-launch.t
	test/template.t
	test/uuid.t
This commit is contained in:
Paul Beckingham
2013-04-07 17:51:24 -04:00
548 changed files with 13752 additions and 2435 deletions

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -97,7 +97,7 @@ static struct
{ "_hastag_", 9, 'b', 0, 'l'}, // +tag [Pseudo-op]
{ "_notag_", 9, 'b', 0, 'l'}, // -tag [Pseudo-op]
// { "-", 15, 'u', 1, 'r' }, // Unary minus
{ "-", 15, 'u', 1, 'r' }, // Unary minus
{ "*", 13, 'b', 1, 'l' }, // Multiplication
{ "/", 13, 'b', 1, 'l' }, // Division
// { "%", 13, 'b', 1, 'l' }, // Modulus

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -30,6 +30,7 @@ set (task_SRCS A3.cpp A3.h
TransportCurl.cpp TransportCurl.h
TransportRSYNC.cpp TransportRSYNC.h
TransportSSH.cpp TransportSSH.h
TransportShell.cpp TransportShell.h
Uri.cpp Uri.h
ViewTask.cpp ViewTask.h
ViewText.cpp ViewText.h

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -31,12 +31,10 @@
#include <fstream>
#include <sstream>
#include <algorithm>
#include <sys/types.h>
#include <sys/stat.h>
#include <inttypes.h>
#include <unistd.h>
#include <stdlib.h>
#include <pwd.h>
#include <Directory.h>
#include <Date.h>
#include <File.h>
@@ -114,7 +112,9 @@ std::string Config::_defaults =
"dateformat.info=Y-M-D H:N:S # Preferred display date format for information\n"
"dateformat.report= # Preferred display date format for reports\n"
"dateformat.annotation= # Preferred display date format for annotations\n"
"weekstart=Sunday # Sunday or Monday only\n"
"weekstart="
STRING_DATE_SUNDAY_LONG
" # Sunday or Monday only\n"
"displayweeknumber=yes # Show week numbers on calendar\n"
"due=7 # Task is considered due in 7 days\n"
"\n"
@@ -212,6 +212,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"
@@ -266,12 +267,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"
@@ -288,6 +290,7 @@ std::string Config::_defaults =
"complete.all.tags=no # Include old tag names in '_ags' command\n"
"list.all.projects=no # Include old project names in 'projects' command\n"
"list.all.tags=no # Include old tag names in 'tags' command\n"
"print.empty.columns=no # Print columns which have no data for any task\n"
"debug=no # Display diagnostics\n"
"extensions=off # Extension system master switch\n"
"fontunderline=yes # Uses underlines rather than -------\n"
@@ -312,103 +315,103 @@ std::string Config::_defaults =
"\n"
"report.long.description=Lists all pending tasks\n"
"report.long.columns=id,project,priority,entry,start,due,recur,due.countdown,entry.age,depends,tags,description\n"
"report.long.labels=ID,Project,Pri,Added,Started,Due,Recur,Countdown,Age,Deps,Tags,Description\n"
"report.long.labels=ID,Proj,Pri,Added,Started,Due,Recur,Countdown,Age,Deps,Tags,Description\n"
"report.long.sort=due+,priority-,project+\n"
"report.long.filter=status:pending\n"
"\n"
"report.list.description=Lists all pending tasks\n"
"report.list.columns=id,project,priority,due,start.active,entry.age,description\n"
"report.list.labels=ID,Project,Pri,Due,Active,Age,Description\n"
"report.list.labels=ID,Proj,Pri,Due,Active,Age,Description\n"
"report.list.sort=due+,priority-,start-,project+\n"
"report.list.filter=status:pending\n"
"\n"
"report.ls.description=Minimal listing of all pending tasks\n"
"report.ls.columns=id,project,priority,description\n"
"report.ls.labels=ID,Project,Pri,Description\n"
"report.ls.labels=ID,Proj,Pri,Description\n"
"report.ls.sort=priority-,project+\n"
"report.ls.filter=status:pending\n"
"\n"
"report.minimal.description=Minimal listing of all pending tasks\n"
"report.minimal.columns=id,project,description.truncated\n"
"report.minimal.labels=ID,Project,Description\n"
"report.minimal.labels=ID,Proj,Description\n"
"report.minimal.sort=project+,description+\n"
"report.minimal.filter=status:pending\n"
"\n"
"report.newest.description=Shows the newest tasks\n"
"report.newest.columns=id,project,priority,due,start.active,entry.age,description\n"
"report.newest.labels=ID,Project,Pri,Due,Active,Age,Description\n"
"report.newest.labels=ID,Proj,Pri,Due,Active,Age,Description\n"
"report.newest.sort=id-\n"
"report.newest.filter=status:pending limit:10\n"
"\n"
"report.oldest.description=Shows the oldest tasks\n"
"report.oldest.columns=id,project,priority,due,start.active,entry.age,description\n"
"report.oldest.labels=ID,Project,Pri,Due,Active,Age,Description\n"
"report.oldest.labels=ID,Proj,Pri,Due,Active,Age,Description\n"
"report.oldest.sort=id+\n"
"report.oldest.filter=status:pending limit:10\n"
"\n"
"report.overdue.description=Lists overdue tasks\n"
"report.overdue.columns=id,project,priority,due,start.active,entry.age,description\n"
"report.overdue.labels=ID,Project,Pri,Due,Active,Age,Description\n"
"report.overdue.labels=ID,Proj,Pri,Due,Active,Age,Description\n"
"report.overdue.sort=due+,priority-,start-,project+\n"
"report.overdue.filter=status:pending +OVERDUE\n"
"\n"
"report.active.description=Lists active tasks\n"
"report.active.columns=id,project,priority,due,start.active,entry.age,description\n"
"report.active.labels=ID,Project,Pri,Due,Active,Age,Description\n"
"report.active.labels=ID,Proj,Pri,Due,Active,Age,Description\n"
"report.active.sort=due+,priority-,project+\n"
"report.active.filter=status:pending start.any:\n"
"\n"
"report.completed.description=Lists completed tasks\n"
"report.completed.columns=end,project,priority,entry.age,description,uuid\n"
"report.completed.labels=Complete,Project,Pri,Age,Description,UUID\n"
"report.completed.labels=Complete,Proj,Pri,Age,Description,UUID\n"
"report.completed.sort=end+,priority-,project+\n"
"report.completed.filter=status:completed\n"
"\n"
"report.recurring.description=Lists recurring tasks\n"
"report.recurring.columns=id,project,priority,due,recur,start.active,entry.age,description\n"
"report.recurring.labels=ID,Project,Pri,Due,Recur,Active,Age,Description\n"
"report.recurring.labels=ID,Proj,Pri,Due,Recur,Active,Age,Description\n"
"report.recurring.sort=due+,priority-,start-,project+\n"
"report.recurring.filter=status:pending parent.any:\n"
"\n"
"report.waiting.description=Lists all waiting tasks\n"
"report.waiting.columns=id,project,priority,wait,entry.age,description\n"
"report.waiting.labels=ID,Project,Pri,Wait,Age,Description\n"
"report.waiting.labels=ID,Proj,Pri,Wait,Age,Description\n"
"report.waiting.sort=wait+,priority-,project+\n"
"report.waiting.filter=status:waiting\n"
"\n"
"report.all.description=Lists all pending and completed tasks\n"
"report.all.columns=id,status,project,priority,due,end,start.active,entry.age,description\n"
"report.all.labels=ID,Status,Project,Pri,Due,Completed,Active,Age,Description\n"
"report.all.labels=ID,Status,Proj,Pri,Due,Completed,Active,Age,Description\n"
"report.all.sort=entry+\n"
"report.all.filter=status.not:deleted\n"
"\n"
"report.next.description=Lists the most urgent tasks\n"
"report.next.columns=id,project,priority,due,start.active,entry.age,urgency,description\n"
"report.next.labels=ID,Project,Pri,Due,A,Age,Urgency,Description\n"
"report.next.labels=ID,Proj,Pri,Due,A,Age,Urg,Description\n"
"report.next.sort=urgency-,due+,priority-,start-,project+\n"
"report.next.filter=status:pending limit:page\n"
"\n"
"report.ready.description=Lists the most urgent tasks\n"
"report.ready.columns=id,project,priority,due,start.active,entry.age,urgency,description\n"
"report.ready.labels=ID,Project,Pri,Due,A,Age,Urgency,Description\n"
"report.ready.labels=ID,Proj,Pri,Due,A,Age,Urg,Description\n"
"report.ready.sort=urgency-,due+,priority-,start-,project+\n"
"report.ready.filter=status:pending limit:page wait.none: '(scheduled.none: or scheduled.before:now )'\n"
"\n"
"report.blocked.description=Lists all blocked tasks\n"
"report.blocked.columns=id,depends,project,priority,due,start.active,entry.age,description\n"
"report.blocked.labels=ID,Deps,Project,Pri,Due,Active,Age,Description\n"
"report.blocked.labels=ID,Deps,Proj,Pri,Due,Active,Age,Description\n"
"report.blocked.sort=due+,priority-,start-,project+\n"
"report.blocked.filter=status:pending +BLOCKED\n"
"\n"
"report.unblocked.description=Lists all unblocked tasks\n"
"report.unblocked.columns=id,depends,project,priority,due,start.active,entry.age,description\n"
"report.unblocked.labels=ID,Deps,Project,Pri,Due,Active,Age,Description\n"
"report.unblocked.labels=ID,Deps,Proj,Pri,Due,Active,Age,Description\n"
"report.unblocked.sort=due+,priority-,start-,project+\n"
"report.unblocked.filter=status:pending -BLOCKED\n"
"\n"
"report.blocking.description=Lists all blocking tasks\n"
"report.blocking.columns=id,depends,project,priority,due,start.active,entry.age,description\n"
"report.blocking.labels=ID,Deps,Project,Pri,Due,Active,Age,Description\n"
"report.blocking.labels=ID,Deps,Proj,Pri,Due,Active,Age,Description\n"
"report.blocking.sort=due+,priority-,start-,project+\n"
"report.blocking.filter=status:pending +BLOCKING\n"
"\n";

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006 - 2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006 - 2013, Paul Beckingham, Federico Hernandez.
// All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -32,7 +32,6 @@
#include <sstream>
#include <algorithm>
#include <assert.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -536,6 +535,7 @@ void Context::shadow ()
" rc.detection:off" + // No need to determine terminal size
" rc.color:off" + // Color off by default
" rc.gc:off " + // GC off, to reduce headaches
" rc.locking:off" + // No file locking
" rc:" + rcfile + " " + // Use specified rc file
command + // User specified command
" >" + // Capture
@@ -576,18 +576,8 @@ const std::vector <std::string> Context::getCommands () const
////////////////////////////////////////////////////////////////////////////////
void Context::assumeLocations ()
{
// Note that this pointer is deliberately not free()'d, even though valgrind
// complains about it. It is either not necessary, or forbidden, depending
// on OS.
// Set up default locations.
struct passwd* pw = getpwuid (getuid ());
if (!pw)
throw std::string (STRING_NO_HOME);
home_dir = pw->pw_dir;
rc_file = File (home_dir + "/.taskrc");
data_dir = Directory (home_dir + "/.task");
rc_file = File ("~/.taskrc");
data_dir = Directory ("~/.task");
}
////////////////////////////////////////////////////////////////////////////////
@@ -600,14 +590,14 @@ void Context::createDefaultConfig ()
!confirm (format (STRING_CONTEXT_CREATE_RC, home_dir, rc_file._data)))
throw std::string (STRING_CONTEXT_NEED_RC);
config.createDefaultRC (rc_file, data_dir);
config.createDefaultRC (rc_file, data_dir._original);
}
// Create data location, if necessary.
config.createDefaultData (data_dir);
// Create extension directory, if necessary.
/* TODO Enable this when the time is right, say for 2.1
/* TODO Enable this when the time is right, say for 2.4
if (! extension_dir.exists ())
extension_dir.create ();
*/
@@ -683,14 +673,14 @@ void Context::clear ()
// this output?'.
void Context::updateXtermTitle ()
{
if (config.getBoolean ("xterm.title"))
if (config.getBoolean ("xterm.title") && isatty (fileno (stdout)))
{
std::string command;
a3.find_command (command);
std::string title;
join (title, " ", a3.list ());
std::cout << "]0;task " << command << " " << title << "" << std::endl;
std::cout << "]0;task " << command << " " << title << "";
}
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -77,13 +77,6 @@ const std::vector <std::string> DOM::get_references () const
// system.os
const std::string DOM::get (const std::string& name)
{
// Cache test.
/*
std::map <std::string, std::string>::iterator hit = _cache.find (name);
if (hit != _cache.end ())
return hit->second;
*/
int len = name.length ();
Nibbler n (name);
@@ -91,17 +84,17 @@ const std::string DOM::get (const std::string& name)
if (len > 3 &&
name.substr (0, 3) == "rc.")
{
return /*_cache[name] =*/ context.config.get (name.substr (3));
return context.config.get (name.substr (3));
}
// context.*
else if (len > 8 &&
name.substr (0, 8) == "context.")
{
if (name == "context.program") return /*_cache[name] =*/ context.a3[0]._raw;
else if (name == "context.args") return /*_cache[name] =*/ context.a3.combine ();
else if (name == "context.width") return /*_cache[name] =*/ format (context.terminal_width);
else if (name == "context.height") return /*_cache[name] =*/ format (context.terminal_height);
if (name == "context.program") return context.a3[0]._raw;
else if (name == "context.args") return context.a3.combine ();
else if (name == "context.width") return format (context.terminal_width);
else if (name == "context.height") return format (context.terminal_height);
else throw format (STRING_DOM_UNREC, name);
}
@@ -113,28 +106,28 @@ const std::string DOM::get (const std::string& name)
{
// Taskwarrior version number.
if (name == "system.version")
return /*_cache[name] =*/ VERSION;
return VERSION;
// OS type.
else if (name == "system.os")
#if defined (DARWIN)
return /*_cache[name] =*/ "Darwin";
return "Darwin";
#elif defined (SOLARIS)
return /*_cache[name] =*/ "Solaris";
return "Solaris";
#elif defined (CYGWIN)
return /*_cache[name] =*/ "Cygwin";
return "Cygwin";
#elif defined (HAIKU)
return /*_cache[name] =*/ "Haiku";
return "Haiku";
#elif defined (OPENBSD)
return /*_cache[name] =*/ "OpenBSD";
return "OpenBSD";
#elif defined (FREEBSD)
return /*_cache[name] =*/ "FreeBSD";
return "FreeBSD";
#elif defined (NETBSD)
return /*_cache[name] =*/ "NetBSD";
return "NetBSD";
#elif defined (LINUX)
return /*_cache[name] =*/ "Linux";
return "Linux";
#else
return /*_cache[name] =*/ STRING_DOM_UNKNOWN;
return STRING_DOM_UNKNOWN;
#endif
else
@@ -142,7 +135,7 @@ const std::string DOM::get (const std::string& name)
}
// Pass-through.
return /*_cache[name] =*/ name;
return name;
}
////////////////////////////////////////////////////////////////////////////////
@@ -183,13 +176,6 @@ const std::string DOM::get (const std::string& name)
//
const std::string DOM::get (const std::string& name, const Task& task)
{
// Cache test.
/*
std::map <std::string, std::string>::iterator hit = _cache.find (name);
if (hit != _cache.end ())
return hit->second;
*/
Nibbler n (name);
int id;
std::string uuid;
@@ -253,7 +239,7 @@ void DOM::set (const std::string& name, const std::string& value)
if (len > 3 &&
name.substr (0, 3) == "rc.")
{
context.config.set (name.substr (3), /*_cache[name] =*/ value);
context.config.set (name.substr (3), value);
}
// Unrecognized --> error.

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -45,7 +45,6 @@ public:
void set (const std::string&, const std::string&);
private:
std::map <std::string, std::string> _cache;
};
#endif

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -56,12 +56,14 @@ static const char* relatives[] =
"eow",
"eoww",
"eocw",
"eocm",
"eom",
"eoq",
"eoy",
"sow",
"soww",
"socw",
"socm",
"som",
"soq",
"soy",
@@ -228,27 +230,27 @@ const std::string Date::toString (
int c = localFormat[i];
switch (c)
{
case 'm': sprintf (buffer, "%d", this->month ()); break;
case 'M': sprintf (buffer, "%02d", this->month ()); break;
case 'd': sprintf (buffer, "%d", this->day ()); break;
case 'D': sprintf (buffer, "%02d", this->day ()); break;
case 'y': sprintf (buffer, "%02d", this->year () % 100); break;
case 'Y': sprintf (buffer, "%d", this->year ()); break;
case 'a': sprintf (buffer, "%.3s", Date::dayName (dayOfWeek ()).c_str ()); break;
case 'A': sprintf (buffer, "%s", Date::dayName (dayOfWeek ()).c_str ()); break;
case 'b': sprintf (buffer, "%.3s", Date::monthName (month ()).c_str ()); break;
case 'B': sprintf (buffer, "%.9s", Date::monthName (month ()).c_str ()); break;
case 'v': sprintf (buffer, "%d", Date::weekOfYear (Date::dayOfWeek (context.config.get ("weekstart")))); break;
case 'V': sprintf (buffer, "%02d", Date::weekOfYear (Date::dayOfWeek (context.config.get ("weekstart")))); break;
case 'h': sprintf (buffer, "%d", this->hour ()); break;
case 'H': sprintf (buffer, "%02d", this->hour ()); break;
case 'n': sprintf (buffer, "%d", this->minute ()); break;
case 'N': sprintf (buffer, "%02d", this->minute ()); break;
case 's': sprintf (buffer, "%d", this->second ()); break;
case 'S': sprintf (buffer, "%02d", this->second ()); break;
case 'j': sprintf (buffer, "%d", this->dayOfYear ()); break;
case 'J': sprintf (buffer, "%03d", this->dayOfYear ()); break;
default: sprintf (buffer, "%c", c); break;
case 'm': sprintf (buffer, "%d", this->month ()); break;
case 'M': sprintf (buffer, "%02d", this->month ()); break;
case 'd': sprintf (buffer, "%d", this->day ()); break;
case 'D': sprintf (buffer, "%02d", this->day ()); break;
case 'y': sprintf (buffer, "%02d", this->year () % 100); break;
case 'Y': sprintf (buffer, "%d", this->year ()); break;
case 'a': sprintf (buffer, "%.3s", Date::dayName (dayOfWeek ()).c_str ()); break;
case 'A': sprintf (buffer, "%.10s", Date::dayName (dayOfWeek ()).c_str ()); break;
case 'b': sprintf (buffer, "%.3s", Date::monthName (month ()).c_str ()); break;
case 'B': sprintf (buffer, "%.10s", Date::monthName (month ()).c_str ()); break;
case 'v': sprintf (buffer, "%d", Date::weekOfYear (Date::dayOfWeek (context.config.get ("weekstart")))); break;
case 'V': sprintf (buffer, "%02d", Date::weekOfYear (Date::dayOfWeek (context.config.get ("weekstart")))); break;
case 'h': sprintf (buffer, "%d", this->hour ()); break;
case 'H': sprintf (buffer, "%02d", this->hour ()); break;
case 'n': sprintf (buffer, "%d", this->minute ()); break;
case 'N': sprintf (buffer, "%02d", this->minute ()); break;
case 's': sprintf (buffer, "%d", this->second ()); break;
case 'S': sprintf (buffer, "%02d", this->second ()); break;
case 'j': sprintf (buffer, "%d", this->dayOfYear ()); break;
case 'J': sprintf (buffer, "%03d", this->dayOfYear ()); break;
default: sprintf (buffer, "%c", c); break;
}
formatted += buffer;
@@ -525,16 +527,23 @@ int Date::length (const std::string& format)
case 'd':
case 'D':
case 'y':
case 'A':
case 'b':
case 'B':
case 'v':
case 'V':
case 'h':
case 'H':
case 'n':
case 'N':
case 'S': total += 2; break;
case 'a': total += 3; break;
case 'Y': total += 4; break;
case 's':
case 'S': total += 2; break;
case 'b':
case 'j':
case 'J':
case 'a': total += 3; break;
case 'Y': total += 4; break;
case 'A':
case 'B': total += 10; break;
// TODO This should be a calculated character width, not necessarily 1.
default: total += 1; break;
}
}
@@ -878,7 +887,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 ()),
@@ -901,6 +910,14 @@ bool Date::isRelativeDate (const std::string& input)
_t = then._t;
return true;
}
else if (found == "socm")
{
int m = today.month ();
int y = today.year ();
Date then (m, 1, y);
_t = then._t;
return true;
}
else if (found == "som")
{
int m = today.month () + 1;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -111,13 +111,14 @@ bool Directory::remove_directory (const std::string& dir)
#if defined (SOLARIS) || defined (HAIKU)
struct stat s;
stat ((dir + "/" + de->d_name).c_str (), &s);
lstat ((dir + "/" + de->d_name).c_str (), &s);
if (s.st_mode & S_IFDIR)
remove_directory (dir + "/" + de->d_name);
else
unlink ((dir + "/" + de->d_name).c_str ());
#else
if (de->d_type == DT_DIR)
if (de->d_type == DT_DIR ||
de->d_type == DT_UNKNOWN)
remove_directory (dir + "/" + de->d_name);
else
unlink ((dir + "/" + de->d_name).c_str ());

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -282,7 +282,7 @@ std::string Duration::formatCompact () const
else if (_secs >= 3600) sprintf (formatted, "%s%dh", (_negative ? "-" : ""), (int) (_secs / 3600));
else if (_secs >= 60) sprintf (formatted, "%s%dm", (_negative ? "-" : ""), (int) (_secs / 60));
else if (_secs >= 1) sprintf (formatted, "%s%ds", (_negative ? "-" : ""), (int) _secs);
else strcpy (formatted, "-");
else formatted[0] = '\0';
return std::string (formatted);
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -337,6 +337,32 @@ void E9::operator_lt (Arg& result, Arg& left, Arg& right)
: "false";
}
}
else if (left._type == Arg::type_duration ||
right._type == Arg::type_duration)
{
if (left._value == "" ||
right._value == "")
result._value = "false";
else
{
Duration left_duration (left._value);
Duration right_duration (right._value);
result._value = (left_duration < right_duration)
? "true"
: "false";
}
}
else if (left._type == Arg::type_number ||
right._type == Arg::type_number)
{
float left_number = strtof (left._value.c_str (), NULL);
float right_number = strtof (right._value.c_str (), NULL);
result._value = (left_number < right_number)
? "true"
: "false";
}
else
{
result._value = (left._value < right._value)
@@ -376,6 +402,32 @@ void E9::operator_lte (Arg& result, Arg& left, Arg& right)
: "false";
}
}
else if (left._type == Arg::type_duration ||
right._type == Arg::type_duration)
{
if (left._value == "" ||
right._value == "")
result._value = "false";
else
{
Duration left_duration (left._value);
Duration right_duration (right._value);
result._value = (left_duration <= right_duration)
? "true"
: "false";
}
}
else if (left._type == Arg::type_number ||
right._type == Arg::type_number)
{
float left_number = strtof (left._value.c_str (), NULL);
float right_number = strtof (right._value.c_str (), NULL);
result._value = (left_number <= right_number)
? "true"
: "false";
}
else
{
result._value = (left._value <= right._value)
@@ -415,6 +467,32 @@ void E9::operator_gte (Arg& result, Arg& left, Arg& right)
: "false";
}
}
else if (left._type == Arg::type_duration ||
right._type == Arg::type_duration)
{
if (left._value == "" ||
right._value == "")
result._value = "false";
else
{
Duration left_duration (left._value);
Duration right_duration (right._value);
result._value = (left_duration >= right_duration)
? "true"
: "false";
}
}
else if (left._type == Arg::type_number ||
right._type == Arg::type_number)
{
float left_number = strtof (left._value.c_str (), NULL);
float right_number = strtof (right._value.c_str (), NULL);
result._value = (left_number >= right_number)
? "true"
: "false";
}
else
{
result._value = (left._value >= right._value)
@@ -453,6 +531,32 @@ void E9::operator_gt (Arg& result, Arg& left, Arg& right)
: "false";
}
}
else if (left._type == Arg::type_duration ||
right._type == Arg::type_duration)
{
if (left._value == "" ||
right._value == "")
result._value = "false";
else
{
Duration left_duration (left._value);
Duration right_duration (right._value);
result._value = result._value = (left_duration > right_duration)
? "true"
: "false";
}
}
else if (left._type == Arg::type_number ||
right._type == Arg::type_number)
{
float left_number = strtof (left._value.c_str (), NULL);
float right_number = strtof (right._value.c_str (), NULL);
result._value = (left_number > right_number)
? "true"
: "false";
}
else
{
result._value = (left._value > right._value)
@@ -497,7 +601,7 @@ void E9::operator_equal (
// Bug 856.
//
// Special case for checking absent projects. Without the explicit "" check
// the right._value.lenghth() is used, which is 0, and therefore generates
// the right._value.length() is used, which is 0, and therefore generates
// a false match.
if (right._value == "")
{
@@ -533,6 +637,16 @@ void E9::operator_equal (
: "false";
}
// Case-insensitive comparison for status. Fixes #1110.
// Also priority, fixing #1154.
else if (left._raw == "status" ||
left._raw == "priority")
{
result._value = compare (left._value, right._value, false)
? "true"
: "false";
}
// Regular equality matching.
else
{

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -31,7 +31,9 @@
#include <glob.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
#include <Path.h>
#include <cmake.h>
@@ -52,12 +54,16 @@ Path::Path ()
Path::Path (const Path& other)
{
if (this != &other)
_data = other._data;
{
_original = other._original;
_data = other._data;
}
}
////////////////////////////////////////////////////////////////////////////////
Path::Path (const std::string& in)
{
_original = in;
_data = expand (in);
}
@@ -70,7 +76,10 @@ Path::~Path ()
Path& Path::operator= (const Path& other)
{
if (this != &other)
this->_data = other._data;
{
this->_original = other._original;
this->_data = other._data;
}
return *this;
}
@@ -170,6 +179,22 @@ bool Path::executable () const
return access (_data.c_str (), X_OK) ? false : true;
}
////////////////////////////////////////////////////////////////////////////////
bool Path::rename (const std::string& new_name)
{
std::string expanded = expand (new_name);
if (_data != expanded)
{
if (::rename (_data.c_str (), expanded.c_str ()) == 0)
{
_data = expanded;
return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
// ~ --> /home/user
// ~foo/x --> /home/foo/s
@@ -183,19 +208,22 @@ std::string Path::expand (const std::string& in)
if (tilde != std::string::npos)
{
struct passwd* pw = getpwuid (getuid ());
const char *home = getenv("HOME");
if (home == NULL)
{
struct passwd* pw = getpwuid (getuid ());
home = pw->pw_dir;
}
// Convert: ~ --> /home/user
if (copy.length () == 1)
{
copy = pw->pw_dir;
}
copy = home;
// Convert: ~/x --> /home/user/x
else if (copy.length () > tilde + 1 &&
copy[tilde + 1] == '/')
{
copy.replace (tilde, 1, pw->pw_dir);
copy.replace (tilde, 1, home);
}
// Convert: ~foo/x --> /home/foo/x

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -54,12 +54,14 @@ public:
bool readable () const;
bool writable () const;
bool executable () const;
bool rename (const std::string&);
// Statics
static std::string expand (const std::string&);
static std::vector<std::string> glob (const std::string&);
public:
std::string _original;
std::string _data;
};

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -216,7 +216,7 @@ void TF2::commit ()
if (_file.open ())
{
if (context.config.getBoolean ("locking"))
_file.lock ();
_file.waitForLock ();
// Write out all the added tasks.
std::vector <Task>::iterator task;
@@ -318,7 +318,7 @@ void TF2::load_tasks ()
_U2I[task.get ("uuid")] = task.id;
}
}
if (_auto_dep_scan)
dependency_scan ();
@@ -339,9 +339,10 @@ void TF2::load_lines ()
if (_file.open ())
{
if (context.config.getBoolean ("locking"))
_file.lock ();
_file.waitForLock ();
_file.read (_lines);
_file.close ();
_loaded_lines = true;
}
}
@@ -627,8 +628,9 @@ void readTaskmods (std::vector <std::string> &input,
std::vector <std::string>::iterator &start,
std::list<Taskmod> &list)
{
static int resourceID = 1;
std::string line;
Taskmod tmod_tmp;
Taskmod tmod_tmp(resourceID++);
DEBUG_STR ("reading taskmods from file: ");
@@ -675,7 +677,7 @@ void readTaskmods (std::vector <std::string> &input,
void TDB2::merge (const std::string& mergeFile)
{
///////////////////////////////////////
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
///////////////////////////////////////
// list of modifications that we want to add to the local database
@@ -726,26 +728,31 @@ void TDB2::merge (const std::string& mergeFile)
///////////////////////////////////////
// find the branch-off point:
// first lines are not equal => assuming mergeFile starts at a
// first mods are not equal => assuming mergeFile starts at a
// later point in time
if (lline.compare (rline) != 0)
{
// iterate in local file to find rline
for ( ; lit != l.end (); ++lit)
{
lline = *lit;
if (lline.compare (rline) == 0) {
std::vector<std::string>::const_iterator tmp_lit = lit;
std::vector<std::string>::const_iterator tmp_rit = rit;
tmp_lit++;
tmp_rit++;
// push the line to the new undo.data
undo_lines.push_back (lline + "\n");
// found first matching lines?
if (lline.compare (rline) == 0)
break;
int lookahead = 1;
if (tmp_lit->substr (0, 3) == "old") {
lookahead = 2;
}
while (lookahead--) {
if (tmp_lit->compare(*tmp_rit) != 0) {
break;
}
tmp_lit++;
tmp_rit++;
}
if (lookahead == -1) {
// at this point we know that the first lines are the same
undo_lines.push_back (lline + "\n");
}
}
else
{
undo_lines.push_back (lline + "\n");
}
// Add some color.
@@ -783,7 +790,7 @@ void TDB2::merge (const std::string& mergeFile)
if (!found)
{
// set iterators to r.end() or l.end() if they are point to the last line
// set iterators to r.end() or l.end() if they point to the last line
if (++rit != r.end())
--rit;
@@ -804,14 +811,14 @@ void TDB2::merge (const std::string& mergeFile)
std::set<std::string> uuid_new, uuid_left;
// 1. read taskmods out of the remaining lines
readTaskmods (l, lit, lmods);
readTaskmods (r, rit, rmods);
readTaskmods (l, lit, lmods);
// 2. move new uuids into mods
DEBUG_STR_PART ("adding new uuids (left) to skip list...");
// modifications on the left side are already in the database
// we just need them to merge conflicts, so we add new the mods for
// we just need them to merge conflicts, so we add the mods for
// new uuids to the skip-list 'uuid_left'
std::list<Taskmod>::iterator lmod_it;
for (lmod_it = lmods.begin (); lmod_it != lmods.end (); lmod_it++)
@@ -842,9 +849,27 @@ void TDB2::merge (const std::string& mergeFile)
std::list<Taskmod>::iterator current = rmod_it++;
Taskmod tmod = *current;
// new uuid?
if (tmod.isNew ())
if (uuid_left.find (tmod.getUuid ()) != uuid_left.end ())
{
// check whether the remote side has added a task with the same UUID
// this happens if it inserted a modification with an older timestamp
// into the undo.data and thereby moved the branch point to an earlier
// point in time. Normally this case will be solved by the merge logic,
// BUT if the UUID is considered new the merge logic will be skipped.
//
// This flaw resulted in a couple of duplication issues and bloated
// undo files (e.g. #1104).
//
// This is just a "hack" which discards all the modifications of the
// remote side to UUIDs that are considered new by both sides.
// There may be more issues with the algorithm; probably a redesign
// and proper encapsulation of the merge algorithm is due.
rmods.erase(current);
}
else if (tmod.isNew ())
{
// new uuid?
/*
// TODO Don't forget L10N.
std::cout << "Adding new remote task "
@@ -1217,8 +1242,8 @@ void TDB2::merge (const std::string& mergeFile)
// now we merge mods (new modifications from mergefile)
// with lmods (part of old undo.data)
lmods.sort(compareTaskmod);
mods.merge (lmods);
mods.merge (mods_history);
mods.merge (lmods, compareTaskmod);
mods.merge (mods_history, compareTaskmod);
// generate undo.data format
std::list<Taskmod>::iterator it;
@@ -1533,26 +1558,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

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -106,6 +106,7 @@ Task::Task ()
, recalc_urgency (true)
, is_blocked (false)
, is_blocking (false)
, annotation_count (0)
{
}
@@ -122,11 +123,12 @@ Task& Task::operator= (const Task& other)
{
std::map <std::string, std::string>::operator= (other);
id = other.id;
urgency_value = other.urgency_value;
recalc_urgency = other.recalc_urgency;
is_blocked = other.is_blocked;
is_blocking = other.is_blocking;
id = other.id;
urgency_value = other.urgency_value;
recalc_urgency = other.recalc_urgency;
is_blocked = other.is_blocked;
is_blocking = other.is_blocking;
annotation_count = other.annotation_count;
}
return *this;
@@ -156,6 +158,7 @@ Task::Task (const std::string& input)
recalc_urgency = true;
is_blocked = false;
is_blocking = false;
annotation_count = 0;
parse (input);
}
@@ -436,6 +439,9 @@ void Task::parse (const std::string& input)
value[value.length () - 1] == 'm')
value += 'o';
if (name.substr (0, 11) == "annotation_")
++annotation_count;
(*this)[name] = decode (json::decode (value));
}
@@ -611,6 +617,7 @@ void Task::legacyParse (const std::string& line)
std::string name = pair.substr (0, colon);
std::string value = pair.substr (colon + 2, pair.length () - colon - 3);
set ("annotation_" + name, value);
++annotation_count;
}
}
@@ -676,7 +683,6 @@ std::string Task::composeJSON (bool include_id /*= false*/) const
// First the non-annotations.
int attributes_written = 0;
int annotation_count = 0;
Task::const_iterator i;
for (i = this->begin (); i != this->end (); ++i)
{
@@ -685,15 +691,9 @@ std::string Task::composeJSON (bool include_id /*= false*/) const
Column* column = context.columns[i->first];
// Annotations are simply counted.
if (i->first.substr (0, 11) == "annotation_")
{
++annotation_count;
}
// Date fields are written as ISO 8601.
else if (column &&
column->type () == "date")
if (column &&
column->type () == "date")
{
Date d (i->second);
out << "\""
@@ -776,6 +776,12 @@ std::string Task::composeJSON (bool include_id /*= false*/) const
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
bool Task::hasAnnotations () const
{
return annotation_count ? true : false;
}
////////////////////////////////////////////////////////////////////////////////
void Task::getAnnotations (std::map <std::string, std::string>& annotations) const
{
@@ -797,6 +803,7 @@ void Task::setAnnotations (const std::map <std::string, std::string>& annotation
for (ci = annotations.begin (); ci != annotations.end (); ++ci)
this->insert (*ci);
annotation_count = annotations.size ();
recalc_urgency = true;
}
@@ -819,6 +826,7 @@ void Task::addAnnotation (const std::string& description)
while (has (key));
(*this)[key] = description;
++annotation_count;
recalc_urgency = true;
}
@@ -830,7 +838,10 @@ void Task::removeAnnotations ()
while (i != this->end ())
{
if (i->first.substr (0, 11) == "annotation_")
{
--annotation_count;
this->erase (i++);
}
else
i++;
}
@@ -955,20 +966,22 @@ bool Task::hasTag (const std::string& tag) const
if (tag == "DUETODAY") return is_duetoday ();
if (tag == "TODAY") return is_duetoday ();
if (tag == "OVERDUE") return is_overdue ();
if (tag == "ACTIVE") return has ("start");
if (tag == "SCHEDULED") return has ("scheduled");
if (tag == "CHILD") return has ("parent");
if (tag == "UNTIL") return has ("until");
if (tag == "WAITING") return has ("wait");
if (tag == "ANNOTATED") return hasAnnotations ();
/*
TODO YESTERDAY - due yesterday
TODO TOMORROW - due tomorrow
TODO WEEK - due this week
TODO MONTH - due this month
TODO YEAR - due this year
TODO ANNOTATED - has any annotations
TODO ACTIVE - is active
TODO READY - is ready
TODO SCHEDULED - is scheduled
TODO WAITING - is waiting
TODO CHILD - is a child
TODO PARENT - is a parent
TODO UNTIL - will expire
*/
// Concrete tags.
@@ -1545,12 +1558,9 @@ float Task::urgency_blocked () const
////////////////////////////////////////////////////////////////////////////////
float Task::urgency_annotations () const
{
std::map <std::string, std::string> annos;
getAnnotations (annos);
if (annos.size () >= 3) return 1.0;
else if (annos.size () == 2) return 0.9;
else if (annos.size () == 1) return 0.8;
if (annotation_count >= 3) return 1.0;
else if (annotation_count == 2) return 0.9;
else if (annotation_count == 1) return 0.8;
return 0.0;
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -62,6 +62,8 @@ public:
bool is_blocked;
bool is_blocking;
int annotation_count;
// Series of helper functions.
static status textToStatus (const std::string&);
static std::string statusToText (status);
@@ -96,6 +98,7 @@ public:
void getTags (std::vector<std::string>&) const;
void removeTag (const std::string&);
bool hasAnnotations () const;
void getAnnotations (std::map <std::string, std::string>&) const;
void setAnnotations (const std::map <std::string, std::string>&);
void addAnnotation (const std::string&);

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,12 @@ bool compareTaskmod (Taskmod first, Taskmod second)
{
if (first._timestamp == second._timestamp)
{
return first._sequenceNumber < second._sequenceNumber;
// preserve relative order within the same resource
if (first._resource == second._resource)
return first._sequenceNumber < second._sequenceNumber;
// sort by UUID if mods where made on different resources
else
return first._resource < second._resource;
}
else
{
@@ -54,6 +59,16 @@ Taskmod::Taskmod ()
_bAfterSet = false;
_bBeforeSet = false;
_sequenceNumber = curSequenceNumber++;
_resource = -1;
}
Taskmod::Taskmod (int resourceID)
{
_timestamp = 0;
_bAfterSet = false;
_bBeforeSet = false;
_sequenceNumber = curSequenceNumber++;
_resource = resourceID;
}
////////////////////////////////////////////////////////////////////////////////
@@ -65,6 +80,7 @@ Taskmod::Taskmod (const Taskmod& other)
this->_bAfterSet = other._bAfterSet;
this->_bBeforeSet = other._bBeforeSet;
this->_sequenceNumber = other._sequenceNumber;
this->_resource = other._resource;
}
////////////////////////////////////////////////////////////////////////////////
@@ -108,7 +124,8 @@ Taskmod& Taskmod::operator= (const Taskmod& other)
this->_timestamp = other._timestamp;
this->_bAfterSet = other._bAfterSet;
this->_bBeforeSet = other._bBeforeSet;
this->_sequenceNumber = other._sequenceNumber;
this->_sequenceNumber = other._sequenceNumber;
this->_resource = other._resource;
}
return *this;
@@ -225,6 +242,12 @@ unsigned long Taskmod::getSequenceNumber () const
return _sequenceNumber;
}
////////////////////////////////////////////////////////////////////////////////
int Taskmod::getResource () const
{
return _resource;
}
////////////////////////////////////////////////////////////////////////////////
std::string Taskmod::getTimeStr () const
{

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -37,6 +37,7 @@ class Taskmod {
public:
Taskmod ();
Taskmod (int resourceID);
Taskmod (const Taskmod& other);
~Taskmod ();
@@ -68,6 +69,7 @@ public:
Task& getBefore ();
long getTimestamp () const;
unsigned long getSequenceNumber () const;
int getResource () const;
std::string getTimeStr () const;
protected:
@@ -77,6 +79,7 @@ protected:
bool _bAfterSet;
bool _bBeforeSet;
unsigned long _sequenceNumber;
int _resource;
static unsigned long curSequenceNumber;
};

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -30,10 +30,15 @@
#include <iostream>
#include <stdlib.h>
#include <util.h>
#include <string.h>
#include <errno.h>
#include <text.h>
#include <i18n.h>
#include <Transport.h>
#include <TransportSSH.h>
#include <TransportRSYNC.h>
#include <TransportCurl.h>
#include <TransportShell.h>
////////////////////////////////////////////////////////////////////////////////
Transport::Transport (const Uri& uri)
@@ -64,6 +69,10 @@ Transport* Transport::getTransport(const Uri& uri)
{
return new TransportCurl(uri);
}
else if ( uri._protocol == "sh+cp")
{
return new TransportShell(uri);
}
return NULL;
}
@@ -87,7 +96,18 @@ int Transport::execute()
it->append("\"");
}
}
return ::execute(_executable, _arguments);
int result = ::execute (_executable, _arguments);
int err;
switch (result)
{
case 127:
throw format (STRING_TRANSPORT_NORUN, _executable);
case -1:
err = errno;
throw format (STRING_TRANSPORT_NOFORK, _executable, ::strerror(err));
default:
return result;
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -106,4 +126,42 @@ bool Transport::is_filelist(const std::string& path)
}
////////////////////////////////////////////////////////////////////////////////
void Transport::expand_braces(const std::string& path,
const std::string& sourceortarget,
std::vector<std::string>& paths)
{
// Is is_filelist appropriate here? We only care about {}
if (is_filelist(path))
{
std::string::size_type pos;
pos = path.find("{");
if (pos == std::string::npos)
throw std::string (STRING_TRANSPORT_CURL_WILDCD);
if (!is_directory(sourceortarget))
throw format (STRING_TRANSPORT_URI_NODIR, sourceortarget);
std::string toSplit;
std::string suffix;
std::string prefix = path.substr (0, pos);
std::vector<std::string> splitted;
toSplit = path.substr (pos+1);
pos = toSplit.find ("}");
suffix = toSplit.substr (pos+1);
split (splitted, toSplit.substr(0, pos), ',');
std::vector <std::string>::iterator file;
for (file = splitted.begin (); file != splitted.end (); ++file) {
std::cout << " -- " << (prefix + *file + suffix) << "\n";
paths.push_back (prefix + *file + suffix);
}
}
else
{
// Not brace expandable - use the path as is.
paths.push_back (path);
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -43,6 +43,9 @@ public:
virtual void send (const std::string&) = 0;
virtual void recv (std::string) = 0;
void expand_braces(const std::string& path, const std::string& sourceortarget,
std::vector<std::string>& paths);
static bool is_directory(const std::string&);
static bool is_filelist(const std::string&);

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -35,12 +35,15 @@
////////////////////////////////////////////////////////////////////////////////
TransportCurl::TransportCurl(const Uri& uri) : Transport(uri)
{
_executable = "curl";
_executable = "curl";
}
////////////////////////////////////////////////////////////////////////////////
void TransportCurl::send(const std::string& source)
{
std::vector<std::string> sourcelist;
std::vector<std::string>::const_iterator source_iter;
if (_uri._host == "")
throw std::string (STRING_TRANSPORT_CURL_URI);
@@ -50,24 +53,22 @@ void TransportCurl::send(const std::string& source)
_arguments.push_back(_uri._user);
}
if (is_filelist(source))
{
std::string::size_type pos;
pos = source.find("{");
if (is_filelist (source)) {
expand_braces (source, _uri._data, sourcelist);
// Is there more than one source?
// Then path has to end with a '/'
if (sourcelist.size () > 1 && !_uri.is_directory ())
throw format (STRING_TRANSPORT_URI_NODIR, _uri);
if (pos == std::string::npos)
throw std::string (STRING_TRANSPORT_CURL_WILDCD);
if (!_uri.is_directory())
throw format (STRING_TRANSPORT_URI_NODIR, _uri._path);
_arguments.push_back ("-T");
_arguments.push_back ("\"" + escape (source, ' ') + "\"");
for (source_iter = sourcelist.begin (); source_iter != sourcelist.end (); ++source_iter) {
_arguments.push_back ("-T");
_arguments.push_back ("\"" + escape (*source_iter, ' ') + "\"");
}
}
else
{
_arguments.push_back ("-T");
_arguments.push_back (escape (source, ' '));
_arguments.push_back ("\"" + escape (source, ' ') + "\"");
}
// cmd line is: curl -T source protocol://host:port/path
@@ -80,14 +81,8 @@ void TransportCurl::send(const std::string& source)
_arguments.push_back (_uri._protocol + "://" + _uri._host + "/" + _uri._path);
}
int result = execute();
if (result)
{
if (result == 127) // command not found
throw std::string (STRING_TRANSPORT_CURL_NORUN);
else
throw std::string (STRING_TRANSPORT_CURL_FAIL);
}
if (execute ())
throw std::string (STRING_TRANSPORT_CURL_FAIL);
}
////////////////////////////////////////////////////////////////////////////////
@@ -106,28 +101,14 @@ void TransportCurl::recv(std::string target)
if (is_filelist(_uri._path))
{
std::string::size_type pos;
pos = _uri._path.find("{");
if (pos == std::string::npos)
throw std::string (STRING_TRANSPORT_CURL_WILDCD);
if (!is_directory(target))
throw format (STRING_TRANSPORT_URI_NODIR, target);
std::string toSplit;
std::string suffix;
std::string prefix = target;
std::vector<std::string> splitted;
toSplit = _uri._path.substr (pos+1);
pos = toSplit.find ("}");
suffix = toSplit.substr (pos+1);
split (splitted, toSplit.substr(0, pos), ',');
std::vector<std::string> paths;
expand_braces (_uri._path, target, paths);
std::vector <std::string>::iterator file;
for (file = splitted.begin (); file != splitted.end (); ++file) {
for (file = paths.begin (); file != paths.end (); ++file) {
targetargs.push_back ("-o");
targetargs.push_back (prefix + *file + suffix);
targetargs.push_back (*file);
}
}
else
@@ -148,14 +129,8 @@ void TransportCurl::recv(std::string target)
_arguments.insert (_arguments.end (), targetargs.begin (), targetargs.end ());
int result = execute();
if (result)
{
if (result == 127) // command not found
throw std::string (STRING_TRANSPORT_CURL_NORUN);
else
throw std::string (STRING_TRANSPORT_CURL_FAIL);
}
if (execute ())
throw std::string (STRING_TRANSPORT_CURL_FAIL);
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -34,69 +34,97 @@
////////////////////////////////////////////////////////////////////////////////
TransportRSYNC::TransportRSYNC(const Uri& uri) : Transport(uri)
{
_executable = "rsync";
_executable = "rsync";
}
////////////////////////////////////////////////////////////////////////////////
void TransportRSYNC::send(const std::string& source)
{
if (_uri._host == "")
throw std::string (STRING_TRANSPORT_RSYNC_URI);
std::vector<std::string> sourcelist;
std::vector<std::string>::const_iterator source_iter;
// Is there more than one file to transfer?
// Then path has to end with a '/'
if (is_filelist(source) && !_uri.is_directory())
throw format (STRING_TRANSPORT_URI_NODIR, _uri._path);
if (_uri._host == "")
throw std::string (STRING_TRANSPORT_RSYNC_URI);
// cmd line is: rsync [--port=PORT] source [user@]host::path
if (_uri._port != "")
{
_arguments.push_back ("--port=" + _uri._port);
}
// cmd line is: rsync [--port=PORT] source [user@]host::path
if (_uri._port != "")
{
_arguments.push_back ("--port=" + _uri._port);
}
_arguments.push_back (source);
if (is_filelist (source))
{
expand_braces (source, _uri._data, sourcelist);
// Is there more than one file to transfer?
// Then path has to end with a '/'
if (sourcelist.size () > 1 && !_uri.is_directory ())
throw format (STRING_TRANSPORT_URI_NODIR, _uri);
if (_uri._user != "")
{
_arguments.push_back (_uri._user + "@" + _uri._host + "::" + _uri._path);
}
else
{
_arguments.push_back (_uri._host + "::" + _uri._path);
}
for (source_iter = sourcelist.begin (); source_iter != sourcelist.end (); ++source_iter) {
_arguments.push_back (*source_iter);
}
}
else
{
_arguments.push_back (source);
}
if (execute())
throw std::string (STRING_TRANSPORT_RSYNC_NORUN);
if (_uri._user != "")
{
_arguments.push_back (_uri._user + "@" + _uri._host + "::" + _uri._path);
}
else
{
_arguments.push_back (_uri._host + "::" + _uri._path);
}
if (execute ())
throw std::string (STRING_TRANSPORT_RSYNC_FAIL);
}
////////////////////////////////////////////////////////////////////////////////
void TransportRSYNC::recv(std::string target)
{
if (_uri._host == "")
throw std::string (STRING_TRANSPORT_RSYNC_URI);
std::vector<std::string> paths;
std::vector<std::string>::const_iterator paths_iter;
// Is there more than one file to transfer?
// Then target has to end with a '/'
if (is_filelist(_uri._path) && !is_directory(target))
throw format (STRING_TRANSPORT_URI_NODIR, target);
if (_uri._host == "")
throw std::string (STRING_TRANSPORT_RSYNC_URI);
// cmd line is: rsync [--port=PORT] [user@]host::path target
if (_uri._port != "")
_arguments.push_back ("--port=" + _uri._port);
// cmd line is: rsync [--port=PORT] [user@]host::path target
if (_uri._port != "")
_arguments.push_back ("--port=" + _uri._port);
if (_uri._user != "")
{
_arguments.push_back (_uri._user + "@" + _uri._host + "::" + _uri._path);
}
else
{
_arguments.push_back (_uri._host + "::" + _uri._path);
}
if (is_filelist(_uri._path)) {
_arguments.push_back (target);
// Rsync servers do not to {} expansion, so we have to do it on the client.
expand_braces (_uri._path, target, paths);
if (execute())
throw std::string (STRING_TRANSPORT_RSYNC_NORUN);
// Is there more than one file to transfer?
// Then target has to end with a '/'
if (paths.size () > 1 && ! is_directory (target))
throw format (STRING_TRANSPORT_URI_NODIR, target);
for (paths_iter = paths.begin (); paths_iter != paths.end (); ++paths_iter) {
if (_uri._user != "")
{
_arguments.push_back (_uri._user + "@" + _uri._host + "::" + *paths_iter);
}
else
{
_arguments.push_back (_uri._host + "::" + *paths_iter);
}
}
}
else
{
_arguments.push_back (_uri._host + "::" + _uri._path);
}
_arguments.push_back (target);
if (execute ())
throw std::string (STRING_TRANSPORT_RSYNC_FAIL);
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -35,73 +35,88 @@
////////////////////////////////////////////////////////////////////////////////
TransportSSH::TransportSSH(const Uri& uri) : Transport(uri)
{
_executable = "scp";
_executable = "scp";
}
////////////////////////////////////////////////////////////////////////////////
void TransportSSH::send(const std::string& source)
{
if (_uri._host == "")
throw std::string (STRING_TRANSPORT_SSH_URI);
std::vector<std::string> sourcelist;
std::vector<std::string>::const_iterator source_iter;
// Is there more than one file to transfer?
// Then path has to end with a '/'
if (is_filelist(source) && !_uri.is_directory())
throw format (STRING_TRANSPORT_URI_NODIR, _uri._path);
if (_uri._host == "")
throw std::string (STRING_TRANSPORT_SSH_URI);
// cmd line is: scp [-p port] [user@]host:path
if (_uri._port != "")
{
_arguments.push_back ("-P");
_arguments.push_back (_uri._port);
}
// cmd line is: scp [-p port] [user@]host:path
if (_uri._port != "")
{
_arguments.push_back ("-P");
_arguments.push_back (_uri._port);
}
_arguments.push_back (source);
if (is_filelist (source))
{
expand_braces (source, _uri._data, sourcelist);
// Is there more than one source?
// Then path has to end with a '/'
if (sourcelist.size () > 1 && !_uri.is_directory ())
throw format (STRING_TRANSPORT_URI_NODIR, _uri);
if (_uri._user != "")
{
_arguments.push_back (_uri._user + "@" + _uri._host + ":" + escape (_uri._path, ' '));
}
else
{
_arguments.push_back (_uri._host + ":" + escape (_uri._path, ' '));
}
for (source_iter = sourcelist.begin (); source_iter != sourcelist.end (); ++source_iter) {
_arguments.push_back (*source_iter);
}
}
else
{
_arguments.push_back (source);
}
if (execute())
throw std::string (STRING_TRANSPORT_SSH_NORUN);
if (_uri._user != "")
{
_arguments.push_back (_uri._user + "@" + _uri._host + ":" + escape (_uri._path, ' '));
}
else
{
_arguments.push_back (_uri._host + ":" + escape (_uri._path, ' '));
}
if (execute ())
throw std::string (STRING_TRANSPORT_SSH_FAIL);
}
////////////////////////////////////////////////////////////////////////////////
void TransportSSH::recv(std::string target)
{
if (_uri._host == "")
throw std::string (STRING_TRANSPORT_SSH_URI);
if (_uri._host == "")
throw std::string (STRING_TRANSPORT_SSH_URI);
// Is there more than one file to transfer?
// Then target has to end with a '/'
if (is_filelist(_uri._path) && !is_directory(target))
// Is there more than one file to transfer?
// Then target has to end with a '/'
if (is_filelist(_uri._path) && !is_directory(target))
throw format (STRING_TRANSPORT_URI_NODIR, target);
// cmd line is: scp [-p port] [user@]host:path
if (_uri._port != "")
{
_arguments.push_back ("-P");
_arguments.push_back (_uri._port);
}
// cmd line is: scp [-p port] [user@]host:path
if (_uri._port != "")
{
_arguments.push_back ("-P");
_arguments.push_back (_uri._port);
}
if (_uri._user != "")
{
_arguments.push_back (_uri._user + "@" + _uri._host + ":" + escape (_uri._path, ' '));
}
else
{
_arguments.push_back (_uri._host + ":" + escape (_uri._path, ' '));
}
// We do not do {} expansion of the URI, as ssh servers do that for us.
_arguments.push_back (target);
if (_uri._user != "")
{
_arguments.push_back (_uri._user + "@" + _uri._host + ":" + escape (_uri._path, ' '));
}
else
{
_arguments.push_back (_uri._host + ":" + escape (_uri._path, ' '));
}
if (execute())
throw std::string (STRING_TRANSPORT_SSH_NORUN);
_arguments.push_back (target);
if (execute ())
throw std::string (STRING_TRANSPORT_SSH_FAIL);
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

102
src/TransportShell.cpp Normal file
View File

@@ -0,0 +1,102 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// http://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <text.h>
#include <i18n.h>
#include <TransportShell.h>
#include <util.h>
////////////////////////////////////////////////////////////////////////////////
TransportShell::TransportShell(const Uri& uri) : Transport(uri)
{
_executable = "cp";
}
////////////////////////////////////////////////////////////////////////////////
void TransportShell::send(const std::string& source)
{
std::vector<std::string> sourcelist;
std::vector<std::string>::const_iterator source_iter;
if (_uri._path == "")
throw std::string (STRING_TRANSPORT_SHELL_NOPATH);
if (is_filelist(source))
{
expand_braces (source, _uri._path, sourcelist);
// Is there more than one file to transfer?
// Then path has to end with a '/'
if (sourcelist.size() > 1 && !_uri.is_directory())
throw format (STRING_TRANSPORT_URI_NODIR, _uri._path);
for (source_iter = sourcelist.begin (); source_iter != sourcelist.end (); ++source_iter)
_arguments.push_back (*source_iter);
}
else
{
_arguments.push_back (source);
}
_arguments.push_back (_uri._path);
if (execute ())
throw std::string (STRING_TRANSPORT_SHELL_FAIL);
}
////////////////////////////////////////////////////////////////////////////////
void TransportShell::recv(std::string target)
{
std::vector<std::string> paths;
std::vector<std::string>::const_iterator paths_iter;
if (_uri._path == "")
throw std::string (STRING_TRANSPORT_SHELL_NOPATH);
if (is_filelist(_uri._path))
{
expand_braces (_uri._path, target, paths);
// Is there more than one file to transfer?
// Then target has to end with a '/'
if (paths.size() > 1 && !is_directory(target))
throw format (STRING_TRANSPORT_URI_NODIR, target);
for (paths_iter = paths.begin (); paths_iter != paths.end (); ++paths_iter)
_arguments.push_back (*paths_iter);
}
else
{
_arguments.push_back (_uri._path);
}
_arguments.push_back (target);
if (execute ())
throw std::string (STRING_TRANSPORT_SHELL_FAIL);
}
////////////////////////////////////////////////////////////////////////////////

45
src/TransportShell.h Normal file
View File

@@ -0,0 +1,45 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// http://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_TRANSPORTSHELL
#define INCLUDED_TRANSPORTSHELL
#define L10N // Localization complete.
#include <string>
#include <Transport.h>
class TransportShell : public Transport {
public:
TransportShell (const Uri&);
virtual void send (const std::string&);
virtual void recv (std::string);
};
#endif

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -197,6 +197,10 @@ std::string Uri::ToString ()
if (is_local ())
return _data;
// No password to obscure, return the original.
if (_protocol == "sh+cp")
return _data;
std::string result;
result = _protocol + "://";
@@ -256,6 +260,13 @@ void Uri::parse ()
pathDelimiter = ":";
}
if (_protocol == "sh+cp")
{
_path = _data;
_parsed = true;
return;
}
// user delimited by single quotes?
if ( _data[0] == '\''
&& (pos = _data.find("'", 1)) != std::string::npos )

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2010 - 2012, Johannes Schlatow.
// Copyright 2010 - 2013, Johannes Schlatow.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -27,11 +27,13 @@
#define L10N // Localization complete.
#include <numeric>
#include <ViewTask.h>
#include <Context.h>
#include <Timer.h>
#include <text.h>
#include <utf8.h>
#include <i18n.h>
#include <main.h>
extern Context context;
@@ -113,6 +115,9 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
{
context.timer_render.start ();
bool const print_empty_columns = context.config.getBoolean ("print.empty.columns");
std::vector <Column*> nonempty_columns;
// Determine minimal, ideal column widths.
std::vector <int> minimal;
std::vector <int> ideal;
@@ -121,8 +126,8 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
for (i = _columns.begin (); i != _columns.end (); ++i)
{
// Headers factor in to width calculations.
int global_min = utf8_length ((*i)->label ());
int global_ideal = global_min;
unsigned int global_min = 0;
unsigned int global_ideal = global_min;
for (unsigned int s = 0; s < sequence.size (); ++s)
{
@@ -133,44 +138,73 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
break;
// Determine minimum and ideal width for this column.
int min;
int ideal;
unsigned int min;
unsigned int ideal;
(*i)->measure (data[sequence[s]], min, ideal);
if (min > global_min) global_min = min;
if (min > global_min) global_min = min;
if (ideal > global_ideal) global_ideal = ideal;
}
minimal.push_back (global_min);
ideal.push_back (global_ideal);
if (print_empty_columns || global_min != 0)
{
unsigned int label_length = utf8_width ((*i)->label ());
if (label_length > global_min) global_min = label_length;
if (label_length > global_ideal) global_ideal = label_length;
minimal.push_back (global_min);
ideal.push_back (global_ideal);
}
if (! print_empty_columns && global_min != 0)
{
nonempty_columns.push_back (*i);
}
}
// Sum the minimal widths.
int sum_minimal = 0;
std::vector <int>::iterator c;
for (c = minimal.begin (); c != minimal.end (); ++c)
sum_minimal += *c;
if (! print_empty_columns)
_columns = nonempty_columns;
int all_extra = _left_margin
+ (2 * _extra_padding)
+ ((_columns.size () - 1) * _intra_padding);
// Sum the widths.
int sum_minimal = std::accumulate (minimal.begin (), minimal.end (), 0);
int sum_ideal = std::accumulate (ideal.begin (), ideal.end (), 0);
// Sum the ideal widths.
int sum_ideal = 0;
for (c = ideal.begin (); c != ideal.end (); ++c)
sum_ideal += *c;
// Calculate final column widths.
int overage = _width
- _left_margin
- (2 * _extra_padding)
- ((_columns.size () - 1) * _intra_padding);
int overage = _width - sum_minimal - all_extra;
context.debug (format ("ViewTask::render min={1} ideal={2} overage={3}",
sum_minimal + all_extra,
sum_ideal + all_extra,
overage));
std::vector <int> widths;
if (_width == 0 || sum_ideal <= overage)
// Ideal case. Everything fits.
if (_width == 0 || sum_ideal + all_extra <= _width)
{
widths = ideal;
else if (sum_minimal > overage || overage < 0)
}
// Not enough for minimum.
else if (overage < 0)
{
context.error (format (STRING_VIEW_TOO_SMALL, sum_minimal + all_extra, _width));
widths = minimal;
}
// Perfect minimal width.
else if (overage == 0)
{
widths = minimal;
}
// Extra space to share.
else if (overage > 0)
{
widths = minimal;
overage -= sum_minimal;
// Spread 'overage' among columns where width[i] < ideal[i]
bool needed = true;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -122,14 +122,14 @@ std::string ViewText::render ()
for (unsigned int col = 0; col < _columns.size (); ++col)
{
// Headers factor in to width calculations.
int global_min = utf8_length (_columns[col]->label ());
int global_ideal = global_min;
unsigned int global_min = utf8_width (_columns[col]->label ());
unsigned int global_ideal = global_min;
for (unsigned int row = 0; row < _data.size (); ++row)
{
// Determine minimum and ideal width for this column.
int min;
int ideal;
unsigned int min;
unsigned int ideal;
_columns[col]->measure (_data[row][col], min, ideal);
if (min > global_min) global_min = min;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -74,7 +74,7 @@ bool ColumnDate::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnDate::measure (Task& task, int& minimum, int& maximum)
void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
@@ -95,7 +95,13 @@ void ColumnDate::measure (Task& task, int& minimum, int& maximum)
if (format == "")
format = context.config.get ("dateformat");
minimum = maximum = date.toString (format).length ();
minimum = maximum = Date::length (format);
}
else if (_style == "countdown")
{
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
Date now;
minimum = maximum = Duration (now - date).format ().length ();
}
else if (_style == "julian")
{
@@ -134,7 +140,7 @@ void ColumnDate::render (
// Determine the output date format, which uses a hierarchy of definitions.
// rc.report.<report>.dateformat
// rc.dateformat.report
// rc.dateformat.
// rc.dateformat
std::string format = context.config.get ("report." + _report + ".dateformat");
if (format == "")
format = context.config.get ("dateformat.report");
@@ -147,6 +153,16 @@ void ColumnDate::render (
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
.toString (format), width)));
}
else if (_style == "countdown")
{
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
Date now;
lines.push_back (
color.colorize (
rightJustify (
Duration (now - date).format (), width)));
}
else if (_style == "julian")
{
lines.push_back (
@@ -178,7 +194,7 @@ void ColumnDate::render (
lines.push_back (
color.colorize (
rightJustify (
leftJustify (
Duration (now - date).formatCompact (), width)));
}
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ public:
~ColumnDate ();
virtual bool validate (std::string&);
virtual void measure (Task&, int&, int&);
virtual void measure (Task&, unsigned int&, unsigned int&);
virtual void render (std::vector <std::string>&, Task&, int, Color&);
};

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -79,7 +79,7 @@ void ColumnDepends::setStyle (const std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnDepends::measure (Task& task, int& minimum, int& maximum)
void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
std::vector <Task> blocking;
dependencyGetBlocking (task, blocking);
@@ -101,7 +101,7 @@ void ColumnDepends::measure (Task& task, int& minimum, int& maximum)
join (all, " ", blocking_ids);
maximum = all.length ();
int length;
unsigned int length;
for (i = blocking.begin (); i != blocking.end (); ++i)
{
length = format (i->id).length ();

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -43,7 +43,7 @@ public:
bool validate (std::string&);
void setStyle (const std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -32,6 +32,7 @@
#include <Date.h>
#include <ColDescription.h>
#include <text.h>
#include <utf8.h>
#include <util.h>
#include <i18n.h>
@@ -51,7 +52,11 @@ ColumnDescription::ColumnDescription ()
_styles.push_back ("truncated");
_styles.push_back ("count");
std::string t = Date ().toString (context.config.get ("dateformat"));
_dateformat = context.config.get ("dateformat.annotation");
if (_dateformat == "")
_dateformat = context.config.get ("dateformat");
std::string t = Date ().toString (_dateformat);
std::string d = STRING_COLUMN_EXAMPLES_DESC;
std::string a1 = STRING_COLUMN_EXAMPLES_ANNO1;
std::string a2 = STRING_COLUMN_EXAMPLES_ANNO2;
@@ -73,6 +78,8 @@ ColumnDescription::ColumnDescription ()
_examples.push_back (d + " [4]");
_hyphenate = context.config.getBoolean ("hyphenate");
_indent = context.config.getInteger ("indent.annotation");
}
////////////////////////////////////////////////////////////////////////////////
@@ -88,7 +95,7 @@ bool ColumnDescription::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
void ColumnDescription::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
std::string description = task.get (_name);
@@ -98,68 +105,63 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
if (_style == "default" ||
_style == "combined")
{
int indent = context.config.getInteger ("indent.annotation");
std::string format = context.config.get ("dateformat.annotation");
if (format == "")
format = context.config.get ("dateformat");
minimum = longestWord (description);
maximum = utf8_width (description);
int min_desc = longestWord (description);
int min_anno = indent + Date::length (format);
minimum = std::max (min_desc, min_anno);
maximum = description.length ();
std::map <std::string, std::string> annos;
task.getAnnotations (annos);
std::map <std::string, std::string>::iterator i;
for (i = annos.begin (); i != annos.end (); i++)
if (task.annotation_count)
{
int len = min_anno + 1 + i->second.length ();
if (len > maximum)
maximum = len;
unsigned int min_anno = _indent + Date::length (_dateformat);
if (min_anno > minimum)
minimum = min_anno;
std::map <std::string, std::string> annos;
task.getAnnotations (annos);
std::map <std::string, std::string>::iterator i;
for (i = annos.begin (); i != annos.end (); i++)
{
unsigned int len = min_anno + 1 + utf8_width (i->second);
if (len > maximum)
maximum = len;
}
}
}
// Just the text
else if (_style == "desc")
{
maximum = description.length ();
maximum = utf8_width (description);
minimum = longestWord (description);
}
// The text <date> <anno> ...
else if (_style == "oneline")
{
std::string format = context.config.get ("dateformat.annotation");
if (format == "")
format = context.config.get ("dateformat");
minimum = longestWord (description);
maximum = utf8_width (description);
int min_desc = longestWord (description);
int min_anno = Date::length (format);
minimum = std::max (min_desc, min_anno);
maximum = description.length ();
std::map <std::string, std::string> annos;
task.getAnnotations (annos);
std::map <std::string, std::string>::iterator i;
for (i = annos.begin (); i != annos.end (); i++)
maximum += i->second.length () + minimum + 1;
if (task.annotation_count)
{
unsigned int min_anno = Date::length (_dateformat);
std::map <std::string, std::string> annos;
task.getAnnotations (annos);
std::map <std::string, std::string>::iterator i;
for (i = annos.begin (); i != annos.end (); i++)
maximum += min_anno + 1 + utf8_width (i->second);
}
}
// The te...
else if (_style == "truncated")
{
minimum = 4;
maximum = description.length ();
maximum = utf8_width (description);
}
// The text [2]
else if (_style == "count")
{
std::map <std::string, std::string> annos;
task.getAnnotations (annos);
// <description> + ' ' + '[' + <count> + ']'
maximum = description.length () + 3 + format ((int)annos.size ()).length ();
maximum = utf8_width (description) + 1 + 1 + format (task.annotation_count).length () + 1;
minimum = longestWord (description);
}
@@ -182,21 +184,15 @@ void ColumnDescription::render (
if (_style == "default" ||
_style == "combined")
{
int indent = context.config.getInteger ("indent.annotation");
std::map <std::string, std::string> annos;
task.getAnnotations (annos);
if (annos.size ())
{
std::string format = context.config.get ("dateformat.annotation");
if (format == "")
format = context.config.get ("dateformat");
std::map <std::string, std::string>::iterator i;
for (i = annos.begin (); i != annos.end (); i++)
{
Date dt (strtol (i->first.substr (11).c_str (), NULL, 10));
description += "\n" + std::string (indent, ' ') + dt.toString (format) + " " + i->second;
description += "\n" + std::string (_indent, ' ') + dt.toString (_dateformat) + " " + i->second;
}
}
@@ -226,15 +222,11 @@ void ColumnDescription::render (
task.getAnnotations (annos);
if (annos.size ())
{
std::string format = context.config.get ("dateformat.annotation");
if (format == "")
format = context.config.get ("dateformat");
std::map <std::string, std::string>::iterator i;
for (i = annos.begin (); i != annos.end (); i++)
{
Date dt (atoi (i->first.substr (11).c_str ()));
description += " " + dt.toString (format) + " " + i->second;
description += " " + dt.toString (_dateformat) + " " + i->second;
}
}
@@ -249,7 +241,7 @@ void ColumnDescription::render (
// This is a des...
else if (_style == "truncated")
{
int len = description.length ();
int len = utf8_width (description);
if (len > width)
lines.push_back (color.colorize (description.substr (0, width - 3) + "..."));
else

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,11 +42,13 @@ public:
~ColumnDescription ();
bool validate (std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:
bool _hyphenate;
std::string _dateformat;
int _indent;
};
#endif

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -73,46 +73,3 @@ void ColumnDue::setStyle (const std::string& value)
}
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnDue::measure (Task& task, int& minimum, int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
if (_style == "countdown")
{
Date date ((time_t) strtol (task.get (_name).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 (_name))
{
if (_style == "countdown")
{
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
Date now;
lines.push_back (
color.colorize (
rightJustify (
Duration (now - date).format (), width)));
}
else
ColumnDate::render (lines, task, width, color);
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -39,8 +39,6 @@ public:
bool validate (std::string&);
void setStyle (const std::string&);
void measure (Task&, int&, int&);
void render (std::vector <std::string>&, Task&, int, Color&);
};
#endif

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -62,7 +62,7 @@ bool ColumnID::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnID::measure (Task& task, int& minimum, int& maximum)
void ColumnID::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
int length;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ public:
~ColumnID ();
bool validate (std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -62,7 +62,7 @@ bool ColumnIMask::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnIMask::measure (Task& task, int& minimum, int& maximum)
void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = task.get ("imask").length ();

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ public:
~ColumnIMask ();
bool validate (std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -62,7 +62,7 @@ bool ColumnMask::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnMask::measure (Task& task, int& minimum, int& maximum)
void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = task.get ("mask").length ();

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ public:
~ColumnMask ();
bool validate (std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -64,7 +64,7 @@ bool ColumnParent::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnParent::measure (Task&, int& minimum, int& maximum)
void ColumnParent::measure (Task&, unsigned int& minimum, unsigned int& maximum)
{
if (_style == "default" || _style == "long") minimum = maximum = 36;
else if (_style == "short") minimum = maximum = 8;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ public:
~ColumnParent ();
bool validate (std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -81,11 +81,15 @@ void ColumnPriority::setStyle (const std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnPriority::measure (Task& task, int& minimum, int& maximum)
void ColumnPriority::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
std::string priority = task.get (_name);
minimum = maximum = 1;
if (priority == "")
minimum = maximum = 0;
else
minimum = maximum = 1;
if (_style == "long")
{
if (priority == "H") minimum = maximum = 4;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -43,7 +43,7 @@ public:
bool validate (std::string&);
void setStyle (const std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -30,6 +30,7 @@
#include <Context.h>
#include <ColProject.h>
#include <text.h>
#include <utf8.h>
#include <util.h>
#include <i18n.h>
@@ -67,7 +68,7 @@ bool ColumnProject::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnProject::measure (Task& task, int& minimum, int& maximum)
void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
std::string project = task.get (_name);
@@ -87,7 +88,7 @@ void ColumnProject::measure (Task& task, int& minimum, int& maximum)
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
minimum = longestWord (project);
maximum = project.length ();
maximum = utf8_width (project);
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ public:
~ColumnProject ();
bool validate (std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -78,7 +78,7 @@ void ColumnRecur::setStyle (const std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnRecur::measure (Task& task, int& minimum, int& maximum)
void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
if (_style == "default" ||
_style == "duration")

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -43,7 +43,7 @@ public:
bool validate (std::string&);
void setStyle (const std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -73,46 +73,3 @@ void ColumnScheduled::setStyle (const std::string& value)
}
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnScheduled::measure (Task& task, int& minimum, int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
if (_style == "countdown")
{
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
Date now;
minimum = maximum = Duration (now - date).format ().length ();
}
else
ColumnDate::measure (task, minimum, maximum);
}
}
////////////////////////////////////////////////////////////////////////////////
void ColumnScheduled::render (
std::vector <std::string>& lines,
Task& task,
int width,
Color& color)
{
if (task.has (_name))
{
if (_style == "countdown")
{
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
Date now;
lines.push_back (
color.colorize (
rightJustify (
Duration (now - date).format (), width)));
}
else
ColumnDate::render (lines, task, width, color);
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -39,8 +39,6 @@ public:
bool validate (std::string&);
void setStyle (const std::string&);
void measure (Task&, int&, int&);
void render (std::vector <std::string>&, Task&, int, Color&);
};
#endif

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -69,7 +69,7 @@ void ColumnStart::setStyle (const std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnStart::measure (Task& task, int& minimum, int& maximum)
void ColumnStart::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,7 @@ public:
bool validate (std::string&);
void setStyle (const std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
};

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -31,6 +31,7 @@
#include <ColStatus.h>
#include <text.h>
#include <i18n.h>
#include <utf8.h>
extern Context context;
@@ -73,24 +74,23 @@ void ColumnStatus::setStyle (const std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnStatus::measure (Task& task, int& minimum, int& maximum)
void ColumnStatus::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
Task::status status = task.getStatus ();
if (_style == "default" ||
_style == "long")
{
if (status == Task::pending ||
status == Task::deleted ||
status == Task::waiting)
{
minimum = maximum = 7;
}
else if (status == Task::completed ||
status == Task::recurring)
{
minimum = maximum = 9;
}
if (status == Task::pending)
minimum = maximum = utf8_width (STRING_COLUMN_LABEL_STAT_PE);
else if (status == Task::deleted)
minimum = maximum = utf8_width (STRING_COLUMN_LABEL_STAT_DE);
else if (status == Task::waiting)
minimum = maximum = utf8_width (STRING_COLUMN_LABEL_STAT_WA);
else if (status == Task::completed)
minimum = maximum = utf8_width (STRING_COLUMN_LABEL_STAT_CO);
else if (status == Task::recurring)
minimum = maximum = utf8_width (STRING_COLUMN_LABEL_STAT_RE);
}
else if (_style == "short")
minimum = maximum = 1;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -43,7 +43,7 @@ public:
bool validate (std::string&);
void setStyle (const std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -71,7 +71,7 @@ void ColumnString::setReport (const std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
//
void ColumnString::measure (const std::string& value, int& minimum, int& maximum)
void ColumnString::measure (const std::string& value, unsigned int& minimum, unsigned int& maximum)
{
if (_style == "left" ||
_style == "right" ||

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ public:
~ColumnString ();
void setReport (const std::string&);
void measure (const std::string&, int&, int&);
void measure (const std::string&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, const std::string&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -32,6 +32,7 @@
#include <ColTags.h>
#include <text.h>
#include <i18n.h>
#include <utf8.h>
extern Context context;
@@ -83,17 +84,16 @@ void ColumnTags::setStyle (const std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnTags::measure (Task& task, int& minimum, int& maximum)
void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
if (_style == "indicator") minimum = maximum = context.config.get ("tag.indicator").length ();
if (_style == "indicator") minimum = maximum = utf8_width (context.config.get ("tag.indicator"));
else if (_style == "count") minimum = maximum = 3;
else if (_style == "default" ||
_style == "list")
{
std::string tags = task.get (_name);
minimum = 0;
maximum = tags.length ();
maximum = utf8_width (tags);
if (maximum)
{
@@ -101,8 +101,11 @@ void ColumnTags::measure (Task& task, int& minimum, int& maximum)
split (all, tags, ',');
std::vector <std::string>::iterator i;
for (i = all.begin (); i != all.end (); ++i)
if ((int)i->length () > minimum)
minimum = i->length () + 1;
{
unsigned int length = utf8_width (*i);
if (length > minimum)
minimum = length;
}
}
}
else
@@ -119,7 +122,18 @@ void ColumnTags::render (
std::string tags = task.get (_name);
if (tags != "")
{
if (_style == "indicator")
if (_style == "default" ||
_style == "list")
{
std::replace (tags.begin (), tags.end (), ',', ' ');
std::vector <std::string> all;
wrapText (all, tags, width, _hyphenate);
std::vector <std::string>::iterator i;
for (i = all.begin (); i != all.end (); ++i)
lines.push_back (color.colorize (leftJustify (*i, width)));
}
else if (_style == "indicator")
{
lines.push_back (
color.colorize (
@@ -133,17 +147,6 @@ void ColumnTags::render (
color.colorize (
rightJustify ("[" + format ((int)all.size ()) + "]", width)));
}
else if (_style == "default" ||
_style == "list")
{
std::replace (tags.begin (), tags.end (), ',', ' ');
std::vector <std::string> all;
wrapText (all, tags, width, _hyphenate);
std::vector <std::string>::iterator i;
for (i = all.begin (); i != all.end (); ++i)
lines.push_back (color.colorize (leftJustify (*i, width)));
}
}
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -43,7 +43,7 @@ public:
bool validate (std::string&);
void setStyle (const std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -32,6 +32,7 @@
#include <Date.h>
#include <ColUDA.h>
#include <text.h>
#include <utf8.h>
#include <i18n.h>
#include <stdlib.h>
@@ -77,7 +78,7 @@ bool ColumnUDA::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
//
void ColumnUDA::measure (Task& task, int& minimum, int& maximum)
void ColumnUDA::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
@@ -91,7 +92,7 @@ void ColumnUDA::measure (Task& task, int& minimum, int& maximum)
// Determine the output date format, which uses a hierarchy of definitions.
// rc.report.<report>.dateformat
// rc.dateformat.report
// rc.dateformat.
// rc.dateformat
Date date ((time_t) strtol (value.c_str (), NULL, 10));
std::string format = context.config.get ("report." + _report + ".dateformat");
if (format == "")
@@ -99,11 +100,11 @@ void ColumnUDA::measure (Task& task, int& minimum, int& maximum)
if (format == "")
format = context.config.get ("dateformat");
minimum = maximum = date.toString (format).length ();
minimum = maximum = Date::length (format);
}
else if (_type == "duration")
{
minimum = maximum = Duration (value).formatCompact ().length ();
minimum = maximum = utf8_width (Duration (value).formatCompact ());
}
else if (_type == "string")
{
@@ -113,7 +114,7 @@ void ColumnUDA::measure (Task& task, int& minimum, int& maximum)
}
else if (_type == "numeric")
{
minimum = maximum = value.length ();
minimum = maximum = utf8_width (value);
}
}
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ public:
~ColumnUDA ();
bool validate (std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
public:

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -64,7 +64,7 @@ bool ColumnUUID::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnUUID::measure (Task&, int& minimum, int& maximum)
void ColumnUUID::measure (Task&, unsigned int& minimum, unsigned int& maximum)
{
if (_style == "default" || _style == "long") minimum = maximum = 36;
else if (_style == "short") minimum = maximum = 8;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ public:
~ColumnUUID ();
bool validate (std::string&);
void measure (Task&, int&, int&);
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:

Some files were not shown because too many files have changed in this diff Show More