summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2003-06-05 19:19:39 +0000
committerOwen Taylor <otaylor@src.gnome.org>2003-06-05 19:19:39 +0000
commit5df9f3457972dc07f28509de66d24770135c0588 (patch)
tree2f3fde74d5dea6686f6a0e9d494194374d7793f1 /pango
parent64ca8b972761a8663ca3eb5cbaf112c52e89e2e1 (diff)
downloadpango-5df9f3457972dc07f28509de66d24770135c0588.tar.gz
Fix bug in determining when we cross line boundaries. (#103421, Matthias
Thu Jun 5 14:53:40 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (pango_layout_move_cursor_visually): Fix bug in determining when we cross line boundaries. (#103421, Matthias Clasen)
Diffstat (limited to 'pango')
-rw-r--r--pango/pango-layout.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 3143714d..403faa67 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -1232,6 +1232,8 @@ pango_layout_move_cursor_visually (PangoLayout *layout,
int n_vis;
int vis_pos, log_pos;
int start_offset;
+ gboolean off_start = FALSE;
+ gboolean off_end = FALSE;
g_return_if_fail (layout != NULL);
g_return_if_fail (old_index >= 0 && old_index <= layout->length);
@@ -1261,10 +1263,31 @@ pango_layout_move_cursor_visually (PangoLayout *layout,
vis_pos = log2vis_map[old_index - line->start_index];
g_free (log2vis_map);
-
+
+ /* Handling movement between lines */
if (vis_pos == 0 && direction < 0)
{
if (base_dir == PANGO_DIRECTION_LTR)
+ off_start = TRUE;
+ else
+ off_end = TRUE;
+ }
+ else if (vis_pos == n_vis && direction > 0)
+ {
+ if (base_dir == PANGO_DIRECTION_LTR)
+ off_end = TRUE;
+ else
+ off_start = TRUE;
+ }
+
+ if (off_start || off_end)
+ {
+ /* If we move over a paragraph boundary, count that as
+ * an extra position in the motion
+ */
+ gboolean paragraph_boundary;
+
+ if (off_start)
{
if (!prev_line)
{
@@ -1273,6 +1296,7 @@ pango_layout_move_cursor_visually (PangoLayout *layout,
return;
}
line = prev_line;
+ paragraph_boundary = (line->start_index + line->length != old_index);
}
else
{
@@ -1283,40 +1307,21 @@ pango_layout_move_cursor_visually (PangoLayout *layout,
return;
}
line = next_line;
+ paragraph_boundary = (line->start_index != old_index);
}
- /* Handle paragraph separators as an extra position */
- vis_pos = g_utf8_strlen (layout->text + line->start_index, line->length);
- if (line->start_index + line->length != old_index)
- vis_pos++;
- }
- else if (vis_pos == n_vis && direction > 0)
- {
- if (base_dir == PANGO_DIRECTION_LTR)
+ if (vis_pos == 0 && direction < 0)
{
- if (!next_line)
- {
- *new_index = G_MAXINT;
- *new_trailing = 0;
- return;
- }
- line = next_line;
+ vis_pos = g_utf8_strlen (layout->text + line->start_index, line->length);
+ if (paragraph_boundary)
+ vis_pos++;
}
- else
+ else /* (vis_pos == n_vis && direction > 0) */
{
- if (!prev_line)
- {
- *new_index = -1;
- *new_trailing = 0;
- return;
- }
- line = prev_line;
+ vis_pos = 0;
+ if (paragraph_boundary)
+ vis_pos--;
}
-
- /* Handle paragraph separators as an extra position */
- vis_pos = 0;
- if (line->start_index != old_index)
- vis_pos--;
}
vis2log_map = pango_layout_line_get_vis2log_map (line, strong);