]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaGui.ml
Bug solved: X-style paste (i.e. paste of the PRIMARY selection using the
[helm.git] / helm / matita / matitaGui.ml
index 733d0aab9699e37a5fd59fb9168a96dc674a10af..6cc4731ad6e7503df7cfaa5521f8019d4729672f 100644 (file)
@@ -728,7 +728,30 @@ class gui () =
       self#main#hpaneScriptSequent#set_position script_w;
         (* source_view *)
       ignore(source_view#connect#after#paste_clipboard 
-        ~callback:(fun () -> (MatitaScript.instance ())#clean_dirty_lock))
+        ~callback:(fun () -> (MatitaScript.instance ())#clean_dirty_lock));
+      (* clean_locked is set to true only "during" a PRIMARY paste
+         operation (i.e. by clicking with the second mouse button) *)
+      let clean_locked = ref false in
+      ignore(source_view#event#connect#button_press
+        ~callback:
+          (fun button ->
+            if GdkEvent.Button.button button = 2 then
+             clean_locked := true;
+            false
+          ));
+      ignore(source_view#event#connect#button_release
+        ~callback:(fun button -> clean_locked := false; false));
+      ignore(source_view#buffer#connect#after#apply_tag
+       ~callback:(
+         fun tag ~start:_ ~stop:_ ->
+          if !clean_locked &&
+             tag#get_oid = (MatitaScript.instance ())#locked_tag#get_oid
+          then
+           begin
+            clean_locked := false;
+            (MatitaScript.instance ())#clean_dirty_lock;
+            clean_locked := true
+           end))
     
     method loadScript file =       
       let script = MatitaScript.instance () in