Enhancement - echo ID on add
- When a task is added, the new ID is echoed back, for convenience. This requires a scan of the pending file, so there is a performance hit, and the feature is controlled by the FEATURE_NEW_ID define.
This commit is contained in:
@@ -210,7 +210,7 @@ int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
|
|||||||
while (fgets (line, T_LINE_MAX, location->pending))
|
while (fgets (line, T_LINE_MAX, location->pending))
|
||||||
{
|
{
|
||||||
int length = ::strlen (line);
|
int length = ::strlen (line);
|
||||||
if (length > 1)
|
if (length > 3) // []\n
|
||||||
{
|
{
|
||||||
// TODO Add hidden attribute indicating source?
|
// TODO Add hidden attribute indicating source?
|
||||||
Task task (line);
|
Task task (line);
|
||||||
@@ -274,7 +274,7 @@ int TDB::loadCompleted (std::vector <Task>& tasks, Filter& filter)
|
|||||||
while (fgets (line, T_LINE_MAX, location->completed))
|
while (fgets (line, T_LINE_MAX, location->completed))
|
||||||
{
|
{
|
||||||
int length = ::strlen (line);
|
int length = ::strlen (line);
|
||||||
if (length > 2)
|
if (length > 3) // []\n
|
||||||
{
|
{
|
||||||
// TODO Add hidden attribute indicating source?
|
// TODO Add hidden attribute indicating source?
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,15 @@ std::string handleAdd ()
|
|||||||
|
|
||||||
context.tdb.lock (context.config.get ("locking", true));
|
context.tdb.lock (context.config.get ("locking", true));
|
||||||
context.tdb.add (context.task);
|
context.tdb.add (context.task);
|
||||||
|
|
||||||
|
#ifdef FEATURE_NEW_ID
|
||||||
|
// All this, just for an id number.
|
||||||
|
std::vector <Task> all;
|
||||||
|
Filter none;
|
||||||
|
context.tdb.loadPending (all, none);
|
||||||
|
out << "Created task " << context.tdb.nextId () << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,8 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// TDB Optimization attempts to reduce the amount of I/O.
|
#define FEATURE_TDB_OPT 1 // TDB Optimization reduces file I/O.
|
||||||
#define FEATURE_TDB_OPT 1
|
#define FEATURE_NEW_ID 1 // Echoes back new id.
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -283,12 +283,12 @@ std::string colorizeFootnote (const std::string& input)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string colorizeDebug (const std::string& input)
|
std::string colorizeDebug (const std::string& input)
|
||||||
{
|
{
|
||||||
if (gsFg["debug.footnote"] != Text::nocolor ||
|
if (gsFg["color.debug"] != Text::nocolor ||
|
||||||
gsBg["debug.footnote"] != Text::nocolor)
|
gsBg["color.debug"] != Text::nocolor)
|
||||||
{
|
{
|
||||||
return Text::colorize (
|
return Text::colorize (
|
||||||
gsFg["debug.footnote"],
|
gsFg["color.debug"],
|
||||||
gsBg["debug.footnote"],
|
gsBg["color.debug"],
|
||||||
input);
|
input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user