diff options
author | Havoc Pennington <hp@redhat.com> | 2001-10-04 00:22:13 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-10-04 00:22:13 +0000 |
commit | 739ffc4934dae8eb1ed2e12eaa9f4772ac715f89 (patch) | |
tree | ff46498583ea76816fbf956652b8b05488ec4aa0 | |
parent | 3c09d348d307f4dc61de16ef8163856ebc34022f (diff) | |
download | gtk+-739ffc4934dae8eb1ed2e12eaa9f4772ac715f89.tar.gz |
fix test case, it previously verified incorrect behavior
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
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 19 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 19 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 19 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 19 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 19 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 19 | ||||
-rw-r--r-- | docs/reference/gtk/tmpl/gtk-unused.sgml | 96 | ||||
-rw-r--r-- | docs/reference/gtk/tmpl/gtkeditable.sgml | 44 | ||||
-rw-r--r-- | docs/reference/gtk/tmpl/gtkentry.sgml | 26 | ||||
-rw-r--r-- | docs/reference/gtk/tmpl/gtkoldeditable.sgml | 26 | ||||
-rw-r--r-- | gtk/gtktextbtree.c | 33 | ||||
-rw-r--r-- | gtk/gtktextbtree.h | 3 | ||||
-rw-r--r-- | gtk/gtktextiter.c | 33 | ||||
-rw-r--r-- | tests/testtextbuffer.c | 4 |
15 files changed, 279 insertions, 119 deletions
@@ -1,3 +1,22 @@ +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 diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index afe3d37a83..f901bdd679 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,22 @@ +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 diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index afe3d37a83..f901bdd679 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,22 @@ +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 diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index afe3d37a83..f901bdd679 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,22 @@ +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 diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index afe3d37a83..f901bdd679 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,22 @@ +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 diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index afe3d37a83..f901bdd679 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,22 @@ +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 diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index afe3d37a83..f901bdd679 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,22 @@ +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 diff --git a/docs/reference/gtk/tmpl/gtk-unused.sgml b/docs/reference/gtk/tmpl/gtk-unused.sgml index a0b014f627..3686e8751a 100644 --- a/docs/reference/gtk/tmpl/gtk-unused.sgml +++ b/docs/reference/gtk/tmpl/gtk-unused.sgml @@ -544,14 +544,6 @@ Control-Return for #GtkText.) @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 @@ -569,42 +561,6 @@ the widget. @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. @@ -729,6 +685,32 @@ You may not attach these to signals created with the @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 @@ -835,6 +817,32 @@ after other user handlers and the default handler. </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> diff --git a/docs/reference/gtk/tmpl/gtkeditable.sgml b/docs/reference/gtk/tmpl/gtkeditable.sgml index 399aad6915..05238afeea 100644 --- a/docs/reference/gtk/tmpl/gtkeditable.sgml +++ b/docs/reference/gtk/tmpl/gtkeditable.sgml @@ -252,3 +252,47 @@ widget or not. @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. + diff --git a/docs/reference/gtk/tmpl/gtkentry.sgml b/docs/reference/gtk/tmpl/gtkentry.sgml index a461020b53..070fb1e231 100644 --- a/docs/reference/gtk/tmpl/gtkentry.sgml +++ b/docs/reference/gtk/tmpl/gtkentry.sgml @@ -287,13 +287,6 @@ to fit. @entry: the object which received the signal. -<!-- ##### SIGNAL GtkEntry::changed ##### --> -<para> - -</para> - -@entry: the object which received the signal. - <!-- ##### SIGNAL GtkEntry::copy-clipboard ##### --> <para> @@ -317,15 +310,6 @@ to fit. @arg1: @arg2: -<!-- ##### SIGNAL GtkEntry::delete-text ##### --> -<para> - -</para> - -@entry: the object which received the signal. -@arg1: -@arg2: - <!-- ##### SIGNAL GtkEntry::insert-at-cursor ##### --> <para> @@ -334,16 +318,6 @@ to fit. @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> diff --git a/docs/reference/gtk/tmpl/gtkoldeditable.sgml b/docs/reference/gtk/tmpl/gtkoldeditable.sgml index c59280ccfc..2f0580157f 100644 --- a/docs/reference/gtk/tmpl/gtkoldeditable.sgml +++ b/docs/reference/gtk/tmpl/gtkoldeditable.sgml @@ -58,13 +58,6 @@ GtkOldEditable @oldeditable: the object which received the signal. -<!-- ##### SIGNAL GtkOldEditable::changed ##### --> -<para> - -</para> - -@oldeditable: the object which received the signal. - <!-- ##### SIGNAL GtkOldEditable::copy-clipboard ##### --> <para> @@ -79,25 +72,6 @@ GtkOldEditable @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> diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c index 8402b2508e..3659538960 100644 --- a/gtk/gtktextbtree.c +++ b/gtk/gtktextbtree.c @@ -1854,10 +1854,11 @@ _gtk_text_btree_tag (const GtkTextIter *start_orig, * "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; @@ -1865,7 +1866,9 @@ _gtk_text_btree_get_line (GtkTextBTree *tree, 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; @@ -1930,6 +1933,22 @@ _gtk_text_btree_get_end_iter_line (GtkTextBTree *tree) } 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, gint *line_start_index, @@ -2919,7 +2938,7 @@ _gtk_text_btree_last_could_contain_tag (GtkTextBTree *tree, 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); } } @@ -3181,7 +3200,7 @@ ensure_end_iter_line (GtkTextBTree *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; } diff --git a/gtk/gtktextbtree.h b/gtk/gtktextbtree.h index b3434ff4d6..2736fa6988 100644 --- a/gtk/gtktextbtree.h +++ b/gtk/gtktextbtree.h @@ -87,6 +87,9 @@ void _gtk_text_btree_tag (const GtkTextIter *start, 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, diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c index 62cbde55b5..1b8fbf9317 100644 --- a/gtk/gtktextiter.c +++ b/gtk/gtktextiter.c @@ -2569,7 +2569,7 @@ gtk_text_iter_backward_line (GtkTextIter *iter) /* 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); @@ -2618,16 +2618,21 @@ gtk_text_iter_forward_lines (GtkTextIter *iter, gint count) { 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); } } @@ -3647,7 +3652,7 @@ gtk_text_iter_set_line (GtkTextIter *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); @@ -4887,7 +4892,7 @@ _gtk_text_btree_get_iter_at_char (GtkTextBTree *tree, 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); @@ -4898,9 +4903,9 @@ _gtk_text_btree_get_iter_at_char (GtkTextBTree *tree, 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; @@ -4909,7 +4914,7 @@ _gtk_text_btree_get_iter_at_line_char (GtkTextBTree *tree, 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); @@ -4932,7 +4937,7 @@ _gtk_text_btree_get_iter_at_line_byte (GtkTextBTree *tree, 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); diff --git a/tests/testtextbuffer.c b/tests/testtextbuffer.c index 175deb9857..0e29a0768f 100644 --- a/tests/testtextbuffer.c +++ b/tests/testtextbuffer.c @@ -1039,9 +1039,9 @@ logical_motion_tests (void) 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; |