mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
text: Take pre-edit cursor position into account
When determining the cursor position we also need to take into account the pre-edit cursor position as set by the set_preedit_string() function.
This commit is contained in:
parent
23cd0b7925
commit
473f7ee31e
@ -574,7 +574,12 @@ clutter_text_position_to_coords (ClutterText *self,
|
|||||||
if (position == -1)
|
if (position == -1)
|
||||||
{
|
{
|
||||||
if (priv->password_char == 0)
|
if (priv->password_char == 0)
|
||||||
index_ = priv->n_bytes;
|
{
|
||||||
|
if (priv->editable && priv->preedit_set)
|
||||||
|
index_ = priv->n_bytes + strlen (priv->preedit_str);
|
||||||
|
else
|
||||||
|
index_ = priv->n_bytes;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
index_ = n_chars * password_char_bytes;
|
index_ = n_chars * password_char_bytes;
|
||||||
}
|
}
|
||||||
@ -584,10 +589,14 @@ clutter_text_position_to_coords (ClutterText *self,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
gchar *text = clutter_text_get_display_text (self);
|
||||||
|
|
||||||
if (priv->password_char == 0)
|
if (priv->password_char == 0)
|
||||||
index_ = offset_to_bytes (priv->text, position);
|
index_ = offset_to_bytes (text, position);
|
||||||
else
|
else
|
||||||
index_ = position * password_char_bytes;
|
index_ = position * password_char_bytes;
|
||||||
|
|
||||||
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pango_layout_get_cursor_pos (clutter_text_get_layout (self),
|
pango_layout_get_cursor_pos (clutter_text_get_layout (self),
|
||||||
@ -624,6 +633,9 @@ clutter_text_ensure_cursor_position (ClutterText *self)
|
|||||||
|
|
||||||
position = priv->position;
|
position = priv->position;
|
||||||
|
|
||||||
|
if (priv->editable && priv->preedit_set)
|
||||||
|
position += priv->preedit_cursor_pos;
|
||||||
|
|
||||||
CLUTTER_NOTE (MISC, "Cursor at %d (preedit %s at pos: %d)",
|
CLUTTER_NOTE (MISC, "Cursor at %d (preedit %s at pos: %d)",
|
||||||
position,
|
position,
|
||||||
priv->preedit_set ? "set" : "unset",
|
priv->preedit_set ? "set" : "unset",
|
||||||
|
Loading…
Reference in New Issue
Block a user