Details

[Home]

Issue of the Implementation # D0161

Brief

gtk_text_iter_backward_visible_line does not ignore ' ' in text marked up with invisible tag.

Detailed Description

gtk_text_iter_backward_visible_line must ignore text marked up with invisible tag, but it doesn't ignore the ' ' characters in the invisible text and moves iter to previous visible character before invisible ' ' and not to the previous visible character before visible new line symbol.

Problem location(s) in the standard

LSB that refers http://library.gnome.org/devel/gtk/2.8/gtk-GtkTextIter.html

Example

#include <gtk/gtk.h>
#include <glib.h>
#include <stdio.h>

int main (int argc, char **argv)
{
  
	GtkWidget *textView = NULL;
	GtkTextBuffer *buffer = NULL;
	GtkTextIter iter;
	GtkTextIter tiStart;
	GtkTextIter tiEnd;
	gchar *txt = "abc
defg
hi
jklm";
	gtk_init(&argc, &argv);

	textView = gtk_text_view_new ();
	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textView));
	gtk_text_buffer_set_text (buffer, txt, -1);

// Marking up a 10 to 14 bytes of the text with invisible tag i->l
	gtk_text_buffer_get_iter_at_offset (buffer, &tiStart, 10);
	gtk_text_buffer_get_iter_at_offset (buffer, &tiEnd, 14);
    	GtkTextTag *text_tag = gtk_text_buffer_create_tag (buffer, NULL, 
				"invisible", TRUE, NULL);
    	gtk_text_buffer_apply_tag (buffer, text_tag, &tiStart, &tiEnd);	
	

	gtk_text_buffer_get_end_iter (buffer, &iter);

	gtk_text_iter_backward_visible_line (&iter);

// gtk_text_iter_backward_visible_line must ignore characters which are marked 
// up with invisible tag
	if (gtk_text_iter_get_char(&iter) != 'd') {
		printf ("Current position of iter in text "%s" is %d, but "
			"should be %d.
", 
			txt, gtk_text_iter_get_offset(&iter), 4);
		printf ("Character at position of %d is %c, at position %d is "
			"%c.
",
			gtk_text_iter_get_offset(&iter), 
			gtk_text_iter_get_char(&iter), 4, 'd');
	}
	return 0;
	
}

Component

gtk+

Accepted

Gnome Bugzilla, 640160

[Home]