From 9d3f004fe43b3c0df85f1ca27662538e4686c0f4 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Fri, 30 Dec 2022 22:23:44 +0100 Subject: [PATCH] Ctr-C now is equivalent to pressing the Break button --- matita/matita/matita.ml | 2 +- matita/matita/matitaGui.ml | 12 ++++++++++-- matita/matita/matitaGuiTypes.mli | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) 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 ] -- 2.39.2