diff --git a/src/gui/interact/ui-coord.hpp b/src/gui/interact/ui-coord.hpp index e43630a1a..6f7edfb5e 100644 --- a/src/gui/interact/ui-coord.hpp +++ b/src/gui/interact/ui-coord.hpp @@ -137,6 +137,17 @@ namespace interact { UNIMPLEMENTED ("augment UI coordinates to indicate a tab specified by index number"); } + /** + * convenience builder function so set a full path definition + * @note the given path string will be split at `'/'` and the + * resulting components will be stored/retrieved as Symbol + */ + UICoord + path (string pathDefinition) const + { + UNIMPLEMENTED ("augment UI coordinates to append a full local path"); + } + UICoord append (Literal elmID) const { diff --git a/src/lib/path-array.hpp b/src/lib/path-array.hpp index 14bb5e29e..15c9c46ab 100644 --- a/src/lib/path-array.hpp +++ b/src/lib/path-array.hpp @@ -318,6 +318,17 @@ namespace lib { return *elm; } + /** reverse lookup of actual path content + * @param content reference to actual content _residing within the path_ + * @return index position of the content within the path + * @throws error::Invalid when the given storage location + * is outside the data content storage of this path + */ + size_t + indexOf (Literal const& content) const + { + UNIMPLEMENTED ("reverse lookup"); + } protected: /* ==== Iteration control API for IterAdapter ==== */ diff --git a/tests/gui/interact/ui-coord-test.cpp b/tests/gui/interact/ui-coord-test.cpp index 9a3e75382..f1e9c0c90 100644 --- a/tests/gui/interact/ui-coord-test.cpp +++ b/tests/gui/interact/ui-coord-test.cpp @@ -76,6 +76,7 @@ namespace test { { verify_basics(); verify_builder(); + verify_stringRepr(); verify_comparisons(); verify_queryAnchor(); verify_queryCoverage(); @@ -126,7 +127,7 @@ namespace test { CHECK (7 == uic.size()); // representation is trimmed and filled - CHECK ("UI:Θ.*.*/*/Φ" == string(uic)); + CHECK ("UI:Θ.*.Σ/*/Φ" == string(uic)); CHECK (Symbol::EMPTY == uic[UIC_WINDOW]); CHECK (Symbol::EMPTY == uic[UIC_PERSP]); CHECK ("Θ" == uic[UIC_PANEL]); @@ -191,6 +192,151 @@ namespace test { } + void + verify_stringRepr() + { + UICoord uic; + CHECK ("UI:?" == string(uic)); + CHECK ("" == uic.getComp()); + CHECK ("" == uic.getPath()); + + uic = uic.path("ἁρχή"); + CHECK ("UI:?/ἁρχή" == string(uic)); + CHECK ("" == uic.getComp()); + CHECK ("ἁρχή" == uic.getPath()); + + uic = uic.path("α/β/γ"); + CHECK ("UI:?/α/β/γ" == string(uic)); + CHECK ("" == uic.getComp()); + CHECK ("α/β/γ" == uic.getPath()); + + uic = uic.append("δ"); + CHECK ("UI:?/α/β/γ/δ" == string(uic)); + CHECK ("" == uic.getComp()); + CHECK ("α/β/γ/δ" == uic.getPath()); + + uic = uic.append(""); + CHECK ("UI:?/α/β/γ/δ" == string(uic)); + CHECK ("" == uic.getComp()); + CHECK ("α/β/γ/δ" == uic.getPath()); + + uic = uic.append("ε/λ/ον"); + CHECK ("UI:?/α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("" == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + + // note: we built a partially empty path array... + CHECK (12 == uic.size()); + CHECK (Symbol::EMPTY == uic.getView()); + CHECK (Symbol::EMPTY == uic.getTab()); + CHECK (Symbol::EMPTY == uic[UIC_WINDOW]); + CHECK (Symbol::EMPTY == uic[UIC_PERSP]); + CHECK (Symbol::EMPTY == uic[UIC_PANEL]); + CHECK (Symbol::EMPTY == uic[UIC_VIEW]); + CHECK (Symbol::EMPTY == uic[UIC_TAB]); + CHECK ("α" == uic[UIC_PART]); + CHECK ("β" == uic[UIC_PART+1]); + CHECK ("γ" == uic[UIC_PART+2]); + CHECK ("δ" == uic[UIC_PART+3]); + CHECK ("ε" == uic[UIC_PART+4]); + CHECK ("λ" == uic[UIC_PART+5]); + CHECK ("ον" == uic[UIC_PART+6]); + + uic = uic.prepend("ειδος"); + CHECK ("UI:?.ειδος/α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("?.ειδος" == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + CHECK (12 == uic.size()); + + uic = uic.tab(""); + CHECK ("UI:?/α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("" == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + + uic = uic.view("ειδος"); + CHECK ("UI:?.ειδος.*/α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("?.ειδος.*" == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + + uic = uic.prepend("panel"); + CHECK ("UI:?-panel.ειδος.*/α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("?-panel.ειδος.*" == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + + uic = uic.view(nullptr); + CHECK ("UI:?-panel.*.*/α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("?-panel.*.*" == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + + uic = uic.tab(" "); + CHECK ("UI:?-panel.*. /α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("?-panel.*. " == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + + uic = uic.prepend("perspective"); + CHECK ("UI:UI:?[perspective]-panel.*. /α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("?[perspective]-panel.*. " == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + + uic = uic.prepend("win"); + CHECK ("UI:UI:win[perspective]-panel.*. /α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("win[perspective]-panel.*. " == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + + uic = uic.persp(""); + CHECK ("UI:UI:win[*]-panel.*. /α/β/γ/δ/ε/λ/ον" == string(uic)); + CHECK ("win[*]-panel.*. " == uic.getComp()); + CHECK ("α/β/γ/δ/ε/λ/ον" == uic.getPath()); + CHECK (12 == uic.size()); + + uic = uic.path(" "); + CHECK ("UI:UI:win[*]-panel.*. / " == string(uic)); + CHECK ("win[*]-panel.*. " == uic.getComp()); + CHECK (" " == uic.getPath()); + CHECK (6 == uic.size()); + CHECK (" " == uic[UIC_PART]); + VERIFY_ERROR (INDEX_BOUNDS, uic[UIC_PART+1]); + + uic = uic.path(nullptr); + CHECK ("UI:UI:win[*]-panel.*. " == string(uic)); + CHECK ("win[*]-panel.*. " == uic.getComp()); + CHECK ("" == uic.getPath()); + CHECK (5 == uic.size()); + VERIFY_ERROR (INDEX_BOUNDS, uic[UIC_PART]); + + uic = uic.append(nullptr); + CHECK ("UI:UI:win[*]-panel.*. " == string(uic)); + CHECK ("win[*]-panel.*. " == uic.getComp()); + CHECK ("" == uic.getPath()); + CHECK (5 == uic.size()); + + uic = uic.append("*"); + CHECK ("UI:UI:win[*]-panel.*. " == string(uic)); + CHECK ("win[*]-panel.*. " == uic.getComp()); + CHECK ("" == uic.getPath()); + CHECK (5 == uic.size()); + + uic = uic.append("**"); + CHECK ("UI:UI:win[*]-panel.*. /**" == string(uic)); + CHECK ("win[*]-panel.*. " == uic.getComp()); + CHECK ("**" == uic.getPath()); + CHECK ("**" == uic[UIC_PART]); + CHECK (6 == uic.size()); + + uic = uic.tab(""); + CHECK ("UI:UI:win[*]-panel.*.*/**" == string(uic)); + CHECK ("win[*]-panel.*.*" == uic.getComp()); + CHECK ("**" == uic.getPath()); + CHECK (6 == uic.size()); + + uic = uic.path(""); + CHECK ("UI:UI:win[*]-panel" == string(uic)); + CHECK ("win[*]-panel" == uic.getComp()); + CHECK ("" == uic.getPath()); + CHECK (3 == uic.size()); + } + + void verify_comparisons() { diff --git a/tests/library/path-array-test.cpp b/tests/library/path-array-test.cpp index 3909f3967..d3ca21a89 100644 --- a/tests/library/path-array-test.cpp +++ b/tests/library/path-array-test.cpp @@ -45,7 +45,7 @@ namespace lib { namespace test { using lumiera::error::LUMIERA_ERROR_INDEX_BOUNDS; - using lumiera::error::LUMIERA_ERROR_LOGIC; + using lumiera::error::LUMIERA_ERROR_INVALID; using ParrT = lib::PathArray<5>; @@ -158,6 +158,21 @@ namespace test { CHECK (Symbol::EMPTY == parr[2]); CHECK ("Ω" == parr[15]); VERIFY_ERROR (INDEX_BOUNDS, parr[16]); + + // but iteration starts with actual content + parr = ParrT{nullptr,nullptr,"Θ","Ξ","Σ","Ψ","Φ","Ω"}; + CHECK ("Θ" == *parr.begin()); + CHECK ( 2 == parr.indexOf (*parr.begin())); + CHECK ("Θ" == parr[2]); + + parr = ParrT{nullptr,nullptr,nullptr,nullptr,"Σ","Ψ","Φ","Ω"}; + CHECK ("Σ" == *parr.begin()); + CHECK ( 5 == parr.indexOf (*parr.begin())); + CHECK ( 6 == parr.indexOf (*++parr.begin())); + CHECK ( 7 == parr.indexOf (*++++parr.begin())); + + Literal some{"muck"}; + VERIFY_ERROR (INVALID, parr.indexOf (some)); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 5ffe99778..7eff9ed6b 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -3826,11 +3826,13 @@ - - - - - + + + + + + + @@ -3901,6 +3903,12 @@ + + + + + +