- Implemented rc.verbose=on|off|list...
- Migrated rc.blanklines to a verbosity token.
- Updated documentation.
This commit is contained in:
Paul Beckingham 2011-05-11 21:49:31 -04:00
parent adc8605b06
commit 5fa77a36de
12 changed files with 65 additions and 13 deletions

View file

@ -70,6 +70,8 @@ std::string Config::defaults =
"\n"
"# Miscellaneous\n"
"verbose=yes # Provide extra feedback\n"
"#verbose=no # Provide minimal feedback\n"
"#verbose=blanklines # Provide controlled feedback\n"
"confirmation=yes # Confirmation on delete, big changes\n"
"echo.command=yes # Details on command just run\n"
"annotations=full # Level of verbosity for annotations: full, sparse or none\n"

View file

@ -27,6 +27,7 @@
#include <iostream>
#include <fstream>
#include <algorithm>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
@ -57,6 +58,7 @@ Context::Context ()
, cmd ()
, dom ()
, use_color (true)
, verbosity_legacy (false)
, inShadow (false)
, terminal_width (0)
, terminal_height (0)
@ -327,6 +329,24 @@ bool Context::color ()
config.getBoolean ("_forcecolor");
}
////////////////////////////////////////////////////////////////////////////////
bool Context::verbose (const std::string& token)
{
if (! verbosity.size ())
{
verbosity_legacy = config.getBoolean ("verbose");
split (verbosity, config.get ("verbose"), ',');
}
if (verbosity_legacy)
return true;
if (std::find (verbosity.begin (), verbosity.end (), token) != verbosity.end ())
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////
void Context::shadow ()
{

View file

@ -60,6 +60,7 @@ public:
int getHeight (); // determine terminal height
bool color (); // TTY or <other>?
bool verbose (const std::string&); // Verbosity control
void header (const std::string&); // Header message sink
void footnote (const std::string&); // Footnote message sink
@ -101,6 +102,8 @@ public:
DOM dom;
bool use_color;
bool verbosity_legacy;
std::vector <std::string> verbosity;
std::vector <std::string> headers;
std::vector <std::string> footnotes;
std::vector <std::string> debugMessages;

View file

@ -216,7 +216,11 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
out += headers[c][i];
}
out += extra + "\n";
out += extra;
// Trim right.
out.erase (out.find_last_not_of (" ") + 1);
out += "\n";
// Stop if the line limit is exceeded.
if (++_lines >= _truncate_lines && _truncate_lines != 0)
@ -269,7 +273,11 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
out += row_color.colorize (std::string (widths[c], ' '));
}
out += (odd ? extra_odd : extra_even) + "\n";
out += (odd ? extra_odd : extra_even);
// Trim right.
out.erase (out.find_last_not_of (" ") + 1);
out += "\n";
// Stop if the line limit is exceeded.
if (++_lines >= _truncate_lines && _truncate_lines != 0)

View file

@ -200,7 +200,11 @@ std::string ViewText::render ()
out += headers[c][i];
}
out += extra + "\n";
out += extra;
// Trim right.
out.erase (out.find_last_not_of (" ") + 1);
out += "\n";
// Stop if the line limit is exceeded.
if (++_lines >= _truncate_lines && _truncate_lines != 0)
@ -256,7 +260,11 @@ std::string ViewText::render ()
}
}
out += (odd ? extra_odd : extra_even) + "\n";
out += (odd ? extra_odd : extra_even);
// Trim right.
out.erase (out.find_last_not_of (" ") + 1);
out += "\n";
// Stop if the line limit is exceeded.
if (++_lines >= _truncate_lines && _truncate_lines != 0)

View file

@ -1093,7 +1093,7 @@ int handleShow (std::string& outs)
// Note that there is a leading and trailing space, to make it easier to
// search for whole words.
std::string recognized =
" annotations blanklines bulk burndown.bias calendar.details calendar.details.report "
" annotations bulk burndown.bias calendar.details calendar.details.report "
"calendar.holidays calendar.legend color calendar.offset calendar.offset.value "
"color.active color.due color.due.today color.blocked color.burndown.done "
"color.burndown.pending color.burndown.started color.overdue color.pri.H "

View file

@ -269,7 +269,7 @@ int handleCustomReport (const std::string& report, std::string& outs)
// Adjust for fluff in the output.
if (maxlines)
maxlines -= (context.config.getBoolean ("blanklines") ? 1 : 0)
maxlines -= (context.verbose ("blanklines") ? 1 : 0)
+ table_header
+ context.headers.size ()
+ context.footnotes.size ();

View file

@ -402,10 +402,7 @@ std::string ucFirst (const std::string& input)
////////////////////////////////////////////////////////////////////////////////
const char* optionalBlankLine ()
{
if (context.config.getBoolean ("blanklines") == true) // no i18n
return newline;
return noline;
return context.verbose ("blanklines") ? newline : noline;
}
////////////////////////////////////////////////////////////////////////////////