diff options
author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2001-11-22 07:36:15 +0000 |
---|---|---|
committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2001-11-22 07:36:15 +0000 |
commit | a8eb19032d5bf75a5ac5fb18a3d0d4b070e0702c (patch) | |
tree | f6aa7769b9b3b0caf8afe4d14928dffbc8dc9bca /otherlibs/labltk/browser/editor.ml | |
parent | 86827528b31e9af179ee340fa8f4469dcc240ef9 (diff) |
accepte commentaires avant ou apres
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4031 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/labltk/browser/editor.ml')
-rw-r--r-- | otherlibs/labltk/browser/editor.ml | 19 |
1 files changed, 16 insertions, 3 deletions
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 *) |