From fe85e28605da0698a38872c49ab07a94d229bfb4 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 26 Nov 2010 19:32:37 -0500 Subject: [PATCH] Show Command Defaults - Added highlighting for the show command that indicates which values differ from the defaults. --- ChangeLog | 2 ++ NEWS | 2 ++ src/command.cpp | 25 ++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 980b3580a..3cecebe1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ + Added burndown charts - burndown.daily, burndown.weekly, burndown.monthly, that use color.burndown.pending, color.burndown.started and color.burndown.done colors. + + Added highlighting for the show command that indicates which values differ + from the defaults. + Added feature #158, regular expression support for filters and substitutions. + Added feature #247, providing infinite width reports when redirecting output to a file, by setting defaultwidth to 0. diff --git a/NEWS b/NEWS index 120976d34..2cddbc81f 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ New Features in taskwarrior 1.9.4 - New 'count' helper command. - Inifinite width reports, when redirecting output. - Regular expression support in filters and substitutions. + - Added highlighting for the show command that indicates which values differ + from the defaults. Please refer to the ChangeLog file for full details. There are too many to list here. diff --git a/src/command.cpp b/src/command.cpp index 4ebd3a418..e58ecdb42 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -958,6 +958,15 @@ int handleShow (std::string& outs) } } + // Find all the values that match the defaults, for highlighting. + std::vector default_values; + Config default_config; + default_config.setDefaults (); + + foreach (i, all) + if (context.config.get (*i) != default_config.get (*i)) + default_values.push_back (*i); + // Create a table for output. Table table; table.setTableWidth (width); @@ -980,6 +989,7 @@ int handleShow (std::string& outs) table.sortOn (0, Table::ascendingCharacter); Color error ("bold white on red"); + Color warning ("black on yellow"); std::string section; @@ -1001,8 +1011,13 @@ int handleShow (std::string& outs) // Look for unrecognized. if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) + { if (std::find (unrecognized.begin (), unrecognized.end (), *i) != unrecognized.end ()) table.setRowColor (row, error); + + else if (std::find (default_values.begin (), default_values.end (), *i) != default_values.end ()) + table.setRowColor (row, warning); + } } } @@ -1021,7 +1036,15 @@ int handleShow (std::string& outs) if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) out << "\n These are highlighted in " << error.colorize ("color") << " above."; - out << "\n"; + out << "\n\n"; + } + + if (default_values.size ()) + { + out << "Some of your .taskrc variables differ from the default values."; + + if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) + out << " These are highlighted in " << warning.colorize ("color") << " above."; } out << context.config.checkForDeprecatedColor ();