mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 03:50:47 -05:00
[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:
parent
039e282a40
commit
75e5b805ab
@ -3692,17 +3692,26 @@ clutter_text_insert_text (ClutterText *self,
|
|||||||
{
|
{
|
||||||
ClutterTextPrivate *priv;
|
ClutterTextPrivate *priv;
|
||||||
GString *new = NULL;
|
GString *new = NULL;
|
||||||
|
gint pos_bytes;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_TEXT (self));
|
g_return_if_fail (CLUTTER_IS_TEXT (self));
|
||||||
g_return_if_fail (text != NULL);
|
g_return_if_fail (text != NULL);
|
||||||
|
|
||||||
priv = self->priv;
|
priv = self->priv;
|
||||||
|
|
||||||
|
pos_bytes = offset_to_bytes (priv->text, position);
|
||||||
|
|
||||||
new = g_string_new (priv->text);
|
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);
|
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);
|
g_string_free (new, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user