diff --git a/src/netxs/console/richtext.hpp b/src/netxs/console/richtext.hpp index feb6f77013..3e8fe63c45 100644 --- a/src/netxs/console/richtext.hpp +++ b/src/netxs/console/richtext.hpp @@ -456,14 +456,34 @@ namespace netxs::console }; // flow: Main cursor forwarding proc. - template + template void output(T const& block, P print) { textline.coor = caretpos; - auto printout = WRAP ? textline.trunc(viewrect.size) - : textline; - auto outwidth = WRAP ? printout.coor.x + printout.size.x - textline.coor.x - : textline.size.x; + + rect printout; + iota outwidth; + if constexpr (WRAP) + { + printout = textline.trunc(viewrect.size); + outwidth = printout.coor.x + printout.size.x - textline.coor.x; + + if constexpr (!SPLIT) + if (printout.size.x > 1) + { + auto p = curpoint + printout.size.x - 1; + if (block.at(p).wdt() == 2) + { + --printout.size.x; + } + } + } + else + { + printout = textline; + outwidth = textline.size.x; + } + //flow::up(); flow::dx(outwidth); //flow::up(); @@ -500,7 +520,7 @@ namespace netxs::console auto middle() { return (viewrect.size.x >> 1) - (textline.size.x >> 1); } void autocr() { if (caretpos.x >= caret_mx) flow::nl(highness); } - template + template void centred(T const& block, P print) { while (textline.size.x > 0) @@ -509,33 +529,33 @@ namespace netxs::console auto axis = textline.size.x >= caret_mx ? 0 : middle(); flow::ax(axis); - output(block, print); + output(block, print); } } - template + template void wrapped(T const& block, P print) { while (textline.size.x > 0) { autocr(); - output(block, print); + output(block, print); } } - template + template void trimmed(T const& block, P print) { if (textline.size.x > 0) { if (centered) flow::ax(middle()); - output(block, print); + output(block, print); } } - template + template void proceed(T const& block, P print) { - if (iswrapln) if (centered) centred(block, print); - else wrapped(block, print); - else trimmed(block, print); + if (iswrapln) if (centered) centred(block, print); + else wrapped(block, print); + else trimmed(block, print); } std::function custom; // flow: Draw commands (customizable). @@ -562,7 +582,7 @@ namespace netxs::console // flow: Split specified textblock on the substrings // and place it to the form by the specified proc. - template + template void compose(T const& block, P print = P()) { combine(runstyle, block.style); @@ -586,11 +606,11 @@ namespace netxs::console } if (arighted) - if (isrlfeed) proceed(block, print); - else proceed(block, print); + if (isrlfeed) proceed(block, print); + else proceed(block, print); else - if (isrlfeed) proceed(block, print); - else proceed(block, print); + if (isrlfeed) proceed(block, print); + else proceed(block, print); } } // flow: Execute specified locus instruction list. @@ -604,18 +624,18 @@ namespace netxs::console } return flow::up(); } - template + template void go(T const& block) { - compose(block); + compose(block); } - template + template void go(T const& block, core& canvas, P printfx = P()) { - compose(block, [&](auto const& coord, auto const& subblock) - { - canvas.text(coord, subblock, isr_to_l, printfx); - }); + compose(block, [&](auto const& coord, auto const& subblock) + { + canvas.text(coord, subblock, isr_to_l, printfx); + }); } template auto print(T const& block, core& canvas, P printfx = P()) @@ -626,7 +646,7 @@ namespace netxs::console if constexpr (USE_LOCUS) coor = forward(block); else coor = flow::cp(); - go(block, canvas, printfx); + go(block, canvas, printfx); return coor; } template @@ -638,7 +658,7 @@ namespace netxs::console if constexpr (USE_LOCUS) coor = forward(block); else coor = flow::cp(); - go(block); + go(block); return coor; } @@ -1200,6 +1220,13 @@ namespace netxs::console len.y * len.x); while (dst != end) *dst++ = blank; } + + //todo unify + auto& at(iota p) const + { + assert(p >= 0); + return *(core::data() + p); + } }; // richtext: Enriched text paragraph. @@ -1267,6 +1294,9 @@ namespace netxs::console auto id() const { return index; } auto& set(cell const& c) { brush.set(c); return *this; } + + //todo unify + auto& at(iota p) const { return lyric->data(p); } // para: . }; // richtext: Cascade of the identical paragraphs. @@ -1390,6 +1420,14 @@ namespace netxs::console auto size () const { return volume; } // rope: Return volume of the source content. auto length() const { return volume.x; } // rope: Return the length of the source content. auto id () const { return (**source).id(); } // rope: Return paragraph id. + auto& front () const { return (**source).at(prefix); } // rope: Return first cell. + + //todo unify + auto& at(iota p) const // rope: . + { + auto shadow = substr(p, 1); + return shadow.front(); + } }; // richtext: Enriched text page.