open MatitaGtkMisc
open MatitaMisc
+let gui_instance = ref None ;;
+
+class console ~evbox ~phrase_sep ~packing ~paned () =
+ let console = MatitaConsole.console ~evbox ~phrase_sep ~packing ~paned () in
+ object
+ method clear = console#clear
+ method echo_error = console#echo_error
+ method echo_message = console#echo_message
+ method wrap_exn: 'a. (unit -> 'a) -> 'a option = console#wrap_exn
+ method choose_uri uris =
+ let g = match !gui_instance with None -> assert false | Some g -> g in
+ let ul = g#newUriDialog () in
+ ul#toplevel#show ();
+ let model = new stringListModel ul#uriChoiceTreeView in
+ List.iter model#easy_append uris;
+ ul#uriChoiceDialog#set_title "Hints";
+ ul#uriChoiceLabel#set_text "Suggested uris";
+ ul#uriChoiceAbortButton#misc#hide ();
+ ul#uriChoiceAutoButton#misc#hide ();
+ ul#uriChoiceConstantsButton#misc#hide ();
+ ul#hbox2#misc#hide ();
+ ul#uriChoiceTreeView#selection#set_mode
+ (`SINGLE :> Gtk.Tags.selection_mode);
+ let _ = ul#uriChoiceTreeView#selection#connect#changed
+ ~callback:(fun () -> ()) in
+ let _ = ul#toplevel#connect#destroy
+ ~callback:(fun () -> GMain.Main.quit ()) in
+ let choices = ref None in
+ let _ = ul#uriChoiceSelectedButton#connect#clicked
+ ~callback:(fun () ->
+ (match model#easy_selection () with
+ | [] -> ()
+ | [uri] -> choices := (Some uri)
+ | _ -> assert false);
+ ul#uriChoiceDialog#destroy ();
+ GMain.Main.quit ()) in
+ GMain.main ();
+ match !choices with
+ | Some u -> u
+ | None -> raise MatitaTypes.Cancel
+
+ method show = console#show
+
+ method console = console
+ end
+
class gui file =
(* creation order _is_ relevant for windows placement *)
let toolbar = new toolBarWin ~file () in
script#scriptWinEventBox; main#consoleEventBox ]
in
let console =
- MatitaConsole.console ~evbox:main#consoleEventBox
+ new console ~evbox:main#consoleEventBox
~phrase_sep:BuildTimeConf.phrase_sep
~packing:main#scrolledConsole#add ~paned:main#mainVPanes ()
in
*)
[ GdkKeysyms._F5,
toggle_win ~check:main#showScriptMenuItem script#scriptWin;
- GdkKeysyms._x, (fun () -> console#toggle ());
+ GdkKeysyms._x, (fun () -> console#console#toggle ());
];
- add_key_binding GdkKeysyms._Escape console#hide main#consoleEventBox;
+ add_key_binding GdkKeysyms._Escape console#console#hide
+ main#consoleEventBox;
(* about win *)
ignore (about#aboutWin#event#connect#delete (fun _ -> true));
ignore (main#aboutMenuItem#connect#activate (fun _ ->
List.iter (fun w -> w#misc#set_sensitive false)
[ main#saveMenuItem; main#saveAsMenuItem ];
main#helpMenu#set_right_justified true;
- ignore (main#showConsoleMenuItem#connect#activate console#toggle);
+ ignore (main#showConsoleMenuItem#connect#activate console#console#toggle);
(* main *)
- connect_button main#hideConsoleButton console#hide;
+ connect_button main#hideConsoleButton console#console#hide;
(* console *)
console#echo_message (sprintf "\tMatita version %s\n"
BuildTimeConf.version);
- console#echo_prompt ();
- console#misc#grab_focus ();
+ console#console#echo_prompt ();
+ console#console#misc#grab_focus ();
method about = about
- method console = console
+ method console = (console :> MatitaTypes.console)
method fileSel = fileSel
method main = main
method script = script
ignore (main#quitMenuItem#connect#activate callback);
self#addKeyBinding GdkKeysyms._q callback
- method setPhraseCallback = console#set_callback
+ method setPhraseCallback = console#console#set_callback
method chooseFile () =
fileSel#fileSelectionWin#show ();
end
-let gui () = new gui (Helm_registry.get "matita.glade_file")
+let gui () =
+ let g = new gui (Helm_registry.get "matita.glade_file") in
+ gui_instance := Some g;
+ g
+
let instance = singleton gui
Tactics.replace ~what:(self#disambiguate what)
~with_what:(self#disambiguate with_what)
| TacticAst.Auto -> Tactics.auto_new ~dbd
+ | TacticAst.Hint ->
+ let l = List.map fst
+ (MetadataQuery.experimental_hint ~dbd
+ (currentProof#proof#proof,currentProof#proof#goal))
+ in
+ let u = console#choose_uri l in
+ Tactics.apply (CicUtil.term_of_uri u)
| TacticAst.Change (what, with_what, _) ->
let what = self#disambiguate what in
let with_what = self#disambiguate with_what in
| `Proof -> (state <- proofState)
| `Command -> (state <- commandState)
+ method endOffset = state#endOffset
+
method private updateState = function
| New_state Command -> (state <- commandState)
| New_state Proof -> (state <- proofState)