Details

[Home]

Issue of the Implementation # D0159

Brief

gtk_text_iter_forward_visible_line does not ignore ' ' in invisible tag.

Detailed Description

gtk_text_iter_forward_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 next visible character after invisible ' ' and not to the next visible character after 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 1 to 4 bytes of the text with invisible tag 
	gtk_text_buffer_get_iter_at_offset (buffer, &tiStart, 1);
	gtk_text_buffer_get_iter_at_offset (buffer, &tiEnd, 5);
    	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_start_iter (buffer, &iter);

	gtk_text_iter_forward_visible_line (&iter);

// gtk_text_iter_forward_visible_line must ignore characters which are marked 
// up with invisible tag
	if (gtk_text_iter_get_char(&iter) != 'h') {
		printf ("Current position of iter in text "%s" is %d, but "
			"should be %d.
", 
			txt, gtk_text_iter_get_offset(&iter), 9);
		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), 9, 'h');
	}
	return 0;
}

Component

gtk+

Accepted

Gnome Bugzilla, 636285

[Home]