mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
DOM
- Migrated DOM off A3, onto A3t. First live use of new parser.
This commit is contained in:
parent
d99f40eaad
commit
0dc73d759b
3 changed files with 17 additions and 7 deletions
|
@ -168,10 +168,6 @@ int Context::initialize (int argc, const char** argv)
|
|||
a3t.entity ("readcmd", cmd->first);
|
||||
else
|
||||
a3t.entity ("writecmd", cmd->first);
|
||||
|
||||
// TODO Entities: Reports.
|
||||
// TODO Entities: Special commands.
|
||||
// TODO Need: bool Command::report() - maybe not.
|
||||
}
|
||||
|
||||
// Instantiate built-in column objects.
|
||||
|
|
17
src/DOM.cpp
17
src/DOM.cpp
|
@ -89,8 +89,21 @@ const std::string DOM::get (const std::string& name)
|
|||
if (len > 8 &&
|
||||
name.substr (0, 8) == "context.")
|
||||
{
|
||||
if (name == "context.program") return context.a3[0]._raw;
|
||||
else if (name == "context.args") return context.a3.combine ();
|
||||
if (name == "context.program") return context.a3t.tree ()->_branches[0]->attribute ("raw");
|
||||
else if (name == "context.args")
|
||||
{
|
||||
std::string combined;
|
||||
std::vector <Tree*>::iterator i;
|
||||
for (i = context.a3t.tree ()->_branches.begin (); i != context.a3t.tree ()->_branches.end (); ++i)
|
||||
{
|
||||
if (combined != "")
|
||||
combined += " ";
|
||||
|
||||
combined += (*i)->attribute ("raw");
|
||||
}
|
||||
|
||||
return combined;
|
||||
}
|
||||
else if (name == "context.width") return format (context.terminal_width ? context.terminal_width : context.getWidth ());
|
||||
else if (name == "context.height") return format (context.terminal_height ? context.terminal_height : context.getHeight ());
|
||||
else throw format (STRING_DOM_UNREC, name);
|
||||
|
|
|
@ -249,6 +249,7 @@ int longestLine (const std::string& input)
|
|||
return longest;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Walk the input text looking for a break point. A break point is one of:
|
||||
// - EOS
|
||||
// - \n
|
||||
|
@ -256,7 +257,7 @@ int longestLine (const std::string& input)
|
|||
// - last punctuation (, ; . :) before 'length' characters, even if not
|
||||
// followed by a space
|
||||
// - first 'length' characters
|
||||
|
||||
//
|
||||
// text "one two three\n four"
|
||||
// bytes 0123456789012 3456789
|
||||
// characters 1234567890a23 4567890
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue