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
This commit is contained in:
Havoc Pennington 2001-10-04 00:22:13 +00:00 committed by Havoc Pennington
parent 3c09d348d3
commit 739ffc4934
15 changed files with 279 additions and 119 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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.

View File

@ -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>

View File

@ -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>

View File

@ -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;
@ -1929,6 +1932,22 @@ _gtk_text_btree_get_end_iter_line (GtkTextBTree *tree)
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,
@ -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;
}

View File

@ -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,

View File

@ -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);

View File

@ -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;