- Configurable extra white space via "blanklines" configuration variable.

This commit is contained in:
Paul Beckingham 2008-06-07 13:23:39 -04:00
parent ccd2b9fc44
commit e025ecc3d4
3 changed files with 42 additions and 29 deletions

View file

@ -350,9 +350,9 @@ void handleProjects (const TDB& tdb, T& task, Config& conf)
table.addCell (row, 1, i->second); table.addCell (row, 1, i->second);
} }
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< unique.size () << unique.size ()
<< (unique.size () == 1 ? " project" : " projects") << (unique.size () == 1 ? " project" : " projects")
<< std::endl; << std::endl;
@ -384,11 +384,12 @@ void handleTags (const TDB& tdb, T& task, Config& conf)
} }
// Render a list of tag names from the map. // Render a list of tag names from the map.
std::cout << optionalBlankLine (conf);
foreach (i, unique) foreach (i, unique)
std::cout << i->first << std::endl; std::cout << i->first << std::endl;
if (unique.size ()) if (unique.size ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< unique.size () << unique.size ()
<< (unique.size () == 1 ? " tag" : " tags") << (unique.size () == 1 ? " tag" : " tags")
<< std::endl; << std::endl;
@ -561,9 +562,9 @@ void handleList (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< table.rowCount () << table.rowCount ()
<< (table.rowCount () == 1 ? " task" : " tasks") << (table.rowCount () == 1 ? " task" : " tasks")
<< std::endl; << std::endl;
@ -722,9 +723,9 @@ void handleSmallList (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< table.rowCount () << table.rowCount ()
<< (table.rowCount () == 1 ? " task" : " tasks") << (table.rowCount () == 1 ? " task" : " tasks")
<< std::endl; << std::endl;
@ -843,9 +844,9 @@ void handleCompleted (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< table.rowCount () << table.rowCount ()
<< (table.rowCount () == 1 ? " task" : " tasks") << (table.rowCount () == 1 ? " task" : " tasks")
<< std::endl; << std::endl;
@ -1004,9 +1005,9 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< table.rowCount () << table.rowCount ()
<< (table.rowCount () == 1 ? " task" : " tasks") << (table.rowCount () == 1 ? " task" : " tasks")
<< std::endl; << std::endl;
@ -1202,9 +1203,9 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< table.rowCount () << table.rowCount ()
<< (table.rowCount () == 1 ? " task" : " tasks") << (table.rowCount () == 1 ? " task" : " tasks")
<< std::endl; << std::endl;
@ -1348,9 +1349,9 @@ void handleReportSummary (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< table.rowCount () << table.rowCount ()
<< (table.rowCount () == 1 ? " project" : " projects") << (table.rowCount () == 1 ? " project" : " projects")
<< std::endl; << std::endl;
@ -1545,9 +1546,9 @@ void handleReportNext (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< table.rowCount () << table.rowCount ()
<< (table.rowCount () == 1 ? " task" : " tasks") << (table.rowCount () == 1 ? " task" : " tasks")
<< std::endl; << std::endl;
@ -1728,7 +1729,7 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl; << std::endl;
else else
@ -1791,7 +1792,7 @@ void handleReportUsage (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl; << std::endl;
else else
@ -1911,8 +1912,8 @@ void handleReportCalendar (const TDB& tdb, T& task, Config& conf)
std::cout << Date::monthName (mFrom) std::cout << Date::monthName (mFrom)
<< " " << " "
<< yFrom << yFrom
<< std::endl << optionalBlankLine (conf)
<< std::endl << optionalBlankLine (conf)
<< renderMonth (mFrom, yFrom, today, pending, conf) << renderMonth (mFrom, yFrom, today, pending, conf)
<< std::endl; << std::endl;
@ -1930,7 +1931,7 @@ void handleReportCalendar (const TDB& tdb, T& task, Config& conf)
<< ", " << ", "
<< Text::colorize (Text::black, Text::on_red, "overdue") << Text::colorize (Text::black, Text::on_red, "overdue")
<< "." << "."
<< std::endl << optionalBlankLine (conf)
<< std::endl; << std::endl;
} }
@ -2046,9 +2047,9 @@ void handleReportActive (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< table.rowCount () << table.rowCount ()
<< (table.rowCount () == 1 ? " task" : " tasks") << (table.rowCount () == 1 ? " task" : " tasks")
<< std::endl; << std::endl;
@ -2162,9 +2163,9 @@ void handleReportOverdue (const TDB& tdb, T& task, Config& conf)
} }
if (table.rowCount ()) if (table.rowCount ())
std::cout << std::endl std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()
<< std::endl << optionalBlankLine (conf)
<< table.rowCount () << table.rowCount ()
<< (table.rowCount () == 1 ? " task" : " tasks") << (table.rowCount () == 1 ? " task" : " tasks")
<< std::endl; << std::endl;
@ -2309,7 +2310,6 @@ void handleVersion (Config& conf)
<< "under certain conditions; again, see the COPYING file for details." << "under certain conditions; again, see the COPYING file for details."
<< std::endl << std::endl
<< std::endl << std::endl
<< std::endl
<< table.render () << table.render ()
<< std::endl; << std::endl;
@ -2515,7 +2515,7 @@ void handleModify (const TDB& tdb, T& task, Config& conf)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void handleColor (Config& conf) void handleColor (Config& conf)
{ {
std::cout << std::endl << "Foreground" << std::endl std::cout << optionalBlankLine (conf) << "Foreground" << std::endl
<< " " << " "
<< Text::colorize (Text::bold, Text::nocolor, "bold") << " " << Text::colorize (Text::bold, Text::nocolor, "bold") << " "
<< Text::colorize (Text::underline, Text::nocolor, "underline") << " " << Text::colorize (Text::underline, Text::nocolor, "underline") << " "
@ -2586,7 +2586,7 @@ void handleColor (Config& conf)
<< " " << Text::colorize (Text::nocolor, Text::on_white, "on_white") << " " << " " << Text::colorize (Text::nocolor, Text::on_white, "on_white") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_white, "on_bright_white") << std::endl << Text::colorize (Text::nocolor, Text::on_bright_white, "on_bright_white") << std::endl
<< std::endl; << optionalBlankLine (conf);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -97,6 +97,7 @@ int autoComplete (const std::string&, const std::vector<std::string>&, std::vect
void formatTimeDeltaDays (std::string&, time_t); void formatTimeDeltaDays (std::string&, time_t);
std::string formatSeconds (time_t); std::string formatSeconds (time_t);
const std::string uuid (); const std::string uuid ();
const char* optionalBlankLine (Config&);
// rules.cpp // rules.cpp
void initializeColorRules (Config&); void initializeColorRules (Config&);

View file

@ -29,6 +29,9 @@
#include <string> #include <string>
#include "task.h" #include "task.h"
static const char* newline = "\n";
static const char* noline = "";
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void wrapText ( void wrapText (
std::vector <std::string>& lines, std::vector <std::string>& lines,
@ -283,3 +286,12 @@ std::string lowerCase (const std::string& input)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const char* optionalBlankLine (Config& conf)
{
if (conf.get ("blanklines", true) == true)
return newline;
return noline;
}
////////////////////////////////////////////////////////////////////////////////