From ff24f81d3f9e4107723e5953e48eb17c17311f68 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 9 Jan 2018 00:50:54 +0100 Subject: [PATCH] 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 --- src/gui/interact/ui-coord-resolver.hpp | 25 ++++++++++++++++++++++++- src/gui/interact/ui-coord.hpp | 8 ++++++++ wiki/thinkPad.ichthyo.mm | 16 ++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/gui/interact/ui-coord-resolver.hpp b/src/gui/interact/ui-coord-resolver.hpp index 6340a8a03..f7b901498 100644 --- a/src/gui/interact/ui-coord-resolver.hpp +++ b/src/gui/interact/ui-coord-resolver.hpp @@ -59,6 +59,7 @@ #include "lib/error.hpp" #include "lib/symbol.hpp" +#include "lib/format-string.hpp" #include "gui/interact/ui-coord.hpp" #include "lib/iter-tree-explorer.hpp" #include "lib/iter-source.hpp" @@ -372,7 +373,29 @@ namespace interact { UICoordResolver&& 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); } diff --git a/src/gui/interact/ui-coord.hpp b/src/gui/interact/ui-coord.hpp index c1be9e7ae..0ad6b43c9 100644 --- a/src/gui/interact/ui-coord.hpp +++ b/src/gui/interact/ui-coord.hpp @@ -599,6 +599,14 @@ namespace interact { uic_.normalise(); return std::move (*this); } + + Builder&& + overwrite (size_t depth, Literal newSpec) + { + Literal* storage = uic_.expandPosition (depth); + uic_.setContent (storage, newSpec); + return std::move (*this); + } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 3a8c8648e..e64d5a706 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -8944,6 +8944,13 @@ + + + + + + + @@ -9372,6 +9379,15 @@ + + + + + + + + +