]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaGui.ml
bumped changelog line to match upload date
[helm.git] / helm / matita / matitaGui.ml
index 6b70a498f05e43bd9b93d6f09b13cd7661683e08..9226ea7b680e78c05eacb771fa179b038a34f52e 100644 (file)
@@ -64,9 +64,17 @@ class gui file =
     MatitaConsole.console ~evbox:main#consoleEventBox ~phrase_sep:";;"
       ~packing:main#scrolledConsole#add ()
   in
+  let script_buf = script#scriptTextView#buffer in
   object (self)
     val mutable chosen_file = None
 
+      (** text mark and tag representing locked part of a script *)
+    val locked_mark =
+      script_buf#create_mark ~name:"locked" ~left_gravity:true
+        script_buf#start_iter
+    val locked_tag =
+      script_buf#create_tag [`BACKGROUND "green"; `EDITABLE false]
+
     initializer
         (* glade's check widgets *)
       List.iter (fun w -> w#check_widgets ())
@@ -109,6 +117,7 @@ class gui file =
         | `CANCEL -> return None
         | `HELP -> ()
         | `DELETE_EVENT -> return None));
+        (* script *)
         (* menus *)
       List.iter (fun w -> w#misc#set_sensitive false)
         [ main#saveMenuItem; main#saveAsMenuItem ];
@@ -164,6 +173,34 @@ class gui file =
       GtkThread.main ();
       chosen_file
 
+    method askText ?(title = "") ?(msg = "") () =
+      let dialog = new textDialog () in
+      dialog#textDialog#set_title title;
+      dialog#textDialogLabel#set_label msg;
+      let text = ref None in
+      let return v =
+        text := v;
+        dialog#textDialog#destroy ();
+        GMain.Main.quit ()
+      in
+      ignore (dialog#textDialog#event#connect#delete (fun _ -> true));
+      ignore (dialog#textDialogCancelButton#connect#clicked (fun _ ->
+        return None));
+      ignore (dialog#textDialogOkButton#connect#clicked (fun _ ->
+        let text = dialog#textDialogTextView#buffer#get_text () in
+        return (Some text)));
+      dialog#textDialog#show ();
+      GtkThread.main ();
+      !text
+
+    method lockScript offset =
+      let mark = `MARK locked_mark in
+      script_buf#move_mark mark ~where:(script_buf#get_iter_at_char offset);
+      script_buf#remove_tag locked_tag ~start:script_buf#start_iter
+        ~stop:script_buf#end_iter;
+      script_buf#apply_tag locked_tag ~start:script_buf#start_iter
+        ~stop:(script_buf#get_iter_at_mark mark)
+
   end
 
 let instance =