mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Context
- Improved sort column parsing to include an optional trailing solidus, in addition to the +/- sort direction.
This commit is contained in:
parent
9c2aea6d62
commit
bd7e66a939
3 changed files with 17 additions and 7 deletions
|
@ -694,19 +694,28 @@ void Context::createDefaultConfig ()
|
||||||
void Context::decomposeSortField (
|
void Context::decomposeSortField (
|
||||||
const std::string& field,
|
const std::string& field,
|
||||||
std::string& key,
|
std::string& key,
|
||||||
bool& ascending)
|
bool& ascending,
|
||||||
|
bool& breakIndicator)
|
||||||
{
|
{
|
||||||
int length = field.length ();
|
int length = field.length ();
|
||||||
|
|
||||||
if (field[length - 1] == '+')
|
int decoration = 1;
|
||||||
|
breakIndicator = false;
|
||||||
|
if (field[length - decoration] == '/')
|
||||||
|
{
|
||||||
|
breakIndicator = true;
|
||||||
|
++decoration;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field[length - decoration] == '+')
|
||||||
{
|
{
|
||||||
ascending = true;
|
ascending = true;
|
||||||
key = field.substr (0, length - 1);
|
key = field.substr (0, length - decoration);
|
||||||
}
|
}
|
||||||
else if (field[length - 1] == '-')
|
else if (field[length - decoration] == '-')
|
||||||
{
|
{
|
||||||
ascending = false;
|
ascending = false;
|
||||||
key = field.substr (0, length - 1);
|
key = field.substr (0, length - decoration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
void clearMessages ();
|
void clearMessages ();
|
||||||
void clear ();
|
void clear ();
|
||||||
|
|
||||||
void decomposeSortField (const std::string&, std::string&, bool&);
|
void decomposeSortField (const std::string&, std::string&, bool&, bool&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void staticInitialization ();
|
void staticInitialization ();
|
||||||
|
|
|
@ -71,6 +71,7 @@ static bool sort_compare (int left, int right)
|
||||||
{
|
{
|
||||||
std::string field;
|
std::string field;
|
||||||
bool ascending;
|
bool ascending;
|
||||||
|
bool breakIndicator;
|
||||||
Column* column;
|
Column* column;
|
||||||
int left_number;
|
int left_number;
|
||||||
int right_number;
|
int right_number;
|
||||||
|
@ -82,7 +83,7 @@ static bool sort_compare (int left, int right)
|
||||||
std::vector <std::string>::iterator k;
|
std::vector <std::string>::iterator k;
|
||||||
for (k = global_keys.begin (); k != global_keys.end (); ++k)
|
for (k = global_keys.begin (); k != global_keys.end (); ++k)
|
||||||
{
|
{
|
||||||
context.decomposeSortField (*k, field, ascending);
|
context.decomposeSortField (*k, field, ascending, breakIndicator);
|
||||||
|
|
||||||
// Urgency.
|
// Urgency.
|
||||||
if (field == "urgency")
|
if (field == "urgency")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue