[text] Insertion of multi-byte characters broken

Bug 1501 - clutter_text_insert_text not working right with non-onebyte
           character

In clutter_text_insert_text(), the position is expressed in characters, not
in bytes.

Actually, it turns out to be working on bytes, so when there are already
multi-byte character in the text buffer, insert text at the position after
the multi-byte character will not work right.

Also, the position is not updated after the insert work is done.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
This commit is contained in:
Raymond Liu 2009-03-09 14:10:45 +08:00 committed by Emmanuele Bassi
parent 039e282a40
commit 75e5b805ab

View File

@ -3692,17 +3692,26 @@ clutter_text_insert_text (ClutterText *self,
{
ClutterTextPrivate *priv;
GString *new = NULL;
gint pos_bytes;
g_return_if_fail (CLUTTER_IS_TEXT (self));
g_return_if_fail (text != NULL);
priv = self->priv;
pos_bytes = offset_to_bytes (priv->text, position);
new = g_string_new (priv->text);
new = g_string_insert (new, position, text);
new = g_string_insert (new, pos_bytes, text);
clutter_text_set_text (self, new->str);
if (position >= 0 && priv->position >= position)
{
clutter_text_set_cursor_position (self, priv->position + g_utf8_strlen (text, -1));
clutter_text_set_selection_bound (self, priv->position);
}
g_string_free (new, TRUE);
}