Page 1 of 1

EditorGadget - scroll to end

Posted: Tue Jan 15, 2008 8:22 pm
by dhouston
There was a recent thread on moving the cursor in an EditorGadget or, more specifically, in the Text Buffer associated with an EditorGadget.

My need was related but a little different. My app always adds lines at the end of the buffer and I need to scroll the Text View to put the last line onscreen.

Code: Select all

Procedure ScrollToEnd(gadget)
  ;scrolls text view to display last line
  Protected end_mark,*buffer, end_iter.GtkTextIter
  *buffer=gtk_text_view_get_buffer_(GadgetID(gadget)) 
  gtk_text_buffer_get_end_iter_(*buffer,@end_iter)
  ;gtk_text_buffer_place_cursor_(*buffer,@end_iter)
  end_mark=gtk_text_buffer_create_mark_(*buffer,"",@end_iter,#False)
  gtk_text_view_scroll_mark_onscreen_(GadgetID(gadget),end_mark)
EndProcedure

Posted: Wed Jan 16, 2008 12:35 pm
by bembulak
Very usefull!
Thanks for sharing!