summaryrefslogtreecommitdiffstats
path: root/otherlibs/labltk/browser/viewer.ml
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/labltk/browser/viewer.ml')
-rw-r--r--otherlibs/labltk/browser/viewer.ml230
1 files changed, 115 insertions, 115 deletions
diff --git a/otherlibs/labltk/browser/viewer.ml b/otherlibs/labltk/browser/viewer.ml
index 1711ee112..7ec4aad9e 100644
--- a/otherlibs/labltk/browser/viewer.ml
+++ b/otherlibs/labltk/browser/viewer.ml
@@ -23,28 +23,28 @@ open Env
open Searchpos
open Searchid
-let list_modules :path =
- List.fold_left path init:[] f:
+let list_modules ~path =
+ List.fold_left path ~init:[] ~f:
begin fun modules dir ->
let l =
List.filter (Useunix.get_files_in_directory dir)
- f:(fun x -> Filename.check_suffix x ".cmi") in
- let l = List.map l f:
+ ~f:(fun x -> Filename.check_suffix x ".cmi") in
+ let l = List.map l ~f:
begin fun x ->
String.capitalize (Filename.chop_suffix x ".cmi")
end in
- List.fold_left l init:modules
- f:(fun modules item ->
+ List.fold_left l ~init:modules
+ ~f:(fun modules item ->
if List.mem item modules then modules else item :: modules)
end
let reset_modules box =
- Listbox.delete box first:(`Num 0) last:`End;
- module_list := Sort.list order:(<) (list_modules path:!Config.load_path);
- Listbox.insert box index:`End texts:!module_list;
- Jg_box.recenter box index:(`Num 0)
+ Listbox.delete box ~first:(`Num 0) ~last:`End;
+ module_list := Sort.list ~order:(<) (list_modules ~path:!Config.load_path);
+ Listbox.insert box ~index:`End ~texts:!module_list;
+ Jg_box.recenter box ~index:(`Num 0)
-let view_symbol :kind :env ?:path id =
+let view_symbol ~kind ~env ?path id =
let name = match id with
Lident x -> x
| Ldot (_, x) -> x
@@ -53,11 +53,11 @@ let view_symbol :kind :env ?:path id =
match kind with
Pvalue ->
let path, vd = lookup_value id env in
- view_signature_item :path :env [Tsig_value (Ident.create name, vd)]
- | Ptype -> view_type_id id :env
+ view_signature_item ~path ~env [Tsig_value (Ident.create name, vd)]
+ | Ptype -> view_type_id id ~env
| Plabel -> let ld = lookup_label id env in
begin match ld.lbl_res.desc with
- Tconstr (path, _, _) -> view_type_decl path :env
+ Tconstr (path, _, _) -> view_type_decl path ~env
| _ -> ()
end
| Pconstructor ->
@@ -65,18 +65,18 @@ let view_symbol :kind :env ?:path id =
begin match cd.cstr_res.desc with
Tconstr (cpath, _, _) ->
if Path.same cpath Predef.path_exn then
- view_signature title:(string_of_longident id) :env ?:path
+ view_signature ~title:(string_of_longident id) ~env ?path
[Tsig_exception (Ident.create name, cd.cstr_args)]
else
- view_type_decl cpath :env
+ view_type_decl cpath ~env
| _ -> ()
end
- | Pmodule -> view_module_id id :env
- | Pmodtype -> view_modtype_id id :env
- | Pclass -> view_class_id id :env
- | Pcltype -> view_cltype_id id :env
+ | Pmodule -> view_module_id id ~env
+ | Pmodtype -> view_modtype_id id ~env
+ | Pclass -> view_class_id id ~env
+ | Pcltype -> view_cltype_id id ~env
-let choose_symbol :title :env ?:signature ?:path l =
+let choose_symbol ~title ~env ?signature ?path l =
if match path with
None -> false
| Some path -> is_shown_module path
@@ -85,27 +85,27 @@ let choose_symbol :title :env ?:signature ?:path l =
Jg_bind.escape_destroy tl;
top_widgets := coe tl :: !top_widgets;
let buttons = Frame.create tl in
- let all = Button.create buttons text:"Show all" padx:20
- and ok = Jg_button.create_destroyer tl parent:buttons
- and detach = Button.create buttons text:"Detach"
- and edit = Button.create buttons text:"Impl"
- and intf = Button.create buttons text:"Intf" in
- let l = Sort.list l order:
+ let all = Button.create buttons ~text:"Show all" ~padx:20
+ and ok = Jg_button.create_destroyer tl ~parent:buttons
+ and detach = Button.create buttons ~text:"Detach"
+ and edit = Button.create buttons ~text:"Impl"
+ and intf = Button.create buttons ~text:"Intf" in
+ let l = Sort.list l ~order:
(fun (li1, _) (li2,_) ->
string_of_longident li1 < string_of_longident li2)
in
- let nl = List.map l f:
+ let nl = List.map l ~f:
begin fun (li, k) ->
string_of_longident li ^ " (" ^ string_of_kind k ^ ")"
end in
let fb = Frame.create tl in
let box =
- new Jg_multibox.c fb cols:3 texts:nl maxheight:3 width:21 in
+ new Jg_multibox.c fb ~cols:3 ~texts:nl ~maxheight:3 ~width:21 in
box#init;
- box#bind_kbd events:[`KeyPressDetail"Escape"]
- action:(fun _ :index -> destroy tl; break ());
+ box#bind_kbd ~events:[`KeyPressDetail"Escape"]
+ ~action:(fun _ ~index -> destroy tl; break ());
if List.length nl > 9 then ignore (Jg_multibox.add_scrollbar box);
- Jg_multibox.add_completion box action:
+ Jg_multibox.add_completion box ~action:
begin fun pos ->
let li, k = List.nth l pos in
let path =
@@ -116,25 +116,25 @@ let choose_symbol :title :env ?:signature ?:path l =
with Not_found -> None
end
| _ -> path
- in view_symbol li kind:k :env ?:path
+ in view_symbol li ~kind:k ~env ?path
end;
- pack [buttons] side:`Bottom fill:`X;
- pack [fb] side:`Top fill:`Both expand:true;
+ pack [buttons] ~side:`Bottom ~fill:`X;
+ pack [fb] ~side:`Top ~fill:`Both ~expand:true;
begin match signature with
- None -> pack [ok] fill:`X expand:true
+ None -> pack [ok] ~fill:`X ~expand:true
| Some signature ->
- Button.configure all command:
+ Button.configure all ~command:
begin fun () ->
- view_signature signature :title :env ?:path
+ view_signature signature ~title ~env ?path
end;
- pack [ok; all] side:`Right fill:`X expand:true
+ pack [ok; all] ~side:`Right ~fill:`X ~expand:true
end;
begin match path with None -> ()
| Some path ->
let frame = Frame.create tl in
- pack [frame] side:`Bottom fill:`X;
+ pack [frame] ~side:`Bottom ~fill:`X;
add_shown_module path
- widgets:{ mw_frame = frame; mw_detach = detach;
+ ~widgets:{ mw_frame = frame; mw_detach = detach;
mw_edit = edit; mw_intf = intf }
end
@@ -142,20 +142,20 @@ let search_which = ref "itself"
let search_symbol () =
if !module_list = [] then
- module_list := Sort.list order:(<) (list_modules path:!Config.load_path);
+ module_list := Sort.list ~order:(<) (list_modules ~path:!Config.load_path);
let tl = Jg_toplevel.titled "Search symbol" in
Jg_bind.escape_destroy tl;
- let ew = Entry.create tl width:30 in
+ let ew = Entry.create tl ~width:30 in
let choice = Frame.create tl
- and which = Textvariable.create on:tl () in
- let itself = Radiobutton.create choice text:"Itself"
- variable:which value:"itself"
- and extype = Radiobutton.create choice text:"Exact type"
- variable:which value:"exact"
- and iotype = Radiobutton.create choice text:"Included type"
- variable:which value:"iotype"
+ and which = Textvariable.create ~on:tl () in
+ let itself = Radiobutton.create choice ~text:"Itself"
+ ~variable:which ~value:"itself"
+ and extype = Radiobutton.create choice ~text:"Exact type"
+ ~variable:which ~value:"exact"
+ and iotype = Radiobutton.create choice ~text:"Included type"
+ ~variable:which ~value:"iotype"
and buttons = Frame.create tl in
- let search = Button.create buttons text:"Search" command:
+ let search = Button.create buttons ~text:"Search" ~command:
begin fun () ->
search_which := Textvariable.get which;
let text = Entry.get ew in
@@ -163,28 +163,28 @@ let search_symbol () =
let l =
match !search_which with
"itself" -> search_string_symbol text
- | "iotype" -> search_string_type text mode:`included
- | "exact" -> search_string_type text mode:`exact
+ | "iotype" -> search_string_type text ~mode:`included
+ | "exact" -> search_string_type text ~mode:`exact
| _ -> assert false
in
if l <> [] then
- choose_symbol title:"Choose symbol" env:!start_env l
+ choose_symbol ~title:"Choose symbol" ~env:!start_env l
with Searchid.Error (s,e) ->
Entry.selection_clear ew;
- Entry.selection_range ew start:(`Num s) end:(`Num e);
- Entry.xview_index ew index:(`Num s)
+ Entry.selection_range ew ~start:(`Num s) ~stop:(`Num e);
+ Entry.xview_index ew ~index:(`Num s)
end
- and ok = Jg_button.create_destroyer tl parent:buttons text:"Cancel" in
+ and ok = Jg_button.create_destroyer tl ~parent:buttons ~text:"Cancel" in
Focus.set ew;
- Jg_bind.return_invoke ew button:search;
+ Jg_bind.return_invoke ew ~button:search;
Textvariable.set which !search_which;
- pack [itself; extype; iotype] side:`Left anchor:`W;
- pack [search; ok] side:`Left fill:`X expand:true;
+ pack [itself; extype; iotype] ~side:`Left ~anchor:`W;
+ pack [search; ok] ~side:`Left ~fill:`X ~expand:true;
pack [coe ew; coe choice; coe buttons]
- side:`Top fill:`X expand:true
+ ~side:`Top ~fill:`X ~expand:true
-let view_defined modlid :env =
+let view_defined modlid ~env =
try match lookup_module modlid env with
path, Tmty_signature sign ->
let ident_of_decl = function
@@ -207,18 +207,18 @@ let view_defined modlid :env =
in iter_sign rem (ident_of_decl decl :: idents)
in
let l = iter_sign sign [] in
- choose_symbol l title:(string_of_path path) signature:sign
- env:(open_signature path sign env) :path
+ choose_symbol l ~title:(string_of_path path) ~signature:sign
+ ~env:(open_signature path sign env) ~path
| _ -> ()
with Not_found -> ()
| Env.Error err ->
- let tl, tw, finish = Jg_message.formatted title:"Error!" () in
+ let tl, tw, finish = Jg_message.formatted ~title:"Error!" () in
Env.report_error Format.std_formatter err;
finish ()
let close_all_views () =
List.iter !top_widgets
- f:(fun tl -> try destroy tl with Protocol.TkError _ -> ());
+ ~f:(fun tl -> try destroy tl with Protocol.TkError _ -> ());
top_widgets := []
@@ -227,64 +227,64 @@ let default_shell = ref "ocaml"
let start_shell () =
let tl = Jg_toplevel.titled "Start New Shell" in
- Wm.transient_set tl master:Widget.default_toplevel;
+ Wm.transient_set tl ~master:Widget.default_toplevel;
let input = Frame.create tl
and buttons = Frame.create tl in
- let ok = Button.create buttons text:"Ok"
- and cancel = Jg_button.create_destroyer tl parent:buttons text:"Cancel"
+ let ok = Button.create buttons ~text:"Ok"
+ and cancel = Jg_button.create_destroyer tl ~parent:buttons ~text:"Cancel"
and labels = Frame.create input
and entries = Frame.create input in
- let l1 = Label.create labels text:"Command:"
- and l2 = Label.create labels text:"Title:"
+ let l1 = Label.create labels ~text:"Command:"
+ and l2 = Label.create labels ~text:"Title:"
and e1 =
- Jg_entry.create entries command:(fun _ -> Button.invoke ok)
+ Jg_entry.create entries ~command:(fun _ -> Button.invoke ok)
and e2 =
- Jg_entry.create entries command:(fun _ -> Button.invoke ok)
- and names = List.map f:fst (Shell.get_all ()) in
- Entry.insert e1 index:`End text:!default_shell;
+ Jg_entry.create entries ~command:(fun _ -> Button.invoke ok)
+ and names = List.map ~f:fst (Shell.get_all ()) in
+ Entry.insert e1 ~index:`End ~text:!default_shell;
let shell_name () = "Shell #" ^ string_of_int !shell_counter in
while List.mem (shell_name ()) names do
incr shell_counter
done;
- Entry.insert e2 index:`End text:(shell_name ());
- Button.configure ok command:(fun () ->
+ Entry.insert e2 ~index:`End ~text:(shell_name ());
+ Button.configure ok ~command:(fun () ->
if not (List.mem (Entry.get e2) names) then begin
default_shell := Entry.get e1;
- Shell.f prog:!default_shell title:(Entry.get e2);
+ Shell.f ~prog:!default_shell ~title:(Entry.get e2);
destroy tl
end);
- pack [l1;l2] side:`Top anchor:`W;
- pack [e1;e2] side:`Top fill:`X expand:true;
- pack [labels;entries] side:`Left fill:`X expand:true;
- pack [ok;cancel] side:`Left fill:`X expand:true;
- pack [input;buttons] side:`Top fill:`X expand:true
+ pack [l1;l2] ~side:`Top ~anchor:`W;
+ pack [e1;e2] ~side:`Top ~fill:`X ~expand:true;
+ pack [labels;entries] ~side:`Left ~fill:`X ~expand:true;
+ pack [ok;cancel] ~side:`Left ~fill:`X ~expand:true;
+ pack [input;buttons] ~side:`Top ~fill:`X ~expand:true
-let f ?(:dir=Unix.getcwd()) ?:on () =
+let f ?(dir=Unix.getcwd()) ?on () =
let tl = match on with
None ->
let tl = Jg_toplevel.titled "Module viewer" in
ignore (Jg_bind.escape_destroy tl); coe tl
| Some top ->
- Wm.title_set top title:"OCamlBrowser";
- Wm.iconname_set top name:"OCamlBrowser";
+ Wm.title_set top ~title:"OCamlBrowser";
+ Wm.iconname_set top ~name:"OCamlBrowser";
let tl = Frame.create top in
- pack [tl] expand:true fill:`Both;
+ pack [tl] ~expand:true ~fill:`Both;
coe tl
in
- let menus = Frame.create tl name:"menubar" in
- let filemenu = new Jg_menu.c "File" parent:menus
- and modmenu = new Jg_menu.c "Modules" parent:menus in
+ let menus = Frame.create tl ~name:"menubar" in
+ let filemenu = new Jg_menu.c "File" ~parent:menus
+ and modmenu = new Jg_menu.c "Modules" ~parent:menus in
let fmbox, mbox, msb = Jg_box.create_with_scrollbar tl in
- Jg_box.add_completion mbox nocase:true action:
+ Jg_box.add_completion mbox ~nocase:true ~action:
begin fun index ->
- view_defined (Lident (Listbox.get mbox :index)) env:!start_env
+ view_defined (Lident (Listbox.get mbox ~index)) ~env:!start_env
end;
Setpath.add_update_hook (fun () -> reset_modules mbox);
let ew = Entry.create tl in
let buttons = Frame.create tl in
- let search = Button.create buttons text:"Search" pady:1 command:
+ let search = Button.create buttons ~text:"Search" ~pady:1 ~command:
begin fun () ->
let s = Entry.get ew in
let is_type = ref false and is_long = ref false in
@@ -294,45 +294,45 @@ let f ?(:dir=Unix.getcwd()) ?:on () =
done;
let l =
if !is_type then try
- search_string_type mode:`included s
+ search_string_type ~mode:`included s
with Searchid.Error (start,stop) ->
- Entry.icursor ew index:(`Num start); []
+ Entry.icursor ew ~index:(`Num start); []
else if !is_long then
search_string_symbol s
else
search_pattern_symbol s in
match l with [] -> ()
- | [lid,kind] when !is_long -> view_symbol lid :kind env:!start_env
- | _ -> choose_symbol title:"Choose symbol" env:!start_env l
+ | [lid,kind] when !is_long -> view_symbol lid ~kind ~env:!start_env
+ | _ -> choose_symbol ~title:"Choose symbol" ~env:!start_env l
end
and close =
- Button.create buttons text:"Close all" pady:1 command:close_all_views
+ Button.create buttons ~text:"Close all" ~pady:1 ~command:close_all_views
in
(* bindings *)
Jg_bind.enter_focus ew;
- Jg_bind.return_invoke ew button:search;
- bind close events:[`Modified([`Double], `ButtonPressDetail 1)]
- action:(fun _ -> destroy tl);
+ Jg_bind.return_invoke ew ~button:search;
+ bind close ~events:[`Modified([`Double], `ButtonPressDetail 1)]
+ ~action:(fun _ -> destroy tl);
(* File menu *)
filemenu#add_command "Open..."
- command:(fun () -> !editor_ref opendialog:true ());
- filemenu#add_command "Editor..." command:(fun () -> !editor_ref ());
- filemenu#add_command "Shell..." command:start_shell;
- filemenu#add_command "Quit" command:(fun () -> destroy tl);
+ ~command:(fun () -> !editor_ref ~opendialog:true ());
+ filemenu#add_command "Editor..." ~command:(fun () -> !editor_ref ());
+ filemenu#add_command "Shell..." ~command:start_shell;
+ filemenu#add_command "Quit" ~command:(fun () -> destroy tl);
(* modules menu *)
modmenu#add_command "Path editor..."
- command:(fun () -> Setpath.set :dir);
+ ~command:(fun () -> Setpath.set ~dir);
modmenu#add_command "Reset cache"
- command:(fun () -> reset_modules mbox; Env.reset_cache ());
- modmenu#add_command "Search symbol..." command:search_symbol;
+ ~command:(fun () -> reset_modules mbox; Env.reset_cache ());
+ modmenu#add_command "Search symbol..." ~command:search_symbol;
- pack [filemenu#button; modmenu#button] side:`Left ipadx:5 anchor:`W;
- pack [menus] side:`Top fill:`X;
- pack [close; search] fill:`X side:`Right expand:true;
- pack [coe buttons; coe ew] fill:`X side:`Bottom;
- pack [msb] side:`Right fill:`Y;
- pack [mbox] side:`Left fill:`Both expand:true;
- pack [fmbox] fill:`Both expand:true side:`Top;
+ pack [filemenu#button; modmenu#button] ~side:`Left ~ipadx:5 ~anchor:`W;
+ pack [menus] ~side:`Top ~fill:`X;
+ pack [close; search] ~fill:`X ~side:`Right ~expand:true;
+ pack [coe buttons; coe ew] ~fill:`X ~side:`Bottom;
+ pack [msb] ~side:`Right ~fill:`Y;
+ pack [mbox] ~side:`Left ~fill:`Both ~expand:true;
+ pack [fmbox] ~fill:`Both ~expand:true ~side:`Top;
reset_modules mbox