summaryrefslogtreecommitdiff
path: root/gtk/gtktextiter.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2000-12-14 23:26:59 +0000
committerHavoc Pennington <hp@src.gnome.org>2000-12-14 23:26:59 +0000
commit94ec8cff934d0d5559d6474131b3682e943bbc8e (patch)
tree1e28209981e5b72a75bd7e49f88f0f673e3a6e29 /gtk/gtktextiter.c
parent2e70f892ccf120947b4ab34a968ca4818208211d (diff)
downloadgdk-pixbuf-94ec8cff934d0d5559d6474131b3682e943bbc8e.tar.gz
remove unused call to get_last_line()
2000-12-14 Havoc Pennington <hp@redhat.com> * gtk/gtktextbtree.c (_gtk_text_btree_validate_line): remove unused call to get_last_line() * gtk/gtkobject.c (gtk_object_add_arg_type): add G_TYPE_POINTER here until boxed is working (and maybe after that - we should really not gratuitously break old code) * gtk/gtktexttag.c (gtk_text_tag_class_init): add commented-out specific types for font_desc and tabs args, move them to GTK_TYPE_POINTER for now, waiting on g_param_spec_boxed() to get fixed. Move GdkColor args to GTK_TYPE_POINTER also. * gtk/gtktextbuffer.c (gtk_text_buffer_class_init): temporarily use GTK_TYPE_POINTER for signal signatures as a hack-around * gtk/gtk-boxed.defs: Add boxed types for PangoFontDescription and PangoTabArray * gtk/gtktextlayout.c (line_display_iter_to_index): make static (line_display_index_to_iter): make static * gtk/gtktextbuffer.c (gtk_text_buffer_class_init): fix marshaller to marshal a string not a boxed * gtk/gtkmarshal.list: add marshaller for GtkTextBuffer:insert_text * gtk/testtext.c (fill_file_buffer): don't use g_utf8_next_char since the UTF-8 isn't validated yet * gtk/gtktextsegment.c (char_segment_check_func): don't require lines to end in '\n' * gtk/gtktextview.c (gtk_text_view_move_cursor): update to use forward_to_delimiters, and grapheme boundaries (gtk_text_view_delete_from_cursor): properly handle non-newline delimiters, and grapheme boundaries * gtk/gtktextiter.c (gtk_text_iter_forward_to_newline): rename to gtk_text_iter_forward_to_delimiters, and make it work properly if empty lines end with a character other than '\n' * gtk/gtktextiter.h, gtk/gtktextiter.c: Add movement by cursor position
Diffstat (limited to 'gtk/gtktextiter.c')
-rw-r--r--gtk/gtktextiter.c105
1 files changed, 102 insertions, 3 deletions
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index 2e181f37e..226604d82 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -2606,6 +2606,94 @@ gtk_text_iter_inside_word (const GtkTextIter *iter)
return test_log_attrs (iter, inside_word_func, NULL);
}
+static gboolean
+find_cursor_pos_func (const PangoLogAttr *attrs,
+ gint offset,
+ gint min_offset,
+ gint len,
+ gint *found_offset)
+{
+ ++offset; /* We always go to the NEXT position */
+
+ /* Find end of next word */
+ while (offset < min_offset + len &&
+ !attrs[offset].is_cursor_position)
+ ++offset;
+
+ *found_offset = offset;
+
+ return offset < min_offset + len;
+}
+
+static gboolean
+is_cursor_pos_func (const PangoLogAttr *attrs,
+ gint offset,
+ gint min_offset,
+ gint len,
+ gint *found_offset)
+{
+ return attrs[offset].is_cursor_position;
+}
+
+gboolean
+gtk_text_iter_forward_cursor_position (GtkTextIter *iter)
+{
+ return find_by_log_attrs (iter, find_cursor_pos_func, TRUE);
+
+}
+
+gboolean
+gtk_text_iter_backward_cursor_position (GtkTextIter *iter)
+{
+ return find_by_log_attrs (iter, find_cursor_pos_func, FALSE);
+}
+
+gboolean
+gtk_text_iter_forward_cursor_positions (GtkTextIter *iter,
+ gint count)
+{
+ g_return_val_if_fail (iter != NULL, FALSE);
+ g_return_val_if_fail (count > 0, FALSE);
+
+ if (!gtk_text_iter_forward_cursor_position (iter))
+ return FALSE;
+ --count;
+
+ while (count > 0)
+ {
+ if (!gtk_text_iter_forward_cursor_position (iter))
+ break;
+ --count;
+ }
+ return TRUE;
+}
+
+gboolean
+gtk_text_iter_backward_cursor_positions (GtkTextIter *iter,
+ gint count)
+{
+ g_return_val_if_fail (iter != NULL, FALSE);
+ g_return_val_if_fail (count > 0, FALSE);
+
+ if (!gtk_text_iter_backward_cursor_position (iter))
+ return FALSE;
+ --count;
+
+ while (count > 0)
+ {
+ if (!gtk_text_iter_backward_cursor_position (iter))
+ break;
+ --count;
+ }
+ return TRUE;
+}
+
+gboolean
+gtk_text_iter_is_cursor_position (const GtkTextIter *iter)
+{
+ return test_log_attrs (iter, is_cursor_pos_func, NULL);
+}
+
void
gtk_text_iter_set_line_offset (GtkTextIter *iter,
gint char_on_line)
@@ -2732,8 +2820,19 @@ gtk_text_iter_forward_to_end (GtkTextIter *iter)
gtk_text_buffer_get_last_iter (buffer, iter);
}
+/**
+ * gtk_text_iter_forward_to_delimiters:
+ * @iter: a #GtkTextIter
+ *
+ * Moves the iterator to point to the paragraph delimiter characters,
+ * which will be either a newline, a carriage return, a carriage
+ * return/newline in sequence, or the Unicode paragraph separator
+ * character.
+ *
+ * Return value: %TRUE if we moved and the new location is not the end iterator
+ **/
gboolean
-gtk_text_iter_forward_to_newline (GtkTextIter *iter)
+gtk_text_iter_forward_to_delimiters (GtkTextIter *iter)
{
gint current_offset;
gint new_offset;
@@ -2757,8 +2856,8 @@ gtk_text_iter_forward_to_newline (GtkTextIter *iter)
/* We don't want to move past all
* empty lines.
*/
- if (gtk_text_iter_get_char (iter) != '\n')
- gtk_text_iter_forward_to_newline (iter);
+ if (!gtk_text_iter_ends_line (iter))
+ gtk_text_iter_forward_to_delimiters (iter);
return TRUE;
}
else