+2001-10-03 Havoc Pennington <hp@redhat.com>
+
+ * tests/testtextbuffer.c (logical_motion_tests): fix test case,
+ it previously verified incorrect behavior
+
+ Fixes for #61565
+
+ * gtk/gtktextiter.c (gtk_text_iter_set_line): don't return lines
+ off the end
+ (_gtk_text_btree_get_iter_at_line_char): don't return lines off
+ the end
+ (_gtk_text_btree_get_iter_at_line_byte): don't return lines off
+ the end
+ (gtk_text_iter_forward_lines): if on the last line, move to end of
+ it
+
+ * gtk/gtktextbtree.c (_gtk_text_btree_last_could_contain_tag):
+ don't return a line off the end
+
Wed Oct 3 23:47:25 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkeditable.[ch]: move insert_text and delete_text virtual
+2001-10-03 Havoc Pennington <hp@redhat.com>
+
+ * tests/testtextbuffer.c (logical_motion_tests): fix test case,
+ it previously verified incorrect behavior
+
+ Fixes for #61565
+
+ * gtk/gtktextiter.c (gtk_text_iter_set_line): don't return lines
+ off the end
+ (_gtk_text_btree_get_iter_at_line_char): don't return lines off
+ the end
+ (_gtk_text_btree_get_iter_at_line_byte): don't return lines off
+ the end
+ (gtk_text_iter_forward_lines): if on the last line, move to end of
+ it
+
+ * gtk/gtktextbtree.c (_gtk_text_btree_last_could_contain_tag):
+ don't return a line off the end
+
Wed Oct 3 23:47:25 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkeditable.[ch]: move insert_text and delete_text virtual
+2001-10-03 Havoc Pennington <hp@redhat.com>
+
+ * tests/testtextbuffer.c (logical_motion_tests): fix test case,
+ it previously verified incorrect behavior
+
+ Fixes for #61565
+
+ * gtk/gtktextiter.c (gtk_text_iter_set_line): don't return lines
+ off the end
+ (_gtk_text_btree_get_iter_at_line_char): don't return lines off
+ the end
+ (_gtk_text_btree_get_iter_at_line_byte): don't return lines off
+ the end
+ (gtk_text_iter_forward_lines): if on the last line, move to end of
+ it
+
+ * gtk/gtktextbtree.c (_gtk_text_btree_last_could_contain_tag):
+ don't return a line off the end
+
Wed Oct 3 23:47:25 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkeditable.[ch]: move insert_text and delete_text virtual
+2001-10-03 Havoc Pennington <hp@redhat.com>
+
+ * tests/testtextbuffer.c (logical_motion_tests): fix test case,
+ it previously verified incorrect behavior
+
+ Fixes for #61565
+
+ * gtk/gtktextiter.c (gtk_text_iter_set_line): don't return lines
+ off the end
+ (_gtk_text_btree_get_iter_at_line_char): don't return lines off
+ the end
+ (_gtk_text_btree_get_iter_at_line_byte): don't return lines off
+ the end
+ (gtk_text_iter_forward_lines): if on the last line, move to end of
+ it
+
+ * gtk/gtktextbtree.c (_gtk_text_btree_last_could_contain_tag):
+ don't return a line off the end
+
Wed Oct 3 23:47:25 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkeditable.[ch]: move insert_text and delete_text virtual
+2001-10-03 Havoc Pennington <hp@redhat.com>
+
+ * tests/testtextbuffer.c (logical_motion_tests): fix test case,
+ it previously verified incorrect behavior
+
+ Fixes for #61565
+
+ * gtk/gtktextiter.c (gtk_text_iter_set_line): don't return lines
+ off the end
+ (_gtk_text_btree_get_iter_at_line_char): don't return lines off
+ the end
+ (_gtk_text_btree_get_iter_at_line_byte): don't return lines off
+ the end
+ (gtk_text_iter_forward_lines): if on the last line, move to end of
+ it
+
+ * gtk/gtktextbtree.c (_gtk_text_btree_last_could_contain_tag):
+ don't return a line off the end
+
Wed Oct 3 23:47:25 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkeditable.[ch]: move insert_text and delete_text virtual
+2001-10-03 Havoc Pennington <hp@redhat.com>
+
+ * tests/testtextbuffer.c (logical_motion_tests): fix test case,
+ it previously verified incorrect behavior
+
+ Fixes for #61565
+
+ * gtk/gtktextiter.c (gtk_text_iter_set_line): don't return lines
+ off the end
+ (_gtk_text_btree_get_iter_at_line_char): don't return lines off
+ the end
+ (_gtk_text_btree_get_iter_at_line_byte): don't return lines off
+ the end
+ (gtk_text_iter_forward_lines): if on the last line, move to end of
+ it
+
+ * gtk/gtktextbtree.c (_gtk_text_btree_last_could_contain_tag):
+ don't return a line off the end
+
Wed Oct 3 23:47:25 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkeditable.[ch]: move insert_text and delete_text virtual
+2001-10-03 Havoc Pennington <hp@redhat.com>
+
+ * tests/testtextbuffer.c (logical_motion_tests): fix test case,
+ it previously verified incorrect behavior
+
+ Fixes for #61565
+
+ * gtk/gtktextiter.c (gtk_text_iter_set_line): don't return lines
+ off the end
+ (_gtk_text_btree_get_iter_at_line_char): don't return lines off
+ the end
+ (_gtk_text_btree_get_iter_at_line_byte): don't return lines off
+ the end
+ (gtk_text_iter_forward_lines): if on the last line, move to end of
+ it
+
+ * gtk/gtktextbtree.c (_gtk_text_btree_last_could_contain_tag):
+ don't return a line off the end
+
Wed Oct 3 23:47:25 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkeditable.[ch]: move insert_text and delete_text virtual
@editable: the object which received the signal.
-<!-- ##### SIGNAL GtkEditable::changed ##### -->
-<para>
-Indicates that the user has changed the contents
-of the widget.
-</para>
-
-@editable: the object which received the signal.
-
<!-- ##### SIGNAL GtkEditable::copy-clipboard ##### -->
<para>
An action signal. Causes the characters in the current selection to
@editable: the object which received the signal.
-<!-- ##### SIGNAL GtkEditable::delete-text ##### -->
-<para>
-This signal is emitted when text is deleted from
-the widget by the user. The default handler for
-this signal will normally be responsible for inserting
-the text, so by connecting to this signal and then
-stopping the signal with gtk_signal_emit_stop(), it
-is possible to modify the inserted text, or prevent
-it from being inserted entirely. The @start_pos
-and @end_pos parameters are interpreted as for
-gtk_editable_delete_text()
-</para>
-
-@editable: the object which received the signal.
-@start_pos: the starting position.
-@end_pos: the end position.
-
-<!-- ##### SIGNAL GtkEditable::insert-text ##### -->
-<para>
-This signal is emitted when text is inserted into
-the widget by the user. The default handler for
-this signal will normally be responsible for inserting
-the text, so by connecting to this signal and then
-stopping the signal with gtk_signal_emit_stop(), it
-is possible to modify the inserted text, or prevent
-it from being inserted entirely.
-</para>
-
-@editable: the object which received the signal.
-@new_text: the new text to insert.
-@new_text_length: the length of the new text.
-@position: the position at which to insert the new text.
- this is an in-out paramter. After the signal
- emission is finished, it should point after
- the newly inserted text.
-
<!-- ##### SIGNAL GtkEditable::kill-char ##### -->
<para>
An action signal. Delete a single character.
@data:
@Returns:
+<!-- ##### SIGNAL GtkEntry::changed ##### -->
+<para>
+
+</para>
+
+@entry: the object which received the signal.
+
+<!-- ##### SIGNAL GtkEntry::delete-text ##### -->
+<para>
+
+</para>
+
+@entry: the object which received the signal.
+@arg1:
+@arg2:
+
+<!-- ##### SIGNAL GtkEntry::insert-text ##### -->
+<para>
+
+</para>
+
+@entry: the object which received the signal.
+@arg1:
+@arg2:
+@arg3:
+
<!-- ##### ENUM GtkFontFilterType ##### -->
<para>
A set of bit flags used to specify the filter being set
</para>
+<!-- ##### SIGNAL GtkOldEditable::changed ##### -->
+<para>
+
+</para>
+
+@oldeditable: the object which received the signal.
+
+<!-- ##### SIGNAL GtkOldEditable::delete-text ##### -->
+<para>
+
+</para>
+
+@oldeditable: the object which received the signal.
+@arg1:
+@arg2:
+
+<!-- ##### SIGNAL GtkOldEditable::insert-text ##### -->
+<para>
+
+</para>
+
+@oldeditable: the object which received the signal.
+@arg1:
+@arg2:
+@arg3:
+
<!-- ##### ARG GtkPacker:default-border-width ##### -->
<para>
@Returns:
+<!-- ##### SIGNAL GtkEditable::changed ##### -->
+<para>
+Indicates that the user has changed the contents
+of the widget.
+</para>
+
+@editable: the object which received the signal.
+
+<!-- ##### SIGNAL GtkEditable::delete-text ##### -->
+<para>
+This signal is emitted when text is deleted from
+the widget by the user. The default handler for
+this signal will normally be responsible for inserting
+the text, so by connecting to this signal and then
+stopping the signal with gtk_signal_emit_stop(), it
+is possible to modify the inserted text, or prevent
+it from being inserted entirely. The @start_pos
+and @end_pos parameters are interpreted as for
+gtk_editable_delete_text()
+</para>
+
+@editable: the object which received the signal.
+@start_pos: the starting position.
+@end_pos: the end position.
+
+<!-- ##### SIGNAL GtkEditable::insert-text ##### -->
+<para>
+This signal is emitted when text is inserted into
+the widget by the user. The default handler for
+this signal will normally be responsible for inserting
+the text, so by connecting to this signal and then
+stopping the signal with gtk_signal_emit_stop(), it
+is possible to modify the inserted text, or prevent
+it from being inserted entirely.
+</para>
+
+@editable: the object which received the signal.
+@new_text: the new text to insert.
+@new_text_length: the length of the new text.
+@position: the position at which to insert the new text.
+ this is an in-out paramter. After the signal
+ emission is finished, it should point after
+ the newly inserted text.
+
@entry: the object which received the signal.
-<!-- ##### SIGNAL GtkEntry::changed ##### -->
-<para>
-
-</para>
-
-@entry: the object which received the signal.
-
<!-- ##### SIGNAL GtkEntry::copy-clipboard ##### -->
<para>
@arg1:
@arg2:
-<!-- ##### SIGNAL GtkEntry::delete-text ##### -->
-<para>
-
-</para>
-
-@entry: the object which received the signal.
-@arg1:
-@arg2:
-
<!-- ##### SIGNAL GtkEntry::insert-at-cursor ##### -->
<para>
@entry: the object which received the signal.
@arg1:
-<!-- ##### SIGNAL GtkEntry::insert-text ##### -->
-<para>
-
-</para>
-
-@entry: the object which received the signal.
-@arg1:
-@arg2:
-@arg3:
-
<!-- ##### SIGNAL GtkEntry::move-cursor ##### -->
<para>
@oldeditable: the object which received the signal.
-<!-- ##### SIGNAL GtkOldEditable::changed ##### -->
-<para>
-
-</para>
-
-@oldeditable: the object which received the signal.
-
<!-- ##### SIGNAL GtkOldEditable::copy-clipboard ##### -->
<para>
@oldeditable: the object which received the signal.
-<!-- ##### SIGNAL GtkOldEditable::delete-text ##### -->
-<para>
-
-</para>
-
-@oldeditable: the object which received the signal.
-@arg1:
-@arg2:
-
-<!-- ##### SIGNAL GtkOldEditable::insert-text ##### -->
-<para>
-
-</para>
-
-@oldeditable: the object which received the signal.
-@arg1:
-@arg2:
-@arg3:
-
<!-- ##### SIGNAL GtkOldEditable::kill-char ##### -->
<para>
* "Getters"
*/
-GtkTextLine*
-_gtk_text_btree_get_line (GtkTextBTree *tree,
- gint line_number,
- gint *real_line_number)
+static GtkTextLine*
+get_line_internal (GtkTextBTree *tree,
+ gint line_number,
+ gint *real_line_number,
+ gboolean include_last)
{
GtkTextBTreeNode *node;
GtkTextLine *line;
int line_count;
line_count = _gtk_text_btree_line_count (tree);
-
+ if (!include_last)
+ line_count -= 1;
+
if (line_number < 0)
{
line_number = line_count;
NULL);
}
+GtkTextLine*
+_gtk_text_btree_get_line (GtkTextBTree *tree,
+ gint line_number,
+ gint *real_line_number)
+{
+ return get_line_internal (tree, line_number, real_line_number, TRUE);
+}
+
+GtkTextLine*
+_gtk_text_btree_get_line_no_last (GtkTextBTree *tree,
+ gint line_number,
+ gint *real_line_number)
+{
+ return get_line_internal (tree, line_number, real_line_number, FALSE);
+}
+
GtkTextLine*
_gtk_text_btree_get_line_at_char (GtkTextBTree *tree,
gint char_index,
at least not without complexity.
So, we just return the last line.
*/
- return _gtk_text_btree_get_line (tree, -1, NULL);
+ return _gtk_text_btree_get_end_iter_line (tree);
}
}
g_assert (n_lines >= 1);
- tree->end_iter_line = _gtk_text_btree_get_line (tree, n_lines - 1, &real_line);
+ tree->end_iter_line = _gtk_text_btree_get_line_no_last (tree, -1, &real_line);
tree->end_iter_line_stamp = tree->chars_changed_stamp;
}
GtkTextLine * _gtk_text_btree_get_line (GtkTextBTree *tree,
gint line_number,
gint *real_line_number);
+GtkTextLine * _gtk_text_btree_get_line_no_last (GtkTextBTree *tree,
+ gint line_number,
+ gint *real_line_number);
GtkTextLine * _gtk_text_btree_get_end_iter_line (GtkTextBTree *tree);
GtkTextLine * _gtk_text_btree_get_line_at_char (GtkTextBTree *tree,
gint char_index,
/* Find first segment in line */
real->any_segment = real->line->segments;
real->segment = _gtk_text_line_byte_to_segment (real->line,
- 0, &offset);
+ 0, &offset);
g_assert (offset == 0);
{
gint old_line;
+ if (gtk_text_iter_is_end (iter))
+ return FALSE;
+
old_line = gtk_text_iter_get_line (iter);
gtk_text_iter_set_line (iter, old_line + count);
- check_invariants (iter);
-
- /* return whether it moved, and is dereferenceable. */
- return
- (gtk_text_iter_get_line (iter) != old_line) &&
- !gtk_text_iter_is_end (iter);
+ if ((gtk_text_iter_get_line (iter) - old_line) < count)
+ {
+ /* count went past the last line, so move to end of last line */
+ if (!gtk_text_iter_is_end (iter))
+ gtk_text_iter_forward_to_end (iter);
+ }
+
+ return !gtk_text_iter_is_end (iter);
}
}
check_invariants (iter);
- line = _gtk_text_btree_get_line (real->tree, line_number, &real_line);
+ line = _gtk_text_btree_get_line_no_last (real->tree, line_number, &real_line);
iter_set_from_char_offset (real, line, 0);
g_return_if_fail (tree != NULL);
line = _gtk_text_btree_get_line_at_char (tree, char_index,
- &line_start, &real_char_index);
+ &line_start, &real_char_index);
iter_init_from_char_offset (iter, tree, line, real_char_index - line_start);
void
_gtk_text_btree_get_iter_at_line_char (GtkTextBTree *tree,
- GtkTextIter *iter,
- gint line_number,
- gint char_on_line)
+ GtkTextIter *iter,
+ gint line_number,
+ gint char_on_line)
{
GtkTextRealIter *real = (GtkTextRealIter*)iter;
GtkTextLine *line;
g_return_if_fail (iter != NULL);
g_return_if_fail (tree != NULL);
- line = _gtk_text_btree_get_line (tree, line_number, &real_line);
+ line = _gtk_text_btree_get_line_no_last (tree, line_number, &real_line);
iter_init_from_char_offset (iter, tree, line, char_on_line);
g_return_if_fail (iter != NULL);
g_return_if_fail (tree != NULL);
- line = _gtk_text_btree_get_line (tree, line_number, &real_line);
+ line = _gtk_text_btree_get_line_no_last (tree, line_number, &real_line);
iter_init_from_byte_offset (iter, tree, line, byte_index);
memset (expected, 0, sizeof (expected));
expected[0] = 24;
- expected[1] = 22;
+ expected[1] = 21;
expected[2] = 17;
- expected[3] = 14;
+ expected[3] = 13;
expected[4] = 9;
expected[5] = 4;
expected[6] = 0;