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

static void
print_buffer (GtkTextBuffer *buffer)
{
	GtkTextIter iter;

	gtk_text_buffer_get_start_iter (buffer, &iter);

	do
	{
		printf ("char #%d at line %d\n",
			(int) gtk_text_iter_get_char (&iter),
			gtk_text_iter_get_line (&iter));
	}
	while (gtk_text_iter_forward_char (&iter));
}

int
main (int argc, char *argv[])
{
	GtkTextBuffer *buffer;
	GtkTextIter iter;

	gtk_init (&argc, &argv);

	printf ("Inserting split pair\n");
	buffer = gtk_text_buffer_new (NULL);

	gtk_text_buffer_get_start_iter (buffer, &iter);
	gtk_text_buffer_insert (buffer, &iter, "a\r", -1);
	gtk_text_buffer_insert (buffer, &iter, "\nb", -1);

	print_buffer (buffer);

	printf ("\nInserting joined pair\n");
	buffer = gtk_text_buffer_new (NULL);

	gtk_text_buffer_get_start_iter (buffer, &iter);
	gtk_text_buffer_insert (buffer, &iter, "a\r\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "b", -1);

	print_buffer (buffer);

	return 0;
}
