EditorGadget - scroll to end

Linux specific forum
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

EditorGadget - scroll to end

Post 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
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 576
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

Very usefull!
Thanks for sharing!
cheers,

bembulak
Post Reply