From 43266a825f25eb53a81d2e16a3542f6b3a1e1f4d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 25 Jul 2010 14:50:20 -0400 Subject: [PATCH] Feature #391 - legendary enhancement - Added feature #391, now the 'task color legend' command will show samples of all the defined colors and color rules from your .taskrc and theme. --- ChangeLog | 3 +++ NEWS | 3 ++- doc/man/task-color.5 | 9 +++++++++ doc/man/task.1 | 5 +++-- src/command.cpp | 30 ++++++++++++++++++++++++++++-- src/report.cpp | 6 ++++-- 6 files changed, 49 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index cfadb9f16..265d81c55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ 1.9.3 () + Added feature #189, that records the start and stop times as an annotation for a task. + + Added feature #391, now the 'task color legend' command will show + samples of all the defined colors and color rules from your .taskrc + and theme. + Added feature #423, now custom report filters allow rc overrides. + Added feature #428, preparing the new structure for the NEWS file. + Added feature #429, which improves the 'all' report to exclude deleted. diff --git a/NEWS b/NEWS index 160563615..6b21fb258 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,8 @@ New Features in task 1.9.3 New commands in task 1.9.3 - - + - New 'task color legend' command will show samples of all the defined colors + and color rules from your .taskrc and theme. - New configuration options in task 1.9.3 diff --git a/doc/man/task-color.5 b/doc/man/task-color.5 index 678a5c667..759028106 100644 --- a/doc/man/task-color.5 +++ b/doc/man/task-color.5 @@ -193,6 +193,15 @@ color1, and proceed. Note that red and color1 are not quite the same. Note also that there is no bold or bright attributes when dealing with 256 colors, but there is still underline available. +.SH LEGEND +Task will show examples of all defined colors used in your .taskrc, or theme, +if you run this command: + + $ task color legend + +This gives you an example of each of the colors, so you can see the effect, +without necessarily creating a set of tasks that meet each of the rule criteria. + .SH RULES Task supports colorization rules. These are configuration values that specify a color, and the conditions under which that color is used. By example, let's diff --git a/doc/man/task.1 b/doc/man/task.1 index 07f8c92d5..9ab2ee985 100644 --- a/doc/man/task.1 +++ b/doc/man/task.1 @@ -133,8 +133,9 @@ Exports all tasks in iCalendar format. Redirect the output to a file, if you wish to save it, or pipe it to another command. .TP -.B color [sample] -Displays all possible colors, or a sample. +.B color [sample | legend] +Displays all possible colors, a named sample, or a legend containing all +currently defined colors. .TP .B version diff --git a/src/command.cpp b/src/command.cpp index b3ad482fc..c6f422499 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1863,10 +1863,36 @@ int handleColor (std::string &outs) if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) { + // If the description contains 'legend', show all the colors currently in + // use. + std::string description = context.task.get ("description"); + if (description.find ("legend") != std::string::npos) + { + out << std::endl + << "Here are the colors currently in use:" + << std::endl; + + std::vector all; + context.config.all (all); + foreach (item, all) + { + if (*item != "_forcecolor" && + *item != "color" && + item->find ("color") != std::string::npos) + { + out << " " + << Color::colorize (" " + *item + " ", + context.config.get (*item)) + << std::endl; + } + } + + out << std::endl; + } + // If there is something in the description, then assume that is a color, // and display it as a sample. - std::string description = context.task.get ("description"); - if (description != "") + else if (description != "") { Color one ("black on bright yellow"); Color two ("underline cyan on bright blue"); diff --git a/src/report.cpp b/src/report.cpp index 569cc7332..8d1580ed1 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -24,6 +24,7 @@ // USA // //////////////////////////////////////////////////////////////////////////////// + #include #include #include @@ -205,8 +206,9 @@ int shortUsage (std::string &outs) table.addCell (row, 2, "Lists all tasks in iCalendar format."); row = table.addRow (); - table.addCell (row, 1, "task color [sample]"); - table.addCell (row, 2, "Displays all possible colors, or a sample."); + table.addCell (row, 1, "task color [sample | legend]"); + table.addCell (row, 2, "Displays all possible colors, a named sample, or a " + "legend containing all currently defined colors."); row = table.addRow (); table.addCell (row, 1, "task version");