Fix line start and line end key binding behaviour

Another fix for the key navigation behaviour around the zeroeth
glyph in the layout.

This commit adds a fast path for for the zero index when the
cursor position is set as zero, in case we are using the line-start
or line-end key bindings, similarly to what we did in commit
be64cbcdc2 for the move-up and
move-down bindings.
This commit is contained in:
Emmanuele Bassi 2008-12-16 10:15:57 +00:00
parent be64cbcdc2
commit dc49dab350

View File

@ -211,11 +211,6 @@ offset_to_bytes (const gchar *text,
if (pos < 0) if (pos < 0)
return strlen (text); return strlen (text);
#if 0
if (pos < 1)
return pos;
#endif
c = g_utf8_next_char (text); c = g_utf8_next_char (text);
j = 1; j = 1;
len = strlen (text); len = strlen (text);
@ -1307,8 +1302,12 @@ clutter_text_real_line_start (ClutterText *self,
layout = clutter_text_get_layout (self); layout = clutter_text_get_layout (self);
pango_layout_index_to_line_x (layout, if (priv->position == 0)
offset_to_bytes (priv->text, priv->position), index_ = 0;
else
index_ = offset_to_bytes (priv->text, priv->position);
pango_layout_index_to_line_x (layout, index_,
0, 0,
&line_no, NULL); &line_no, NULL);
@ -1342,7 +1341,11 @@ clutter_text_real_line_end (ClutterText *self,
gint position; gint position;
layout = clutter_text_get_layout (self); layout = clutter_text_get_layout (self);
index_ = offset_to_bytes (priv->text, priv->position);
if (priv->position == 0)
index_ = 0;
else
index_ = offset_to_bytes (priv->text, priv->position);
pango_layout_index_to_line_x (layout, index_, pango_layout_index_to_line_x (layout, index_,
0, 0,
@ -2145,6 +2148,7 @@ clutter_text_get_selection (ClutterText *text)
if (end_index == start_index) if (end_index == start_index)
return g_strdup (""); return g_strdup ("");
if (end_index < start_index) if (end_index < start_index)
{ {
gint temp = start_index; gint temp = start_index;