- let href_callback uri =
- let term = CicAst.Uri (UriManager.string_of_uri uri, None) in
- ignore (interpreter#evalAst (TacticAst.Command (TacticAst.Check term)))
- in
- sequent_viewer#set_href_callback (Some href_callback)
-
-(** {2 Script window handling} *)
-
-let script_forward _ =
- let buf = gui#script#scriptTextView#buffer in
- let locked_iter = buf#get_iter_at_mark (`NAME "locked") in
- let (success, hide) =
- interpreter#evalPhrase
- (buf#get_text ~start:locked_iter ~stop:buf#end_iter ())
- in
- if success then
- gui#lockScript (locked_iter#offset + interpreter#endOffset)
-
-let script_jump _ =
- let buf = gui#script#scriptTextView#buffer in
- let locked_iter = buf#get_iter_at_mark (`NAME "locked") in
- let cursor_iter = buf#get_iter_at_mark (`NAME "insert") in
- let raw_text = buf#get_text ~start:locked_iter ~stop:cursor_iter () in
- let len = String.length raw_text in
- let rec parse offset =
- if offset < len then begin
- let (success, hide) =
- interpreter#evalPhrase (String.sub raw_text offset (len - offset))
- in
- if success then begin
- let new_offset = interpreter#endOffset + offset in
- gui#lockScript (new_offset + locked_iter#offset);
- parse new_offset
- end else
- raise Exit
- end
- in
- try
- parse 0
- with Exit -> ()
-
-let script_back _ = not_implemented "script_back"
-
-let load_script fname =
- gui#script#scriptTextView#buffer#set_text (input_file fname);
- gui#script#scriptWin#show ();
- gui#main#showScriptMenuItem#set_active true
-
-(** {2 GUI callbacks} *)
-
-let _ =
- gui#setQuitCallback currentProof#quit;
- gui#setPhraseCallback interpreter#evalPhrase;
- 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 -> load_script 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 _ ->
- let currentProof = (currentProof :> MatitaTypes.currentProof) in
- ignore (MatitaMathView.cicBrowser ~disambiguator ~currentProof ())));
- connect_button gui#script#scriptWinForwardButton script_forward;
- connect_button gui#script#scriptWinBackButton script_back;
- connect_button gui#script#scriptWinJumpButton script_jump;
- let module A = TacticAst in
- let hole = CicAst.UserInput in
- let tac ast _ = ignore (interpreter#evalAst (A.Tactic 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 *)