Make invisible text work a bit better (#66194, patch by Jeroen
2005-06-13 Matthias Clasen <mclasen@redhat.com> Make invisible text work a bit better (#66194, patch by Jeroen Zwartepoorte) * gtk/gtk.symbols: * gtk/gtktextiter.[hc]: Add function to move by visible lines. * gtk/gtktextview.c (gtk_text_view_move_cursor_internal): Skip invisible text when moving by paragraphs. * gtk/gtktextlayout.c (gtk_text_layout_move_iter_visually): Skip invisible lines here too.
This commit is contained in:
committed by
Matthias Clasen
parent
f66144459c
commit
4b14b2d4bd
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
||||
2005-06-13 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Make invisible text work a bit better (#66194, patch by
|
||||
Jeroen Zwartepoorte)
|
||||
|
||||
* gtk/gtk.symbols:
|
||||
* gtk/gtktextiter.[hc]: Add function to move by
|
||||
visible lines.
|
||||
|
||||
* gtk/gtktextview.c (gtk_text_view_move_cursor_internal):
|
||||
Skip invisible text when moving by paragraphs.
|
||||
|
||||
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_visually):
|
||||
Skip invisible lines here too.
|
||||
|
||||
2005-06-12 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkselection.c (gtk_target_list_add_image_targets):
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
2005-06-13 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Make invisible text work a bit better (#66194, patch by
|
||||
Jeroen Zwartepoorte)
|
||||
|
||||
* gtk/gtk.symbols:
|
||||
* gtk/gtktextiter.[hc]: Add function to move by
|
||||
visible lines.
|
||||
|
||||
* gtk/gtktextview.c (gtk_text_view_move_cursor_internal):
|
||||
Skip invisible text when moving by paragraphs.
|
||||
|
||||
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_visually):
|
||||
Skip invisible lines here too.
|
||||
|
||||
2005-06-12 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkselection.c (gtk_target_list_add_image_targets):
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
2005-06-13 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Make invisible text work a bit better (#66194, patch by
|
||||
Jeroen Zwartepoorte)
|
||||
|
||||
* gtk/gtk.symbols:
|
||||
* gtk/gtktextiter.[hc]: Add function to move by
|
||||
visible lines.
|
||||
|
||||
* gtk/gtktextview.c (gtk_text_view_move_cursor_internal):
|
||||
Skip invisible text when moving by paragraphs.
|
||||
|
||||
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_visually):
|
||||
Skip invisible lines here too.
|
||||
|
||||
2005-06-12 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkselection.c (gtk_target_list_add_image_targets):
|
||||
|
||||
@@ -2890,6 +2890,8 @@ gtk_text_iter_backward_sentence_starts
|
||||
gtk_text_iter_backward_to_tag_toggle
|
||||
gtk_text_iter_backward_visible_cursor_position
|
||||
gtk_text_iter_backward_visible_cursor_positions
|
||||
gtk_text_iter_backward_visible_line
|
||||
gtk_text_iter_backward_visible_lines
|
||||
gtk_text_iter_backward_visible_word_start
|
||||
gtk_text_iter_backward_visible_word_starts
|
||||
gtk_text_iter_backward_word_start
|
||||
@@ -2919,6 +2921,8 @@ gtk_text_iter_forward_to_line_end
|
||||
gtk_text_iter_forward_to_tag_toggle
|
||||
gtk_text_iter_forward_visible_cursor_position
|
||||
gtk_text_iter_forward_visible_cursor_positions
|
||||
gtk_text_iter_forward_visible_line
|
||||
gtk_text_iter_forward_visible_lines
|
||||
gtk_text_iter_forward_visible_word_end
|
||||
gtk_text_iter_forward_visible_word_ends
|
||||
gtk_text_iter_forward_word_end
|
||||
|
||||
@@ -2719,6 +2719,162 @@ gtk_text_iter_backward_lines (GtkTextIter *iter, gint count)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_iter_forward_visible_line:
|
||||
* @iter: an iterator
|
||||
*
|
||||
* Moves @iter to the start of the next visible line. Returns %TRUE if there
|
||||
* was a next line to move to, and %FALSE if @iter was simply moved to
|
||||
* the end of the buffer and is now not dereferenceable, or if @iter was
|
||||
* already at the end of the buffer.
|
||||
*
|
||||
* Return value: whether @iter can be dereferenced
|
||||
*
|
||||
* Since: 2.8
|
||||
**/
|
||||
gboolean
|
||||
gtk_text_iter_forward_visible_line (GtkTextIter *iter)
|
||||
{
|
||||
while (gtk_text_iter_forward_line (iter))
|
||||
{
|
||||
if (!_gtk_text_btree_char_is_invisible (iter))
|
||||
return TRUE;
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!gtk_text_iter_forward_char (iter))
|
||||
return FALSE;
|
||||
|
||||
if (!_gtk_text_btree_char_is_invisible (iter))
|
||||
return TRUE;
|
||||
}
|
||||
while (!gtk_text_iter_ends_line (iter));
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_iter_backward_visible_line:
|
||||
* @iter: an iterator
|
||||
*
|
||||
* Moves @iter to the start of the previous visible line. Returns %TRUE if
|
||||
* @iter could be moved; i.e. if @iter was at character offset 0, this
|
||||
* function returns %FALSE. Therefore if @iter was already on line 0,
|
||||
* but not at the start of the line, @iter is snapped to the start of
|
||||
* the line and the function returns %TRUE. (Note that this implies that
|
||||
* in a loop calling this function, the line number may not change on
|
||||
* every iteration, if your first iteration is on line 0.)
|
||||
*
|
||||
* Return value: whether @iter moved
|
||||
*
|
||||
* Since: 2.8
|
||||
**/
|
||||
gboolean
|
||||
gtk_text_iter_backward_visible_line (GtkTextIter *iter)
|
||||
{
|
||||
while (gtk_text_iter_backward_line (iter))
|
||||
{
|
||||
if (!_gtk_text_btree_char_is_invisible (iter))
|
||||
return TRUE;
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!gtk_text_iter_backward_char (iter))
|
||||
return FALSE;
|
||||
|
||||
if (!_gtk_text_btree_char_is_invisible (iter))
|
||||
return TRUE;
|
||||
}
|
||||
while (!gtk_text_iter_starts_line (iter));
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_iter_forward_visible_lines:
|
||||
* @iter: a #GtkTextIter
|
||||
* @count: number of lines to move forward
|
||||
*
|
||||
* Moves @count visible lines forward, if possible (if @count would move
|
||||
* past the start or end of the buffer, moves to the start or end of
|
||||
* the buffer). The return value indicates whether the iterator moved
|
||||
* onto a dereferenceable position; if the iterator didn't move, or
|
||||
* moved onto the end iterator, then %FALSE is returned. If @count is 0,
|
||||
* the function does nothing and returns %FALSE. If @count is negative,
|
||||
* moves backward by 0 - @count lines.
|
||||
*
|
||||
* Return value: whether @iter moved and is dereferenceable
|
||||
*
|
||||
* Since: 2.8
|
||||
**/
|
||||
gboolean
|
||||
gtk_text_iter_forward_visible_lines (GtkTextIter *iter,
|
||||
gint count)
|
||||
{
|
||||
FIX_OVERFLOWS (count);
|
||||
|
||||
if (count < 0)
|
||||
return gtk_text_iter_backward_visible_lines (iter, 0 - count);
|
||||
else if (count == 0)
|
||||
return FALSE;
|
||||
else if (count == 1)
|
||||
{
|
||||
check_invariants (iter);
|
||||
return gtk_text_iter_forward_visible_line (iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gtk_text_iter_forward_visible_line (iter) && count > 0)
|
||||
count--;
|
||||
return count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_iter_backward_visible_lines:
|
||||
* @iter: a #GtkTextIter
|
||||
* @count: number of lines to move backward
|
||||
*
|
||||
* Moves @count visible lines backward, if possible (if @count would move
|
||||
* past the start or end of the buffer, moves to the start or end of
|
||||
* the buffer). The return value indicates whether the iterator moved
|
||||
* onto a dereferenceable position; if the iterator didn't move, or
|
||||
* moved onto the end iterator, then %FALSE is returned. If @count is 0,
|
||||
* the function does nothing and returns %FALSE. If @count is negative,
|
||||
* moves forward by 0 - @count lines.
|
||||
*
|
||||
* Return value: whether @iter moved and is dereferenceable
|
||||
*
|
||||
* Since: 2.8
|
||||
**/
|
||||
gboolean
|
||||
gtk_text_iter_backward_visible_lines (GtkTextIter *iter,
|
||||
gint count)
|
||||
{
|
||||
FIX_OVERFLOWS (count);
|
||||
|
||||
if (count < 0)
|
||||
return gtk_text_iter_forward_visible_lines (iter, 0 - count);
|
||||
else if (count == 0)
|
||||
return FALSE;
|
||||
else if (count == 1)
|
||||
{
|
||||
return gtk_text_iter_backward_visible_line (iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gtk_text_iter_backward_visible_line (iter) && count > 0)
|
||||
count--;
|
||||
return count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
typedef gboolean (* FindLogAttrFunc) (const PangoLogAttr *attrs,
|
||||
gint offset,
|
||||
gint min_offset,
|
||||
|
||||
@@ -188,6 +188,13 @@ gboolean gtk_text_iter_forward_word_ends (GtkTextIter *iter,
|
||||
gint count);
|
||||
gboolean gtk_text_iter_backward_word_starts (GtkTextIter *iter,
|
||||
gint count);
|
||||
|
||||
gboolean gtk_text_iter_forward_visible_line (GtkTextIter *iter);
|
||||
gboolean gtk_text_iter_backward_visible_line (GtkTextIter *iter);
|
||||
gboolean gtk_text_iter_forward_visible_lines (GtkTextIter *iter,
|
||||
gint count);
|
||||
gboolean gtk_text_iter_backward_visible_lines (GtkTextIter *iter,
|
||||
gint count);
|
||||
|
||||
gboolean gtk_text_iter_forward_visible_word_end (GtkTextIter *iter);
|
||||
gboolean gtk_text_iter_backward_visible_word_start (GtkTextIter *iter);
|
||||
|
||||
@@ -2390,8 +2390,8 @@ gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
|
||||
index += layout->preedit_cursor - layout->preedit_len;
|
||||
|
||||
pango_layout_get_cursor_pos (display->layout, index,
|
||||
strong_pos ? &pango_strong_pos : NULL,
|
||||
weak_pos ? &pango_weak_pos : NULL);
|
||||
strong_pos ? &pango_strong_pos : NULL,
|
||||
weak_pos ? &pango_weak_pos : NULL);
|
||||
|
||||
if (strong_pos)
|
||||
{
|
||||
@@ -3117,6 +3117,7 @@ gtk_text_layout_move_iter_visually (GtkTextLayout *layout,
|
||||
{
|
||||
GtkTextLineDisplay *display = NULL;
|
||||
GtkTextIter orig;
|
||||
GtkTextIter lineiter;
|
||||
|
||||
g_return_val_if_fail (layout != NULL, FALSE);
|
||||
g_return_val_if_fail (iter != NULL, FALSE);
|
||||
@@ -3174,10 +3175,17 @@ gtk_text_layout_move_iter_visually (GtkTextLayout *layout,
|
||||
|
||||
if (new_index < 0 || (new_index == 0 && extra_back))
|
||||
{
|
||||
line = _gtk_text_line_previous (line);
|
||||
do
|
||||
{
|
||||
line = _gtk_text_line_previous (line);
|
||||
|
||||
if (!line)
|
||||
goto done;
|
||||
if (!line)
|
||||
goto done;
|
||||
|
||||
_gtk_text_btree_get_iter_at_line (_gtk_text_buffer_get_btree (layout->buffer),
|
||||
&lineiter, line, 0);
|
||||
}
|
||||
while (totally_invisible_line (layout, line, &lineiter));
|
||||
|
||||
gtk_text_layout_free_line_display (layout, display);
|
||||
display = gtk_text_layout_get_line_display (layout, line, FALSE);
|
||||
@@ -3185,10 +3193,17 @@ gtk_text_layout_move_iter_visually (GtkTextLayout *layout,
|
||||
}
|
||||
else if (new_index > byte_count)
|
||||
{
|
||||
line = _gtk_text_line_next_excluding_last (line);
|
||||
if (!line)
|
||||
goto done;
|
||||
do
|
||||
{
|
||||
line = _gtk_text_line_next_excluding_last (line);
|
||||
if (!line)
|
||||
goto done;
|
||||
|
||||
_gtk_text_btree_get_iter_at_line (_gtk_text_buffer_get_btree (layout->buffer),
|
||||
&lineiter, line, 0);
|
||||
}
|
||||
while (totally_invisible_line (layout, line, &lineiter));
|
||||
|
||||
gtk_text_layout_free_line_display (layout, display);
|
||||
display = gtk_text_layout_get_line_display (layout, line, FALSE);
|
||||
new_index = 0;
|
||||
|
||||
@@ -4759,7 +4759,7 @@ gtk_text_view_move_cursor_internal (GtkTextView *text_view,
|
||||
gtk_text_iter_forward_to_line_end (&newplace);
|
||||
--count;
|
||||
}
|
||||
gtk_text_iter_forward_lines (&newplace, count);
|
||||
gtk_text_iter_forward_visible_lines (&newplace, count);
|
||||
gtk_text_iter_forward_to_line_end (&newplace);
|
||||
}
|
||||
else if (count < 0)
|
||||
@@ -4769,7 +4769,7 @@ gtk_text_view_move_cursor_internal (GtkTextView *text_view,
|
||||
gtk_text_iter_set_line_offset (&newplace, 0);
|
||||
++count;
|
||||
}
|
||||
gtk_text_iter_forward_lines (&newplace, count);
|
||||
gtk_text_iter_forward_visible_lines (&newplace, count);
|
||||
gtk_text_iter_set_line_offset (&newplace, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user