From 964d1aa93e9a2f52a416fa5030e556d09548c252 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 2 Jun 2015 13:03:19 -0400 Subject: [PATCH] Review: Usability/feedback improvements - Added a full-width colored banner to track progress through the review set. - Added a colored prompt for per-task actions. - Removed debug output. --- src/review.cpp | 64 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/src/review.cpp b/src/review.cpp index 4ebe10d..a5afd55 100644 --- a/src/review.cpp +++ b/src/review.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -42,6 +43,7 @@ #include #endif +#include #include #include #include @@ -106,44 +108,68 @@ static void deleteTask (const std::string& uuid) std::cout << STRING_REVIEW_DELETED << "\n"; } +//////////////////////////////////////////////////////////////////////////////// +static const std::string banner ( + unsigned int current, + unsigned int total, + unsigned int width, + const std::string& message) +{ + std::stringstream out; + out << " [" + << current + << " of " + << total + << "] " + << message; + + out << std::string (width - out.str ().length () - 1, ' '); + + Color color ("white on blue"); + return color.colorize (out.str ()) + "\n"; +} + +//////////////////////////////////////////////////////////////////////////////// +static const std::string menu () +{ + Color text ("white on blue"); + return text.colorize (" (Enter) Skip, (e)dit, (c)ompleted, (d)eleted, Mark as (r)eviewed, (q)uit "); +} + //////////////////////////////////////////////////////////////////////////////// static void reviewLoop (const std::vector & uuids) { auto tasks = 0; auto total = uuids.size (); + auto width = getWidth (); unsigned int current = 0; while (current < total) { - auto uuid = uuids[current]; - std::cout << "# [" << current << "] uuid '" << uuid << "'\n"; + // Display banner for this task. + std::cout << banner (current + 1, total, width, ""); - // TODO Run 'info' report for task + // Run 'info' report for task. + auto uuid = uuids[current]; std::string command = "task " + uuid + " information"; - std::cout << "# [" << current << "] command '" << command << "'\n"; system (command.c_str ()); - // TODO Add prompt context ' ( of )' - std::string prompt = "(Enter) Skip, (e)dit, (c)ompleted, (d)eleted, Mark as (r)eviewed, (q)uit "; - // Display prompt, get input. - command = getResponse (prompt); + auto response = getResponse (menu ()); - if (command == "e") { editTask (uuid); ++current; } - else if (command == "r") { reviewTask (uuid); ++current; } - else if (command == "c") { completeTask (uuid); ++current; } - else if (command == "d") { deleteTask (uuid); ++current; } - else if (command == "q") { break; } - else if (command == "") { std::cout << "Skipped\n"; ++current; } + if (response == "e") { editTask (uuid); ++current; } + else if (response == "r") { reviewTask (uuid); ++current; } + else if (response == "c") { completeTask (uuid); ++current; } + else if (response == "d") { deleteTask (uuid); ++current; } + else if (response == "q") { break; } + else if (response == "") { std::cout << "Skipped\n"; ++current; } else { - std::cout << format (STRING_REVIEW_UNRECOGNIZED, command) << "\n"; + std::cout << format (STRING_REVIEW_UNRECOGNIZED, response) << "\n"; } // Note that just hitting yields an empty command, which does // nothing but advance to the next task. - - // TODO Remove prompt context. } std::cout << format (STRING_REVIEW_END, tasks, total) << "\n"; @@ -161,9 +187,9 @@ int cmdReview (const std::vector & args) output); if (status || output != "date\n") { - execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.type", "date"}, input, output); + execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.type", "date"}, input, output); execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.label", "Reviewed"}, input, output); - execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "review.period", "1week"}, input, output); + execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "review.period", "1week"}, input, output); } // Obtain a list of UUIDs to review.