Count logical lines in GtkTextView

Hi, ALL,

In the docs it meantions that the iterator retrieved will be at position 0.

However it doesn’t say whether it will point at the line 0 or line 1.

Consider the following:

    GtkTextIter iter;
    unsigned numberOfLines = 1;

    GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(m_text));
    gtk_text_buffer_get_start_iter(buffer, &iter);
    while( gtk_text_view_forward_display_line(GTK_TEXT_VIEW(m_text), &iter))
    {
        numberOfLines++;
    }
    return numberOfLines;

Do I initialize the numberOfLines to 0 or 1?

Based on the documentation it should be 0, but I’m not sure…

Thank you.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.