Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to (programmatically) scroll to a specific line in gtktextview/gtksourceview
    primarykey
    data
    text
    <p>I am creating a text editor as a way of getting more familiar with C and gtk+. I am using gtk+-2.0 &amp; gtksourceview-2.0, and gtk_scrolled_window . As a first attempt at creating a goto function browser I thought I would just simply create an array of functions found in the document and a corresponding array of lines on which they occur. I have that much done. I was surprised to find that there is no goto line capability that I can easily find in devhelp. It sounds like gtk_text_view_scroll_to_mark () is what I want (after creating a mark), but all the *scroll_to functions require a within_margin, which to be honest I don't really understand.:</p> <p>From devhelp:</p> <p>The effective screen for purposes of this function is reduced by a margin of size within_margin.</p> <p>What does that mean?</p> <p>Am I even close? How can I create this scroll to line number functionality?</p> <p>Thanks.</p> <p><strong>UPDATE:</strong> The following three functions were used to scroll to a line in the buffer:</p> <pre><code>gtk_text_iter_set_line (&amp;start, lineNums[9]); gtk_text_buffer_add_mark (tbuffer, scroll2mark, &amp;start); gtk_text_view_scroll_to_mark (text_view, scroll2mark, 0.0, TRUE, 0.0, 0.17); </code></pre> <p>The last parameter of gtk_text_view_scroll_to_mark was used to get the target line number to line up with the very top line in the buffer. I imagine this parameter will not work on all screen sizes, but I have not tested it.</p> <p>The gtk_text_view_scroll_mark_onscreen function got me close to the line number, but it was just a couple of lines off the bottom of the text area. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload