From 26a9769e483c32c87ef43e16ecca3db47e58e030 Mon Sep 17 00:00:00 2001 From: tasn Date: Mon, 18 Jul 2011 07:41:27 +0000 Subject: [PATCH] Evas text: Fixed text_props_index_find and added props_cluster_next/prev. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@61469 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/engines/common/evas_text_utils.c | 38 +++++++++++++++++++++++--------- src/lib/engines/common/evas_text_utils.h | 3 +++ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/lib/engines/common/evas_text_utils.c b/src/lib/engines/common/evas_text_utils.c index d62c3d9..a00df91 100644 --- a/src/lib/engines/common/evas_text_utils.c +++ b/src/lib/engines/common/evas_text_utils.c @@ -65,11 +65,12 @@ evas_common_text_props_content_unref(Evas_Text_Props *props) } } -EAPI int -evas_common_text_props_cluster_next(const Evas_Text_Props *props, int pos) +static int +_evas_common_text_props_cluster_move(const Evas_Text_Props *props, int pos, + Eina_Bool right) { int prop_pos = evas_common_text_props_index_find(props, pos); - if ((props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) && (prop_pos > 0)) + if (!right && (prop_pos > 0)) { #ifdef OT_SUPPORT return props->info->ot[props->start + prop_pos - 1].source_cluster - @@ -78,8 +79,7 @@ evas_common_text_props_cluster_next(const Evas_Text_Props *props, int pos) return props->start + prop_pos - 1 - props->text_offset; #endif } - else if ((props->bidi.dir != EVAS_BIDI_DIRECTION_RTL) && - (prop_pos < (int) (props->len - 1))) + else if (right && (prop_pos < (int) (props->len - 1))) { #ifdef OT_SUPPORT return props->info->ot[props->start + prop_pos + 1].source_cluster - @@ -92,6 +92,24 @@ evas_common_text_props_cluster_next(const Evas_Text_Props *props, int pos) return pos; } +EAPI int +evas_common_text_props_cluster_next(const Evas_Text_Props *props, int pos) +{ + Eina_Bool right; + /* Move right if we are in a non-rtl text */ + right = (props->bidi.dir != EVAS_BIDI_DIRECTION_RTL); + return _evas_common_text_props_cluster_move(props, pos, right); +} + +EAPI int +evas_common_text_props_cluster_prev(const Evas_Text_Props *props, int pos) +{ + Eina_Bool right; + /* Move right if we are in an rtl text */ + right = (props->bidi.dir == EVAS_BIDI_DIRECTION_RTL); + return _evas_common_text_props_cluster_move(props, pos, right); +} + /* Returns the index of the logical char in the props. */ EAPI int evas_common_text_props_index_find(const Evas_Text_Props *props, int _cutoff) @@ -156,7 +174,7 @@ evas_common_text_props_index_find(const Evas_Text_Props *props, int _cutoff) if (ot_info->source_cluster != (size_t) _cutoff) break; } - mid = props->len - mid; + mid--; } else { @@ -189,7 +207,7 @@ evas_common_text_props_split(Evas_Text_Props *base, #ifdef OT_SUPPORT _cutoff = evas_common_text_props_index_find(base, _cutoff); - if (_cutoff > 0) + if (_cutoff >= 0) { cutoff = (size_t) _cutoff; } @@ -206,9 +224,9 @@ evas_common_text_props_split(Evas_Text_Props *base, if (base->bidi.dir == EVAS_BIDI_DIRECTION_RTL) { ext->start = base->start; - ext->len = base->len - cutoff; - base->start = (base->start + base->len) - cutoff; - base->len = cutoff; + ext->len = cutoff + 1; + base->start = base->start + ext->len; + base->len = base->len - ext->len; #ifdef OT_SUPPORT ext->text_offset = diff --git a/src/lib/engines/common/evas_text_utils.h b/src/lib/engines/common/evas_text_utils.h index 6d42d99..7f1c802 100644 --- a/src/lib/engines/common/evas_text_utils.h +++ b/src/lib/engines/common/evas_text_utils.h @@ -75,6 +75,9 @@ EAPI int evas_common_text_props_cluster_next(const Evas_Text_Props *props, int pos); EAPI int +evas_common_text_props_cluster_prev(const Evas_Text_Props *props, int pos); + +EAPI int evas_common_text_props_index_find(const Evas_Text_Props *props, int _cutoff); EAPI void -- 2.7.4