From f5e0f8b7a6f5e0d21860bc81bacf3126dcdae5f8 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 20 Jun 2009 13:06:53 -0400 Subject: [PATCH] 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. --- src/TDB.cpp | 4 ++-- src/command.cpp | 9 +++++++++ src/main.h | 5 ++--- src/rules.cpp | 8 ++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/TDB.cpp b/src/TDB.cpp index 6fafe9d8c..e4820eb6e 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -210,7 +210,7 @@ int TDB::loadPending (std::vector & tasks, Filter& filter) while (fgets (line, T_LINE_MAX, location->pending)) { int length = ::strlen (line); - if (length > 1) + if (length > 3) // []\n { // TODO Add hidden attribute indicating source? Task task (line); @@ -274,7 +274,7 @@ int TDB::loadCompleted (std::vector & tasks, Filter& filter) while (fgets (line, T_LINE_MAX, location->completed)) { int length = ::strlen (line); - if (length > 2) + if (length > 3) // []\n { // TODO Add hidden attribute indicating source? diff --git a/src/command.cpp b/src/command.cpp index 037e113d9..c70f217c8 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -83,6 +83,15 @@ std::string handleAdd () context.tdb.lock (context.config.get ("locking", true)); context.tdb.add (context.task); + +#ifdef FEATURE_NEW_ID + // All this, just for an id number. + std::vector all; + Filter none; + context.tdb.loadPending (all, none); + out << "Created task " << context.tdb.nextId () << std::endl; +#endif + context.tdb.commit (); context.tdb.unlock (); diff --git a/src/main.h b/src/main.h index 7be5e98bd..308b47f17 100644 --- a/src/main.h +++ b/src/main.h @@ -25,9 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// -// TDB Optimization attempts to reduce the amount of I/O. -#define FEATURE_TDB_OPT 1 - +#define FEATURE_TDB_OPT 1 // TDB Optimization reduces file I/O. +#define FEATURE_NEW_ID 1 // Echoes back new id. #include #include diff --git a/src/rules.cpp b/src/rules.cpp index 69df64245..604c5eb3c 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -283,12 +283,12 @@ std::string colorizeFootnote (const std::string& input) //////////////////////////////////////////////////////////////////////////////// std::string colorizeDebug (const std::string& input) { - if (gsFg["debug.footnote"] != Text::nocolor || - gsBg["debug.footnote"] != Text::nocolor) + if (gsFg["color.debug"] != Text::nocolor || + gsBg["color.debug"] != Text::nocolor) { return Text::colorize ( - gsFg["debug.footnote"], - gsBg["debug.footnote"], + gsFg["color.debug"], + gsBg["color.debug"], input); }