diff --git a/ChangeLog b/ChangeLog index 252b76f67..4e5f63679 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 --------------------------- diff --git a/NEWS b/NEWS index 4d193142a..34281c357 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/src/DOM.cpp b/src/DOM.cpp index bcca43e9c..c4f1acd88 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -47,11 +47,18 @@ extern Context context; // Configuration: // rc. // +// 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 (context.terminal_width + ? context.terminal_width + : context.getWidth ())); + return true; + } + else if (name == "tw.height") + { + value = Variant (static_cast (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)) diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 486229499..376f40fc7 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -1132,10 +1132,15 @@ bool Lexer::isOperator (std::string& token, Lexer::Type& type) // rc. // // 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",