From 0449f9e0a215a4efc091ec957ab22f31435dde24 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 9 Jun 2009 23:58:05 -0400 Subject: [PATCH] Enhancements - version command - Implemented version command. - Corrected config handling in version command. --- src/Context.cpp | 4 +--- src/Makefile.am | 21 +++++++++++---------- src/command.cpp | 18 +++++++++--------- src/interactive.cpp | 4 ++-- src/recur.cpp | 4 +++- src/task.cpp | 1 - 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index 7cb84dc7c..aa6b12c14 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -153,10 +153,8 @@ void Context::dispatch () } */ -/* bool gcMod = false; // Change occurred by way of gc. bool cmdMod = false; // Change occurred by way of command type. -*/ std::string out; /* // Read-only commands with no side effects. @@ -165,6 +163,7 @@ void Context::dispatch () if (cmd.command == "projects") { out = handleProjects (); } else if (cmd.command == "tags") { out = handleTags (); } else if (cmd.command == "colors") { out = handleColor (); } + else if (cmd.command == "version") { out = handleVersion (); } /* else if (command == "info") { out = handleInfo (); } else if (command == "stats") { out = handleReportStats (); } @@ -173,7 +172,6 @@ void Context::dispatch () else if (command == "calendar") { out = handleReportCalendar (); } else if (command == "summary") { out = handleReportSummary (); } else if (command == "timesheet") { out = handleReportTimesheet (); } - else if (command == "version") { out = handleVersion (); } else if (command == "help") { out = longUsage (); } // Commands that cause updates. diff --git a/src/Makefile.am b/src/Makefile.am index 0a35472a6..54d6cc0ed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,11 +1,12 @@ bin_PROGRAMS = task -task_SOURCES = Config.cpp Date.cpp Record.cpp T.cpp T2.cpp TDB.cpp TDB2.cpp \ - Att.cpp Filter.cpp Sequence.cpp Table.cpp Grid.cpp Timer.cpp \ - Duration.cpp StringTable.cpp Location.cpp Subst.cpp Keymap.cpp \ - Nibbler.cpp Context.cpp Cmd.cpp color.cpp parse.cpp task.cpp \ - edit.cpp command.cpp report.cpp util.cpp text.cpp rules.cpp \ - import.cpp interactive.cpp recur.cpp \ - Config.h Date.h Record.h T.h TDB.h Att.h Filter.h Sequence.h \ - Table.h Grid.h Timer.h Duration.h StringTable.h Location.h \ - Subst.h Keymap.h Nibbler.h Context.h Cmd.h color.h task.h - +task_SOURCES = Att.cpp Cmd.cpp Config.cpp Context.cpp Date.cpp Duration.cpp \ + Filter.cpp Grid.cpp Keymap.cpp Location.cpp Nibbler.cpp \ + Record.cpp Sequence.cpp StringTable.cpp Subst.cpp T2.cpp \ + TDB2.cpp Table.cpp Timer.cpp color.cpp command.cpp edit.cpp \ + import.cpp interactive.cpp parse.cpp recur.cpp report.cpp \ + rules.cpp task.cpp text.cpp utf8.cpp util.cpp \ + Att.h Cmd.h Config.h Context.h Date.h Duration.h Filter.h \ + Grid.h Keymap.h Location.h Nibbler.h Record.h Sequence.h \ + StringTable.h Subst.h T2.h TDB2.h Table.h Timer.h color.h \ + i18n.h task.h text.h utf8.h util.h \ + T.cpp T.h TDB.cpp TDB.h diff --git a/src/command.cpp b/src/command.cpp index 5a3aa1c97..25396c1db 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -270,7 +270,7 @@ std::string handleUndo () std::string handleVersion () { std::stringstream out; -/* + // Determine window size, and set table accordingly. int width = context.config.get ("defaultwidth", (int) 80); #ifdef HAVE_LIBNCURSES @@ -301,8 +301,8 @@ std::string handleVersion () link.setColumnJustification (0, Table::left); link.addCell (link.addRow (), 0, "See http://taskwarrior.org for the latest releases, online documentation " - "and lively discussion. New releases containing fixes and enhancements are " - "made frequently."); + "and lively discussion. New releases containing fixes and enhancements " + "are made frequently."); // Create a table for output. Table table; @@ -356,7 +356,7 @@ std::string handleVersion () // Complain about configuration variables that are not recognized. // These are the regular configuration variables. - // Note that there is a leading and trailing space. + // Note that there is a leading and trailing space, to make searching easier. std::string recognized = " blanklines color color.active color.due color.overdue color.pri.H " "color.pri.L color.pri.M color.pri.none color.recurring color.tagged " @@ -384,10 +384,10 @@ std::string handleVersion () { // These are special configuration variables, because their name is // dynamic. - if (i->find ("color.keyword.") == std::string::npos && - i->find ("color.project.") == std::string::npos && - i->find ("color.tag.") == std::string::npos && - i->find ("report.") == std::string::npos) + if (i->substr (0, 14) != "color.keyword." && + i->substr (0, 14) != "color.project." && + i->substr (0, 10) != "color.tag." && + i->substr (0, 7) != "report.") { unrecognized.push_back (*i); } @@ -423,7 +423,7 @@ std::string handleVersion () " that doesn't exist, or is unreadable." << std::endl; } -*/ + return out.str (); } diff --git a/src/interactive.cpp b/src/interactive.cpp index 9b3a93263..303b1924a 100644 --- a/src/interactive.cpp +++ b/src/interactive.cpp @@ -83,8 +83,8 @@ int Context::interactive () bkgdset (COLOR_PAIR (2)); int line = height / 2; - mvprintw (line, width / 2 - 14, " I n t e r a c t i v e t a s k "); - mvprintw (line + 1, width / 2 - 14, " Coming in version 2.0.0 "); + mvprintw (line, width / 2 - 16, " I n t e r a c t i v e t a s k "); + mvprintw (line + 1, width / 2 - 16, " Coming in version 2.0.0 "); std::string footer = "Press 'q' to quit."; while ((int) footer.length () < width) diff --git a/src/recur.cpp b/src/recur.cpp index b39e3d7bf..8ad33a125 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -56,8 +56,9 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// // Scans all tasks, and for any recurring tasks, determines whether any new // child tasks need to be generated to fill gaps. -void handleRecurrence (TDB& tdb, std::vector & tasks) +void handleRecurrence (std::vector & tasks) { +/* std::vector modified; // Look at all tasks and find any recurring ones. @@ -134,6 +135,7 @@ void handleRecurrence (TDB& tdb, std::vector & tasks) } tasks = modified; +*/ } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/task.cpp b/src/task.cpp index 55a89a012..53fb8aee8 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -462,7 +462,6 @@ std::string runTaskCommand ( else if (command == "calendar") { out = handleReportCalendar (tdb, task); } else if (command == "summary") { out = handleReportSummary (tdb, task); } else if (command == "timesheet") { out = handleReportTimesheet (tdb, task); } - else if (command == "version") { out = handleVersion ( ); } else if (command == "help") { out = longUsage ( ); } // Commands that cause updates.