placing a cursor and scrolling automatically



Hello gtk-devel,
I've created a text view in a scrolled window and I'd like my scrolled window to automatically scroll whenever the cursor goes offscreen.
Here's my code(in ocaml)

open Gobject
let _ =
  let source_window = GWindow.window () in
  let scrolled_window = GBin.scrolled_window ~packing:source_window#add () in
  let buffer = GText.buffer () in
  let view = GText.view ~buffer:buffer ~packing:scrolled_window#add  () in
    buffer#insert "santo\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nsanto\nnot\n";
    buffer#place_cursor (buffer#get_iter (`OFFSET 500));
    source_window#show ();
    source_window#maximize ();
    GMain.Main.main ()
     


how can this be done?
cheers
--Jacques


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]