From a8eb19032d5bf75a5ac5fb18a3d0d4b070e0702c Mon Sep 17 00:00:00 2001 From: Jacques Garrigue Date: Thu, 22 Nov 2001 07:36:15 +0000 Subject: accepte commentaires avant ou apres git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4031 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- otherlibs/labltk/browser/editor.ml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'otherlibs/labltk/browser/editor.ml') diff --git a/otherlibs/labltk/browser/editor.ml b/otherlibs/labltk/browser/editor.ml index 2b280be0f..517599c6c 100644 --- a/otherlibs/labltk/browser/editor.ml +++ b/otherlibs/labltk/browser/editor.ml @@ -504,10 +504,23 @@ class editor ~top ~menus = object (self) if not (Winfo.ismapped top) then Wm.deiconify top; match file with None -> () | Some file -> - self#load_text [file]; + self#load_text [file]; Text.mark_set current_tw ~mark:"insert" ~index:(tpos pos); - Text.yview_index current_tw - ~index:(`Linechar(1,0),[`Char pos; `Line (-2)]) + try + let index = + Text.search current_tw ~switches:[`Backwards] ~pattern:"*)" + ~start:(tpos pos) ~stop:(tpos pos ~modi:[`Line(-1)]) in + let index = + Text.search current_tw ~switches:[`Backwards] ~pattern:"(*" + ~start:(index,[]) ~stop:(tpos pos ~modi:[`Line(-20)]) in + let s = Text.get current_tw ~start:(index,[`Line(-1);`Linestart]) + ~stop:(index,[`Line(-1);`Lineend]) in + for i = 0 to String.length s - 1 do + match s.[i] with '\t'|' ' -> () | _ -> raise Not_found + done; + Text.yview_index current_tw ~index:(index,[`Line(-1)]) + with _ -> + Text.yview_index current_tw ~index:(tpos pos ~modi:[`Line(-2)]) initializer (* Create a first window *) -- cgit v1.2.3-70-g09d2