Navigator: implement extension by (partial) UI-Coordinate spec

rationale: sometimes (likely this is even the standard case) we do not just
want to "extend", rather we want to extent at very specific levels.

This is easy to implement, based on the existing building blocks for path manipulation
This commit is contained in:
Fischlurch 2018-01-09 00:50:54 +01:00
parent 55c196e5a2
commit ff24f81d3f
3 changed files with 48 additions and 1 deletions

View file

@ -59,6 +59,7 @@
#include "lib/error.hpp" #include "lib/error.hpp"
#include "lib/symbol.hpp" #include "lib/symbol.hpp"
#include "lib/format-string.hpp"
#include "gui/interact/ui-coord.hpp" #include "gui/interact/ui-coord.hpp"
#include "lib/iter-tree-explorer.hpp" #include "lib/iter-tree-explorer.hpp"
#include "lib/iter-source.hpp" #include "lib/iter-source.hpp"
@ -372,7 +373,29 @@ namespace interact {
UICoordResolver&& UICoordResolver&&
extend (UICoord const& partialExtensionSpec) extend (UICoord const& partialExtensionSpec)
{ {
UNIMPLEMENTED ("extend by UI-Coordinates"); if (not canCover())
{
uic_ = partialExtensionSpec;
}
else
{
ENSURE (res_.isResolved and res_.covfefe);
size_t coverable = res_.covfefe->size();
auto newContent = partialExtensionSpec.begin();
size_t extensionPos = newContent? partialExtensionSpec.indexOf(*newContent) : 0;
if (coverable >= extensionPos)
throw error::Invalid (util::_Fmt{"Attempt to extend covered path %s with %s "
"would overwrite positions %d to %d (incl)"}
% *res_.covfefe
% partialExtensionSpec
% extensionPos
% coverable);
cover();
for ( ; newContent; ++newContent, ++extensionPos )
overwrite (extensionPos, *newContent);
}
res_.depth = query_.determineCoverage (this->uic_); // coverage may grow
return std::move (*this);
} }

View file

@ -599,6 +599,14 @@ namespace interact {
uic_.normalise(); uic_.normalise();
return std::move (*this); return std::move (*this);
} }
Builder&&
overwrite (size_t depth, Literal newSpec)
{
Literal* storage = uic_.expandPosition (depth);
uic_.setContent (storage, newSpec);
return std::move (*this);
}
}; };

View file

@ -8944,6 +8944,13 @@
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515451127221" ID="ID_130067342" MODIFIED="1515451168209" TEXT="durch (partielle) UI-Coord spec"> <node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515451127221" ID="ID_130067342" MODIFIED="1515451168209" TEXT="durch (partielle) UI-Coord spec">
<linktarget COLOR="#4f6f95" DESTINATION="ID_130067342" ENDARROW="Default" ENDINCLINATION="544;89;" ID="Arrow_ID_992203487" SOURCE="ID_1736775031" STARTARROW="None" STARTINCLINATION="704;0;"/> <linktarget COLOR="#4f6f95" DESTINATION="ID_130067342" ENDARROW="Default" ENDINCLINATION="544;89;" ID="Arrow_ID_992203487" SOURCE="ID_1736775031" STARTARROW="None" STARTINCLINATION="704;0;"/>
<icon BUILTIN="flag-yellow"/> <icon BUILTIN="flag-yellow"/>
<node CREATED="1515455194222" ID="ID_1550640486" MODIFIED="1515455202609" TEXT="brauche (nun doch) overwrite">
<node CREATED="1515455204572" ID="ID_538708318" MODIFIED="1515455215023" TEXT="im UI-Coord-Builder ansiedeln"/>
<node CREATED="1515455215779" ID="ID_1744879837" MODIFIED="1515455225131" TEXT="protected....">
<icon BUILTIN="smiley-neutral"/>
</node>
</node>
<node CREATED="1515455238808" ID="ID_1864948105" MODIFIED="1515455247459" TEXT="Fehlerbehandlung: &#xdc;berlapp finden"/>
</node> </node>
</node> </node>
</node> </node>
@ -9372,6 +9379,15 @@
</node> </node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515451047192" ID="ID_554336668" MODIFIED="1515451078845" TEXT="erweitern scheitert wegen &#xdc;berlapp"> <node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515451047192" ID="ID_554336668" MODIFIED="1515451078845" TEXT="erweitern scheitert wegen &#xdc;berlapp">
<icon BUILTIN="flag-yellow"/> <icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515455278659" ID="ID_1749331083" MODIFIED="1515455288490" TEXT="pr&#xe4;ziser Anschlu&#xdf; funktioniert">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515455289417" ID="ID_228177396" MODIFIED="1515455317398" TEXT="&#xdc;berlapp == 1 scheitert">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515455296784" ID="ID_957569216" MODIFIED="1515455313258" TEXT="sinnvolle Fehlermeldung">
<icon BUILTIN="flag-yellow"/>
</node>
</node> </node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515449669446" ID="ID_1747646759" MODIFIED="1515449741572" TEXT="partially covered erweitern"> <node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515449669446" ID="ID_1747646759" MODIFIED="1515449741572" TEXT="partially covered erweitern">
<icon BUILTIN="flag-yellow"/> <icon BUILTIN="flag-yellow"/>