How to (programmatically) scroll to a specific line in gtktextview / gtksourceview

I am creating a text editor as a way to get to know C and gtk +. I use gtk + -2.0 and gtksourceview-2.0, and gtk_scrolled_window. As the first attempt to create a goto function browser, I decided to simply create an array of the functions found in the document and the corresponding array of lines on which they occur. I have done so much. I was surprised to find that there are no features for the goto line that I can easily find in devhelp. It seems that gtk_text_view_scroll_to_mark () is what I want (after creating the label), but all * scroll_to functions require int_margin, which, to be honest, I really don't understand:

From devhelp:

The effective screen for this function is reduced by using the size field inside margin.

What does it mean?

Am I even close? How can I create this scroll function to line number?

Thank.

UPDATE: The following three functions were used to scroll through a line in the buffer:

gtk_text_iter_set_line (&start, lineNums[9]);
gtk_text_buffer_add_mark (tbuffer, scroll2mark, &start);  
gtk_text_view_scroll_to_mark (text_view, scroll2mark, 0.0, TRUE, 0.0, 0.17);

The last parameter, gtk_text_view_scroll_to_mark, was used to get the target line number according to the top line in the buffer. I assume that this option will not work on all screen sizes, but I have not tested it.

The gtk_text_view_scroll_mark_onscreen function brought me closer to the line number, but it was just a couple of lines from the bottom of the text area.

+3
source share
1 answer

inside_margin , , , , , .

, use_align false (.. , ), , ( ).

, , , g_text_view_scroll_mark_on_screen, , . , .

+2

All Articles