- let href_callback uri =
- let term = CicAst.Uri (uri, None) in
- ignore (interpreter#evalAst (TacticAst.Command (TacticAst.Check term)))
- in
- sequent_viewer#set_href_callback (Some href_callback)
-
-let console_callback s =
- let module A = TacticAst in
- let rec strip_locations = function
- | A.LocatedTactical (loc, tac) -> strip_locations tac
- | tac -> tac
- in
- let needed_by_script ast =
- prerr_endline (TacticAstPp.pp_tactical ast);
- match strip_locations ast with
- | A.Tactic _
- | A.Command
- (A.Inductive _ | A.Theorem _ | A.Coercion _ | A.Qed _ | A.Proof) ->
- true
- | _ -> false
- in
- let ast = disambiguator#parserr#parseTactical (Stream.of_string s) in
- if needed_by_script ast then
- script#advance ast
- else
- interpreter#evalAst ast
-
-let console_callback s =
- match gui#console#wrap_exn (fun () -> console_callback s) with
- | None -> (false, false)
- | Some outcome -> outcome
-
-(** {2 GUI callbacks} *)
-
-let _ =
- gui#setQuitCallback currentProof#quit;
- gui#setPhraseCallback console_callback;
- gui#main#debugMenu#misc#hide ();
- ignore (gui#main#newProofMenuItem#connect#activate (fun _ ->
- gui#console#clear ();
- gui#console#show ~msg:"theorem " ()));
- ignore (gui#main#openMenuItem#connect#activate (fun _ ->
- match gui#chooseFile () with
- | None -> ()
- | Some f when is_proof_script f ->
- ignore (gui#console#wrap_exn (fun () -> script#loadFrom f))
- | Some f ->
- gui#console#echo_error (sprintf
- "Don't know what to do with file: %s\nUnrecognized file format."
- f)));
- ignore (gui#main#newCicBrowserMenuItem#connect#activate (fun _ ->
- ignore (MatitaMathView.cicBrowser ())));
- let module A = TacticAst in
- let hole = CicAst.UserInput in
- let tac ast _ =
- let ast = A.Tactic ast in
- ignore (interpreter#evalAst ast);
- ignore (script#advance ast)
- in
- let tac_w_term ast _ =
-(* gui#console#clear (); *)
- gui#console#show ~msg:(TacticAstPp.pp_tactic ast) ();
- gui#main#mainWin#present ()
+ let cic_math_view = MatitaMathView.cicMathView_instance () in
+ let sequents_viewer = MatitaMathView.sequentsViewer_instance () in
+ sequents_viewer#load_logo;
+ cic_math_view#set_href_callback
+ (Some (fun uri -> (MatitaMathView.cicBrowser ())#load
+ (`Uri (UriManager.uri_of_string uri))));
+ let browser_observer _ = MatitaMathView.refresh_all_browsers () in
+ let sequents_observer status =
+ sequents_viewer#reset;
+ match status.proof_status with
+ | Incomplete_proof ({ stack = stack } as incomplete_proof) ->
+ sequents_viewer#load_sequents incomplete_proof;
+ (try
+ script#setGoal (Continuationals.Stack.find_goal stack);
+ sequents_viewer#goto_sequent script#goal
+ with Failure _ -> script#setGoal ~-1);
+ | Proof proof -> sequents_viewer#load_logo_with_qed
+ | No_proof -> sequents_viewer#load_logo
+ | Intermediate _ -> assert false (* only the engine may be in this state *)