DOM: New references: tw.syncneeded, tw.program, tw.args, tw.width, tw.height

- And deprecating context.program, context.args, context.width, context.height
This commit is contained in:
Paul Beckingham 2017-02-25 19:21:24 -05:00
parent 545a764450
commit a92f596bc0
4 changed files with 87 additions and 10 deletions

View file

@ -88,6 +88,7 @@
- Added 'history.weekly', 'history.daily', 'ghistory.weekly', 'ghistory.daily'
report variations, with code refactoring.
(thanks to Lukas Barth).
- New DOM references: annotations.count, tw.syncneeded.
------ current release ---------------------------

6
NEWS
View file

@ -3,7 +3,8 @@ New Features in Taskwarrior 2.6.0
- The 'QUARTER' virtual tag was added.
- Improved compatibility with SmartOS, OmniOS and OpenIndiana.
- New DOM reference: annotations.count.
- New DOM references: annotations.count, tw.syncneeded, tw.program, tw.args,
tw.width, tw.height.
- Renovated 'timesheet' command with a more compact report that accepts a
filter, and has a default filter showing the last four weeks of completed
and started tasks.
@ -30,6 +31,9 @@ Newly Deprecated Features in Taskwarrior 2.6.0
"0" for off, and "1" for on. Avoid used of "on", "off", "true", "t",
"false", "f", "yes", "y", "no", "n".
- The 'PARENT' and 'CHILD' virtual tags are replaced by 'TEMPLATE' and 'INSTANCE'.
- The 'context.program', 'context.args', 'context.width' and 'context.height'
DOM references are deprecated, replaced by similarly-named 'tw.xxx'
references.
Removed Features in 2.6.0

View file

@ -47,11 +47,18 @@ extern Context context;
// Configuration:
// rc.<name>
//
// Taskwarrior:
// tw.syncneeded
// tw.program
// tw.args
// tw.width
// tw.height
//
// System:
// context.program
// context.args
// context.width
// context.height
// context.program // 2017-02-25 Deprecated in 2.6.0
// context.args // 2017-02-25 Deprecated in 2.6.0
// context.width // 2017-02-25 Deprecated in 2.6.0
// context.height // 2017-02-25 Deprecated in 2.6.0
// system.version
// system.os
//
@ -78,6 +85,61 @@ bool getDOM (const std::string& name, Variant& value)
return false;
}
// tw.*
if (len > 3 &&
! name.compare (0, 3, "tw.", 3))
{
if (name == "tw.syncneeded")
{
value = Variant (false);
for (const auto& line : context.tdb2.backlog.get_lines ())
{
if (line[0] == '{')
{
value = Variant (true);
break;
}
}
return true;
}
else if (name == "tw.program")
{
value = Variant (context.cli2.getBinary ());
return true;
}
else if (name == "tw.args")
{
std::string commandLine;
for (auto& arg : context.cli2._original_args)
{
if (commandLine != "")
commandLine += ' ';
commandLine += arg.attribute("raw");
}
value = Variant (commandLine);
return true;
}
else if (name == "tw.width")
{
value = Variant (static_cast<int> (context.terminal_width
? context.terminal_width
: context.getWidth ()));
return true;
}
else if (name == "tw.height")
{
value = Variant (static_cast<int> (context.terminal_height
? context.terminal_height
: context.getHeight ()));
return true;
}
else
throw format (STRING_DOM_UNREC, name);
}
// context.*
if (len > 8 &&
! name.compare (0, 8, "context.", 8))

View file

@ -1132,10 +1132,15 @@ bool Lexer::isOperator (std::string& token, Lexer::Type& type)
// rc.<name>
//
// System:
// context.program
// context.args
// context.width
// context.height
// tw.syncneeded
// tw.program
// tw.args
// tw.width
// tw.height
// context.program // 2017-02-25 Deprecated in 2.6.0
// context.args // 2017-02-25 Deprecated in 2.6.0
// context.width // 2017-02-25 Deprecated in 2.6.0
// context.height // 2017-02-25 Deprecated in 2.6.0
// system.version
// system.os
//
@ -1179,7 +1184,12 @@ bool Lexer::isDOM (std::string& token, Lexer::Type& type)
else
_cursor = marker;
if (isOneOf ({"context.program",
if (isOneOf ({"tw.syncneeded",
"tw.program",
"tw.args",
"tw.width",
"tw.height",
"context.program",
"context.args",
"context.width",
"context.height",