#include <gtk/gtk.h>

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

	gtk_init (&argc, &argv);

	buffer = gtk_text_buffer_new (NULL);
	gtk_text_buffer_set_text (buffer, "שרה שרה שיר שמח", -1);

	gtk_text_buffer_get_start_iter (buffer, &iter);
	g_print ("%d", gtk_text_iter_get_offset (&iter));
	while (!gtk_text_iter_is_end (&iter))
	{
		gtk_text_iter_forward_word_end (&iter);
		g_print (" %d", gtk_text_iter_get_offset (&iter));
		g_assert (gtk_text_iter_ends_word (&iter));
	}
	g_print ("\n");

	gtk_text_buffer_get_end_iter (buffer, &iter);
	g_print ("%d", gtk_text_iter_get_offset (&iter));
	while (!gtk_text_iter_is_start (&iter))
	{
		gtk_text_iter_backward_word_start (&iter);
		g_print (" %d", gtk_text_iter_get_offset (&iter));
		g_assert (gtk_text_iter_starts_word (&iter));
		g_assert (gtk_text_iter_inside_word (&iter));
	}
	g_print ("\n");

	return 0;
}
