From: Claudio Sacerdoti Coen Date: Fri, 30 Dec 2022 21:23:44 +0000 (+0100) Subject: Ctr-C now is equivalent to pressing the Break button X-Git-Tag: make_still_working~12 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=9d3f004fe43b3c0df85f1ca27662538e4686c0f4;p=helm.git Ctr-C now is equivalent to pressing the Break button --- diff --git a/matita/matita/matita.ml b/matita/matita/matita.ml index 2731a5ac7..189259621 100644 --- a/matita/matita/matita.ml +++ b/matita/matita/matita.ml @@ -106,9 +106,9 @@ let init_debugging_menu gui = let _ = at_exit (fun () -> print_endline "\nThanks for using Matita!\n"); - Sys.catch_break true; let args = Helm_registry.get_list Helm_registry.string "matita.args" in let gui = MatitaGui.instance () in + Sys.set_signal Sys.sigint (Sys.Signal_handle(fun _ -> gui#kill_worker ())); init_debugging_menu gui; List.iter gui#loadScript (List.rev args); gui#main#mainWin#show (); diff --git a/matita/matita/matitaGui.ml b/matita/matita/matitaGui.ml index 2a1381e3d..af5ea5805 100644 --- a/matita/matita/matitaGui.ml +++ b/matita/matita/matitaGui.ml @@ -400,6 +400,8 @@ let interactive_error_interp ~all_passes dialog#toplevel#destroy () ) () +let ref_kill_worker = ref (fun _ -> assert false) + class gui () = (* creation order _is_ relevant for windows placement *) let main = new mainWin () in @@ -552,13 +554,15 @@ class gui () = let source_view = (s ())#source_view in main#buttonsToolbar#misc#set_sensitive false; main#scriptMenu#misc#set_sensitive false; - source_view#set_editable false + source_view#set_editable false; + main#scriptAbortButton#set_sensitive true in let unlock_world _ = let source_view = (s ())#source_view in main#buttonsToolbar#misc#set_sensitive true; main#scriptMenu#misc#set_sensitive true; - source_view#set_editable true + source_view#set_editable true; + main#scriptAbortButton#set_sensitive false in let worker_thread = ref None in let notify_exn (source_view : GSourceView3.source_view) exn = @@ -648,6 +652,7 @@ class gui () = match !worker_thread with None -> assert false | Some t -> interrupt := Some (Thread.id t) in + ref_kill_worker := kill_worker ; let keep_focus f (script: MatitaScript.script) = try f script; script#source_view#misc#grab_focus () @@ -782,6 +787,7 @@ class gui () = connect_button main#scriptBottomButton bottom; connect_button main#scriptJumpButton jump; connect_button main#scriptAbortButton kill_worker; + main#scriptAbortButton#set_sensitive false; connect_menu_item main#scriptAdvanceMenuItem advance; connect_menu_item main#scriptRetractMenuItem retract; connect_menu_item main#scriptTopMenuItem top; @@ -984,6 +990,8 @@ class gui () = script#addObserver sequents_observer; script#addObserver browser_observer + method kill_worker () = !ref_kill_worker () + method loadScript file = let page = main#scriptNotebook#current_page in let script = MatitaScript.at_page page in diff --git a/matita/matita/matitaGuiTypes.mli b/matita/matita/matitaGuiTypes.mli index f75769fb0..ce5c3c3d9 100644 --- a/matita/matita/matitaGuiTypes.mli +++ b/matita/matita/matitaGuiTypes.mli @@ -30,6 +30,8 @@ object (** {2 Utility methods} *) method loadScript: string -> unit + + method kill_worker: unit -> unit end type paste_kind = [ `Term | `Pattern ]