How do I understand what the following means?
Posted
by Runner
on Stack Overflow
See other posts from Stack Overflow
or by Runner
Published on 2010-05-01T16:43:07Z
Indexed on
2010/05/01
16:47 UTC
Read the original article
Hit count: 295
Quoted from here:
if (to_end)
{
/* If we want to scroll to the end, including horizontal scrolling,
* then we just create a mark with right gravity at the end of the
* buffer. It will stay at the end unless explicitely moved with
* gtk_text_buffer_move_mark.
*/
gtk_text_buffer_create_mark (buffer, "end", &iter, FALSE);
/* Add scrolling timeout. */
return g_timeout_add (50, (GSourceFunc) scroll_to_end, textview);
}
else
{
/* If we want to scroll to the bottom, but not scroll horizontally,
* then an end mark won't do the job. Just create a mark so we can
* use it with gtk_text_view_scroll_mark_onscreen, we'll position it
* explicitely when needed. Use left gravity so the mark stays where
* we put it after inserting new text.
*/
gtk_text_buffer_create_mark (buffer, "scroll", &iter, TRUE);
/* Add scrolling timeout. */
return g_timeout_add (100, (GSourceFunc) scroll_to_bottom, textview);
}
Though there are quite a few lines of comments, I still don't understand the logic in it,especially, what's the relation between an mark and the position of scroll bar?
© Stack Overflow or respective owner