mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-24 08:56:43 +02:00
Feature
- Add the configuration variable 'print.empty.columns'. - If this variable is set to 'no', columns with all empty values are not printed. This variable defaults to 'yes' (thus nothing is changed by default). - Updated taskrc.5.in to mention the new variable. - Added unit tests.
This commit is contained in:
parent
a7b20b7a4e
commit
d7c225c87b
6 changed files with 92 additions and 4 deletions
|
@ -289,6 +289,7 @@ std::string Config::_defaults =
|
|||
"complete.all.tags=no # Include old tag names in '_ags' command\n"
|
||||
"list.all.projects=no # Include old project names in 'projects' command\n"
|
||||
"list.all.tags=no # Include old tag names in 'tags' command\n"
|
||||
"print.empty.columns=yes # Print columns which have no data for any task\n"
|
||||
"debug=no # Display diagnostics\n"
|
||||
"extensions=off # Extension system master switch\n"
|
||||
"fontunderline=yes # Uses underlines rather than -------\n"
|
||||
|
|
|
@ -113,6 +113,9 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
|||
{
|
||||
context.timer_render.start ();
|
||||
|
||||
bool const print_empty_columns = context.config.getBoolean ("print.empty.columns");
|
||||
std::vector <Column*> nonempty_columns;
|
||||
|
||||
// Determine minimal, ideal column widths.
|
||||
std::vector <int> minimal;
|
||||
std::vector <int> ideal;
|
||||
|
@ -121,7 +124,7 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
|||
for (i = _columns.begin (); i != _columns.end (); ++i)
|
||||
{
|
||||
// Headers factor in to width calculations.
|
||||
int global_min = utf8_length ((*i)->label ());
|
||||
int global_min = 0;
|
||||
int global_ideal = global_min;
|
||||
|
||||
for (unsigned int s = 0; s < sequence.size (); ++s)
|
||||
|
@ -141,10 +144,24 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
|||
if (ideal > global_ideal) global_ideal = ideal;
|
||||
}
|
||||
|
||||
minimal.push_back (global_min);
|
||||
ideal.push_back (global_ideal);
|
||||
if (print_empty_columns || global_min != 0)
|
||||
{
|
||||
int label_length = utf8_length ((*i)->label ());
|
||||
if (label_length > global_min) global_min = label_length;
|
||||
if (label_length > global_ideal) global_ideal = label_length;
|
||||
minimal.push_back (global_min);
|
||||
ideal.push_back (global_ideal);
|
||||
}
|
||||
|
||||
if (!print_empty_columns && global_min != 0)
|
||||
{
|
||||
nonempty_columns.push_back(*i);
|
||||
}
|
||||
}
|
||||
|
||||
if (!print_empty_columns)
|
||||
_columns = nonempty_columns;
|
||||
|
||||
// Sum the minimal widths.
|
||||
int sum_minimal = 0;
|
||||
std::vector <int>::iterator c;
|
||||
|
|
|
@ -85,7 +85,11 @@ void ColumnPriority::measure (Task& task, int& minimum, int& maximum)
|
|||
{
|
||||
std::string priority = task.get (_name);
|
||||
|
||||
minimum = maximum = 1;
|
||||
if (priority == "")
|
||||
minimum = maximum = 0;
|
||||
else
|
||||
minimum = maximum = 1;
|
||||
|
||||
if (_style == "long")
|
||||
{
|
||||
if (priority == "H") minimum = maximum = 4;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue