summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--unicode/biditest2.C6
-rw-r--r--unicode/book.xml14
-rw-r--r--unicode/courier-unicode.h.in8
-rw-r--r--unicode/unicodecpp.C29
4 files changed, 43 insertions, 14 deletions
diff --git a/unicode/biditest2.C b/unicode/biditest2.C
index cbd8c25..ce293b6 100644
--- a/unicode/biditest2.C
+++ b/unicode/biditest2.C
@@ -349,7 +349,11 @@ void character_test()
unicode::bidi_logical_order(logical_string,
logical_levels,
- paragraph);
+ paragraph,
+ []
+ (size_t, size_t) {},
+ 0,
+ logical_string.size());
auto new_string=unicode::bidi_embed(logical_string,
logical_levels,
diff --git a/unicode/book.xml b/unicode/book.xml
index 45686dc..3eb0a6e 100644
--- a/unicode/book.xml
+++ b/unicode/book.xml
@@ -2878,14 +2878,18 @@ See COPYING for distribution information.
<paramdef>std::u32string &amp;<parameter>string</parameter></paramdef>
<paramdef>std::vector &lt;unicode_bidi_level_t&gt; &amp;<parameter>levels</parameter></paramdef>
<paramdef>unicode_bidi_level_t <parameter>paragraph_embedding</parameter></paramdef>
- <paramdef>const std::function&lt;void (size_t, size_t) noexcept&gt; &amp;<parameter>removed_callback</parameter></paramdef>
+ <paramdef>const std::function&lt;void (size_t, size_t) noexcept&gt; &amp;<parameter>reorder_callback</parameter>=[](size_t, size_t){}</paramdef>
+ <paramdef>size_t <parameter>starting_pos</parameter>=0</paramdef>
+ <paramdef>size_t <parameter>n</parameter>=(size_t)-1</paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>unicode::bidi_logical_order</function></funcdef>
<paramdef>std::vector &lt;unicode_bidi_level_t&gt; &amp;<parameter>levels</parameter></paramdef>
<paramdef>unicode_bidi_level_t <parameter>paragraph_embedding</parameter></paramdef>
- <paramdef>const std::function&lt;void (size_t, size_t) noexcept&gt; &amp;<parameter>removed_callback</parameter></paramdef>
+ <paramdef>const std::function&lt;void (size_t, size_t) noexcept&gt; &amp;<parameter>reorder_callback</parameter></paramdef>
+ <paramdef>size_t <parameter>starting_pos</parameter>=0</paramdef>
+ <paramdef>size_t <parameter>n</parameter>=(size_t)-1</paramdef>
</funcprototype>
<funcprototype>
@@ -3043,8 +3047,10 @@ auto [levels, level]=unicode::bidi_calc(types);
<listitem>
<para>
- <function>unicode::bidi_reorder</function> and
- <function>unicode::bidi_cleanup</function> take two optional
+ <function>unicode::bidi_reorder</function>,
+ <function>unicode::bidi_cleanup</function>, and
+ <function>unicode::bidi_logical_order</function>
+ take two optional
parameters (defaulted values or overloaded) specifying
an optional starting position and number of characters that
define a subset of the original string that gets reordered
diff --git a/unicode/courier-unicode.h.in b/unicode/courier-unicode.h.in
index 4bc7b55..9d398ec 100644
--- a/unicode/courier-unicode.h.in
+++ b/unicode/courier-unicode.h.in
@@ -2291,12 +2291,16 @@ int bidi_logical_order(std::u32string &string,
std::vector<unicode_bidi_level_t> &levels,
unicode_bidi_level_t paragraph_embedding,
const std::function<void (size_t, size_t)>
- &lambda=[](size_t,size_t){});
+ &lambda=[](size_t,size_t){},
+ size_t starting_pos=0,
+ size_t n=(size_t)-1);
//! Convert Unicode string from canonical rendering order to logical order.
void bidi_logical_order(std::vector<unicode_bidi_level_t> &levels,
unicode_bidi_level_t paragraph_embedding,
- const std::function<void (size_t, size_t)> &lambda);
+ const std::function<void (size_t, size_t)> &lambda,
+ size_t starting_pos=0,
+ size_t n=(size_t)-1);
//! Embed directional and isolation markers
diff --git a/unicode/unicodecpp.C b/unicode/unicodecpp.C
index 5677b86..3ef3b05 100644
--- a/unicode/unicodecpp.C
+++ b/unicode/unicodecpp.C
@@ -806,16 +806,24 @@ int unicode::bidi_logical_order(std::u32string &string,
std::vector<unicode_bidi_level_t> &levels,
unicode_bidi_level_t paragraph_embedding,
const std::function<void (size_t, size_t)>
- &lambda)
+ &lambda,
+ size_t starting_pos,
+ size_t n)
{
- if (string.size() != levels.size())
+ auto s=string.size();
+
+ if (s != levels.size())
return -1;
- if (string.empty())
+ if (starting_pos >= s)
return 0;
+ if (n > s-starting_pos)
+ n=s-starting_pos;
+
cb_wrapper<void (size_t, size_t)> cb{lambda};
- unicode_bidi_logical_order(&string[0], &levels[0], string.size(),
+ unicode_bidi_logical_order(&string[starting_pos],
+ &levels[starting_pos], n,
paragraph_embedding,
&reorder_callback,
reinterpret_cast<void *>(&cb));
@@ -826,13 +834,20 @@ int unicode::bidi_logical_order(std::u32string &string,
void unicode::bidi_logical_order(std::vector<unicode_bidi_level_t> &levels,
unicode_bidi_level_t paragraph_embedding,
const std::function<void (size_t, size_t)>
- &lambda)
+ &lambda,
+ size_t starting_pos,
+ size_t n)
{
- if (levels.size() == 0)
+ auto s=levels.size();
+
+ if (starting_pos >= s)
return;
+ if (n > s-starting_pos)
+ n=s-starting_pos;
+
cb_wrapper<void (size_t, size_t)> cb{lambda};
- unicode_bidi_logical_order(NULL, &levels[0], levels.size(),
+ unicode_bidi_logical_order(NULL, &levels[starting_pos], n,
paragraph_embedding,
&reorder_callback,
reinterpret_cast<void *>(&cb));