TextView or SourceView line numbers

Hello all,

I am trying a very simple text view attempt and I would like to see the line numbers of the widget. I read that I should be using gtksourceview instead of textview but I found it very complicated and I could not find any examples or tutorial to try. Can you give me an example for the easiest and simplest way of using sourceview to only show line numbers ?

Thank in advance

GtkSource.View is a subclass of Gtk.TextView. Therefore, you can use it the same way you would use a Gtk.TextView. Just set the show-line-numbers property to TRUE.

GtkWidget *source_view = gtk_source_view_new ();
gtk_source_view_set_show_line_numbers (GTK_SOURCE_VIEW (source_view), TRUE);
1 Like

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