X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=inline;f=helm%2Fsoftware%2Fmatita%2FmatitaGui.ml;h=d04fbcadab4b8bcace82958733d197b007742cc4;hb=f5ca06e7437c022413b14bd8f63fa3466a1ead0c;hp=3ba6499a93acab767646871f0559dcd6ff848576;hpb=5c1b44dfefa085fbb56e23047652d3650be9d855;p=helm.git
diff --git a/helm/software/matita/matitaGui.ml b/helm/software/matita/matitaGui.ml
index 3ba6499a9..d04fbcada 100644
--- a/helm/software/matita/matitaGui.ml
+++ b/helm/software/matita/matitaGui.ml
@@ -42,7 +42,7 @@ class type browserWin =
* lablgladecc :-(((( *)
object
inherit MatitaGeneratedGui.browserWin
- method browserUri: GEdit.combo_box_entry
+ method browserUri: GEdit.entry
end
class console ~(buffer: GText.buffer) () =
@@ -67,13 +67,13 @@ class console ~(buffer: GText.buffer) () =
end
let clean_current_baseuri grafite_status =
- LibraryClean.clean_baseuris [GrafiteTypes.get_baseuri grafite_status]
+ LibraryClean.clean_baseuris [grafite_status#baseuri]
-let save_moo lexicon_status grafite_status =
+let save_moo grafite_status =
let script = MatitaScript.current () in
- let baseuri = GrafiteTypes.get_baseuri grafite_status in
+ let baseuri = grafite_status#baseuri in
let no_pstatus =
- grafite_status.GrafiteTypes.proof_status = GrafiteTypes.No_proof
+ grafite_status#proof_status = GrafiteTypes.No_proof
in
match script#bos, script#eos, no_pstatus with
| true, _, _ -> ()
@@ -85,10 +85,11 @@ let save_moo lexicon_status grafite_status =
LibraryMisc.lexicon_file_of_baseuri
~must_exist:false ~baseuri ~writable:true
in
- GrafiteMarshal.save_moo moo_fname
- grafite_status.GrafiteTypes.moo_content_rev;
+ GrafiteMarshal.save_moo moo_fname grafite_status#moo_content_rev;
LexiconMarshal.save_lexicon lexicon_fname
- lexicon_status.LexiconEngine.lexicon_content_rev
+ grafite_status#lstatus.LexiconEngine.lexicon_content_rev;
+ NCicLibrary.Serializer.serialize ~baseuri:(NUri.uri_of_string baseuri)
+ grafite_status#dump
| _ -> clean_current_baseuri grafite_status
;;
@@ -201,9 +202,10 @@ class interpErrorModel =
tree_store#get ~row:iter ~column:interp_no_col
end
+exception UseLibrary;;
let rec interactive_error_interp ~all_passes
- (source_buffer:GSourceView.source_buffer) notify_exn offset errorll filename
+ (source_buffer:GSourceView2.source_buffer) notify_exn offset errorll filename
=
(* hook to save a script for each disambiguation error *)
if false then
@@ -220,7 +222,7 @@ let rec interactive_error_interp ~all_passes
assert (List.flatten errorll <> []);
let errorll' =
let remove_non_significant =
- List.filter (fun (_env,_diff,_loc,_msg,significant) -> significant) in
+ List.filter (fun (_env,_diff,_loc_msg,significant) -> significant) in
let annotated_errorll () =
List.rev
(snd
@@ -263,8 +265,8 @@ let rec interactive_error_interp ~all_passes
| [loffset,[_,envs_and_diffs,msg,significant]] ->
let _,env,diff = List.hd envs_and_diffs in
notify_exn
- (GrafiteDisambiguator.DisambiguationError
- (offset,[[env,diff,loffset,msg,significant]]));
+ (MultiPassDisambiguator.DisambiguationError
+ (offset,[[env,diff,lazy (loffset,Lazy.force msg),significant]]));
| _::_ ->
let dialog = new disambiguationErrors () in
dialog#check_widgets ();
@@ -298,8 +300,8 @@ let rec interactive_error_interp ~all_passes
~start:source_buffer#start_iter
~stop:source_buffer#end_iter;
notify_exn
- (GrafiteDisambiguator.DisambiguationError
- (offset,[[env,diff,loffset,msg,significant]]))
+ (MultiPassDisambiguator.DisambiguationError
+ (offset,[[env,diff,lazy(loffset,Lazy.force msg),significant]]))
));
let return _ =
dialog#disambiguationErrors#destroy ();
@@ -327,10 +329,17 @@ let rec interactive_error_interp ~all_passes
String.concat "\n"
("" ::
List.map
- (fun k,value ->
- DisambiguatePp.pp_environment
- (DisambiguateTypes.Environment.add k value
- DisambiguateTypes.Environment.empty))
+ (fun k,desc ->
+ let alias =
+ match k with
+ | DisambiguateTypes.Id id ->
+ LexiconAst.Ident_alias (id, desc)
+ | DisambiguateTypes.Symbol (symb, i)->
+ LexiconAst.Symbol_alias (symb, i, desc)
+ | DisambiguateTypes.Num i ->
+ LexiconAst.Number_alias (i, desc)
+ in
+ LexiconAstPp.pp_alias alias)
diff) ^ "\n"
in
source_buffer#insert
@@ -340,9 +349,7 @@ let rec interactive_error_interp ~all_passes
return ()
);
connect_button dialog#disambiguationErrorsMoreErrors
- (fun _ -> return () ;
- interactive_error_interp ~all_passes:true source_buffer
- notify_exn offset errorll filename);
+ (fun _ -> return () ; raise UseLibrary);
connect_button dialog#disambiguationErrorsCancelButton fail;
dialog#disambiguationErrors#show ();
GtkThread.main ()
@@ -367,12 +374,12 @@ class gui () =
[ main#mainWinEventBox ]
in
let console = new console ~buffer:main#logTextView#buffer () in
- let (source_view: GSourceView.source_view) =
- GSourceView.source_view
+ let (source_view: GSourceView2.source_view) =
+ GSourceView2.source_view
~auto_indent:true
- ~insert_spaces_instead_of_tabs:true ~tabs_width:2
- ~margin:80 ~show_margin:true
- ~smart_home_end:true
+ ~insert_spaces_instead_of_tabs:true ~tab_width:2
+ ~right_margin_position:80 ~show_right_margin:true
+ ~smart_home_end:`AFTER
~packing:main#scriptScrolledWin#add
()
in
@@ -380,15 +387,24 @@ class gui () =
Helm_registry.get_opt_default Helm_registry.int
~default:BuildTimeConf.default_font_size "matita.font_size"
in
+ let similarsymbols_tag_name = "similarsymbolos" in
+ let similarsymbols_tag = `NAME similarsymbols_tag_name in
let source_buffer = source_view#source_buffer in
object (self)
val mutable chosen_file = None
val mutable _ok_not_exists = false
val mutable _only_directory = false
val mutable font_size = default_font_size
- val mutable next_ligatures = []
+ val mutable similarsymbols = []
+ val mutable similarsymbols_orig = []
val clipboard = GData.clipboard Gdk.Atom.clipboard
val primary = GData.clipboard Gdk.Atom.primary
+
+ method private reset_similarsymbols =
+ similarsymbols <- [];
+ similarsymbols_orig <- [];
+ try source_buffer#delete_mark similarsymbols_tag
+ with GText.No_such_mark _ -> ()
initializer
let s () = MatitaScript.current () in
@@ -428,14 +444,23 @@ class gui () =
~logo:(GdkPixbuf.from_file (MatitaMisc.image_path "/matita_medium.png"))
~name:"Matita"
~version:BuildTimeConf.version
- ~website:"http://helm.cs.unibo.it"
+ ~website:"http://matita.cs.unibo.it"
()
in
+ ignore(about_dialog#connect#response (fun _ ->about_dialog#misc#hide ()));
connect_menu_item main#contentsMenuItem (fun () ->
- let cmd =
- sprintf "gnome-help ghelp://%s/C/matita.xml &" BuildTimeConf.help_dir
- in
- ignore (Sys.command cmd));
+ if 0 = Sys.command "which gnome-help" then
+ let cmd =
+ sprintf "gnome-help ghelp://%s/C/matita.xml &" BuildTimeConf.help_dir
+ in
+ ignore (Sys.command cmd)
+ else
+ MatitaGtkMisc.report_error ~title:"help system error"
+ ~message:(
+ "The program gnome-help is not installed\n\n"^
+ "To browse the user manal it is necessary to install "^
+ "the gnome help syste (also known as yelp)")
+ ~parent:main#toplevel ());
connect_menu_item main#aboutMenuItem about_dialog#present;
(* findRepl win *)
let show_find_Repl () =
@@ -550,11 +575,15 @@ class gui () =
source_view#misc#grab_focus ()
in
connect_menu_item main#undoMenuItem safe_undo;
+(*CSC: XXX
ignore(source_view#source_buffer#connect#can_undo
~callback:main#undoMenuItem#misc#set_sensitive);
+*) main#undoMenuItem#misc#set_sensitive true;
connect_menu_item main#redoMenuItem safe_redo;
+(*CSC: XXX
ignore(source_view#source_buffer#connect#can_redo
~callback:main#redoMenuItem#misc#set_sensitive);
+*) main#redoMenuItem#misc#set_sensitive true;
ignore(source_view#connect#after#populate_popup
~callback:(fun pre_menu ->
let menu = new GMenu.menu pre_menu in
@@ -625,7 +654,11 @@ class gui () =
source_buffer#move_mark `SEL_BOUND source_buffer#end_iter);
connect_menu_item main#findReplMenuItem show_find_Repl;
connect_menu_item main#externalEditorMenuItem self#externalEditor;
- connect_menu_item main#ligatureButton self#nextLigature;
+ connect_menu_item main#ligatureButton self#nextSimilarSymbol;
+ ignore(source_buffer#connect#after#insert_text
+ ~callback:(fun iter str ->
+ if main#menuitemAutoAltL#active && (str = " " || str = "\n") then
+ ignore(self#expand_virtual_if_any iter str)));
ignore (findRepl#findEntry#connect#activate find_forward);
(* interface lockers *)
let lock_world _ =
@@ -675,20 +708,33 @@ class gui () =
let thread_main =
fun () ->
lock_world ();
+ let saved_use_library= !MultiPassDisambiguator.use_library in
try
+ MultiPassDisambiguator.use_library := !all_disambiguation_passes;
f ();
+ MultiPassDisambiguator.use_library := saved_use_library;
unlock_world ()
with
- | GrafiteDisambiguator.DisambiguationError (offset,errorll) ->
+ | MultiPassDisambiguator.DisambiguationError (offset,errorll) ->
(try
interactive_error_interp
~all_passes:!all_disambiguation_passes source_buffer
notify_exn offset errorll (s())#filename
with
- exc -> notify_exn exc);
+ | UseLibrary ->
+ MultiPassDisambiguator.use_library := true;
+ (try f ()
+ with
+ | MultiPassDisambiguator.DisambiguationError (offset,errorll) ->
+ interactive_error_interp ~all_passes:true source_buffer
+ notify_exn offset errorll (s())#filename
+ | exc ->
+ notify_exn exc);
+ | exc -> notify_exn exc);
+ MultiPassDisambiguator.use_library := saved_use_library;
unlock_world ()
| exc ->
- notify_exn exc;
+ (try notify_exn exc with Sys.Break as e -> notify_exn e);
unlock_world ()
in
(*thread_main ();*)
@@ -753,9 +799,60 @@ class gui () =
ignore (adj#connect#changed
(fun _ -> adj#set_value (adj#upper -. adj#page_size)));
console#message (sprintf "\tMatita version %s\n" BuildTimeConf.version);
- (* TO BE REMOVED *)
+ (* natural deduction palette *)
main#tacticsButtonsHandlebox#misc#hide ();
- main#tacticsBarMenuItem#misc#hide ();
+ MatitaGtkMisc.toggle_callback
+ ~callback:(fun b ->
+ if b then main#tacticsButtonsHandlebox#misc#show ()
+ else main#tacticsButtonsHandlebox#misc#hide ())
+ ~check:main#menuitemPalette;
+ connect_button main#butImpl_intro
+ (fun () -> source_buffer#insert "apply rule (â#i [â¦] (â¦));\n");
+ connect_button main#butAnd_intro
+ (fun () -> source_buffer#insert
+ "apply rule (â§#i (â¦) (â¦));\n\t[\n\t|\n\t]\n");
+ connect_button main#butOr_intro_left
+ (fun () -> source_buffer#insert "apply rule (â¨#i_l (â¦));\n");
+ connect_button main#butOr_intro_right
+ (fun () -> source_buffer#insert "apply rule (â¨#i_r (â¦));\n");
+ connect_button main#butNot_intro
+ (fun () -> source_buffer#insert "apply rule (¬#i [â¦] (â¦));\n");
+ connect_button main#butTop_intro
+ (fun () -> source_buffer#insert "apply rule (â¤#i);\n");
+ connect_button main#butImpl_elim
+ (fun () -> source_buffer#insert
+ "apply rule (â#e (â¦) (â¦));\n\t[\n\t|\n\t]\n");
+ connect_button main#butAnd_elim_left
+ (fun () -> source_buffer#insert "apply rule (â§#e_l (â¦));\n");
+ connect_button main#butAnd_elim_right
+ (fun () -> source_buffer#insert "apply rule (â§#e_r (â¦));\n");
+ connect_button main#butOr_elim
+ (fun () -> source_buffer#insert
+ "apply rule (â¨#e (â¦) [â¦] (â¦) [â¦] (â¦));\n\t[\n\t|\n\t|\n\t]\n");
+ connect_button main#butNot_elim
+ (fun () -> source_buffer#insert
+ "apply rule (¬#e (â¦) (â¦));\n\t[\n\t|\n\t]\n");
+ connect_button main#butBot_elim
+ (fun () -> source_buffer#insert "apply rule (â¥#e (â¦));\n");
+ connect_button main#butRAA
+ (fun () -> source_buffer#insert "apply rule (RAA [â¦] (â¦));\n");
+ connect_button main#butUseLemma
+ (fun () -> source_buffer#insert "apply rule (lem #premises name â¦);\n");
+ connect_button main#butDischarge
+ (fun () -> source_buffer#insert "apply rule (discharge [â¦]);\n");
+
+ connect_button main#butForall_intro
+ (fun () -> source_buffer#insert "apply rule (â#i {â¦} (â¦));\n");
+ connect_button main#butForall_elim
+ (fun () -> source_buffer#insert "apply rule (â#e {â¦} (â¦));\n");
+ connect_button main#butExists_intro
+ (fun () -> source_buffer#insert "apply rule (â#i {â¦} (â¦));\n");
+ connect_button main#butExists_elim
+ (fun () -> source_buffer#insert
+ "apply rule (â#e (â¦) {â¦} [â¦] (â¦));\n\t[\n\t|\n\t]\n");
+
+
+ (* TO BE REMOVED *)
main#scriptNotebook#remove_page 1;
main#scriptNotebook#set_show_tabs false;
(* / TO BE REMOVED *)
@@ -789,15 +886,19 @@ class gui () =
notify_exn exn
else raise exn);
(* script *)
- ignore (source_buffer#connect#mark_set (fun _ _ -> next_ligatures <- []));
let _ =
- match GSourceView.source_language_from_file BuildTimeConf.lang_file with
+ let source_language_manager =
+ GSourceView2.source_language_manager ~default:true in
+ source_language_manager#set_search_path
+ (BuildTimeConf.runtime_base_dir ::
+ source_language_manager#search_path);
+ match source_language_manager#language "grafite" with
| None ->
- HLog.warn (sprintf "can't load language file %s"
- BuildTimeConf.lang_file)
- | Some matita_lang ->
+ HLog.warn(sprintf "can't load a language file for \"grafite\" in %s"
+ BuildTimeConf.runtime_base_dir)
+ | Some x as matita_lang ->
source_buffer#set_language matita_lang;
- source_buffer#set_highlight true
+ source_buffer#set_highlight_syntax true
in
let disableSave () =
(s())#assignFileName None;
@@ -822,14 +923,13 @@ class gui () =
else saveAsScript ()
in
let abandon_script () =
- let lexicon_status = (s ())#lexicon_status in
let grafite_status = (s ())#grafite_status in
if source_view#buffer#modified then
(match ask_unsaved main#toplevel with
| `YES -> saveScript ()
| `NO -> ()
| `CANCEL -> raise MatitaTypes.Cancel);
- save_moo lexicon_status grafite_status
+ save_moo grafite_status
in
let loadScript () =
let script = s () in
@@ -842,6 +942,8 @@ class gui () =
source_view#source_buffer#begin_not_undoable_action ();
script#loadFromFile f;
source_view#source_buffer#end_not_undoable_action ();
+ source_view#buffer#move_mark `INSERT source_view#buffer#start_iter;
+ source_view#buffer#place_cursor source_view#buffer#start_iter;
console#message ("'"^f^"' loaded.\n");
self#_enableSaveTo f
| None -> ()
@@ -876,12 +978,12 @@ class gui () =
match ask_unsaved main#toplevel with
| `YES ->
saveScript ();
- save_moo script#lexicon_status script#grafite_status;
+ save_moo script#grafite_status;
GMain.Main.quit ()
| `NO -> GMain.Main.quit ()
| `CANCEL -> ()
else
- (save_moo script#lexicon_status script#grafite_status;
+ (save_moo script#grafite_status;
GMain.Main.quit ()));
connect_button main#scriptAdvanceButton advance;
connect_button main#scriptRetractButton retract;
@@ -902,8 +1004,20 @@ class gui () =
(fun _ ->
let c = MatitaMathView.cicBrowser () in
c#load (`About `Coercions));
+ connect_menu_item main#showHintsDbMenuItem
+ (fun _ ->
+ let c = MatitaMathView.cicBrowser () in
+ c#load (`About `Hints));
connect_menu_item main#showAutoGuiMenuItem
(fun _ -> MatitaAutoGui.auto_dialog Auto.get_auto_status);
+ connect_menu_item main#showTermGrammarMenuItem
+ (fun _ ->
+ let c = MatitaMathView.cicBrowser () in
+ c#load (`About `Grammar));
+ connect_menu_item main#showUnicodeTable
+ (fun _ ->
+ let c = MatitaMathView.cicBrowser () in
+ c#load (`About `TeX));
(* script monospace font stuff *)
self#updateFontSize ();
(* debug menu *)
@@ -918,8 +1032,11 @@ class gui () =
(* focus *)
self#sourceView#misc#grab_focus ();
(* main win dimension *)
- let width = Gdk.Screen.width () in
- let height = Gdk.Screen.height () in
+ let width = Gdk.Screen.width ~screen:(Gdk.Screen.default ()) () in
+ let height = Gdk.Screen.height ~screen:(Gdk.Screen.default ()) () in
+ (* hack for xinerama, no proper support of monitors from lablgtk *)
+ let width = if width > 1600 then width / 2 else width in
+ let height = if height > 1200 then height / 2 else height in
let main_w = width * 90 / 100 in
let main_h = height * 80 / 100 in
let script_w = main_w * 6 / 10 in
@@ -953,7 +1070,7 @@ class gui () =
end));
(* math view handling *)
connect_menu_item main#newCicBrowserMenuItem (fun () ->
- ignore (MatitaMathView.cicBrowser ()));
+ ignore(MatitaMathView.cicBrowser ()));
connect_menu_item main#increaseFontSizeMenuItem (fun () ->
self#increaseFontSize ();
MatitaMathView.increase_font_size ();
@@ -1004,58 +1121,96 @@ class gui () =
method pastePattern () =
source_view#buffer#insert (MatitaMathView.paste_clipboard `Pattern)
- method private nextLigature () =
- let iter = source_buffer#get_iter_at_mark `INSERT in
- let write_ligature len s =
+ method private expand_virtual_if_any iter tok =
+ try
+ let len = MatitaGtkMisc.utf8_string_length tok in
+ let last_word =
+ let prev = iter#copy#backward_chars len in
+ prev#get_slice ~stop:(prev#copy#backward_find_char
+ (fun x -> Glib.Unichar.isspace x || x = Glib.Utf8.first_char "\\"))
+ in
+ let inplaceof, symb = Virtuals.symbol_of_virtual last_word in
+ self#reset_similarsymbols;
+ let s = Glib.Utf8.from_unichar symb in
+ assert(Glib.Utf8.validate s);
+ source_buffer#delete ~start:iter
+ ~stop:(iter#copy#backward_chars
+ (MatitaGtkMisc.utf8_string_length inplaceof + len));
+ source_buffer#insert ~iter
+ (if inplaceof.[0] = '\\' then s else (s ^ tok));
+ true
+ with Virtuals.Not_a_virtual -> false
+
+ val similar_memory = Hashtbl.create 97
+ val mutable old_used_memory = false
+
+ method private nextSimilarSymbol () =
+ let write_similarsymbol s =
+ let s = Glib.Utf8.from_unichar s in
+ let iter = source_buffer#get_iter_at_mark `INSERT in
assert(Glib.Utf8.validate s);
- source_buffer#delete ~start:iter ~stop:(iter#copy#backward_chars len);
- source_buffer#insert ~iter:(source_buffer#get_iter_at_mark `INSERT) s
+ source_buffer#delete ~start:iter ~stop:(iter#copy#backward_chars 1);
+ source_buffer#insert ~iter:(source_buffer#get_iter_at_mark `INSERT) s;
+ (try source_buffer#delete_mark similarsymbols_tag
+ with GText.No_such_mark _ -> ());
+ ignore(source_buffer#create_mark ~name:similarsymbols_tag_name
+ (source_buffer#get_iter_at_mark `INSERT));
in
- let get_ligature word =
- let len = String.length word in
- let aux_tex () =
- try
- for i = len - 1 downto 0 do
- if HExtlib.is_alpha word.[i] then ()
- else
- (if word.[i] = '\\' then raise (Found i) else raise (Found ~-1))
- done;
- None
- with Found i ->
- if i = ~-1 then None else Some (String.sub word i (len - i))
- in
- let aux_ligature () =
- try
- for i = len - 1 downto 0 do
- if CicNotationLexer.is_ligature_char word.[i] then ()
- else raise (Found (i+1))
- done;
- raise (Found 0)
- with
- | Found i ->
- (try
- Some (String.sub word i (len - i))
- with Invalid_argument _ -> None)
- in
- match aux_tex () with
- | Some macro -> macro
- | None -> (match aux_ligature () with Some l -> l | None -> word)
+ let new_similarsymbol =
+ try
+ let iter_ins = source_buffer#get_iter_at_mark `INSERT in
+ let iter_lig = source_buffer#get_iter_at_mark similarsymbols_tag in
+ not (iter_ins#equal iter_lig)
+ with GText.No_such_mark _ -> true
in
- (match next_ligatures with
- | [] -> (* find ligatures and fill next_ligatures, then try again *)
- let last_word =
- iter#get_slice
- ~stop:(iter#copy#backward_find_char Glib.Unichar.isspace)
+ if new_similarsymbol then
+ (if not(self#expand_virtual_if_any (source_buffer#get_iter_at_mark `INSERT) "")then
+ let last_symbol =
+ let i = source_buffer#get_iter_at_mark `INSERT in
+ Glib.Utf8.first_char (i#get_slice ~stop:(i#copy#backward_chars 1))
in
- let ligature = get_ligature last_word in
- (match CicNotationLexer.lookup_ligatures ligature with
- | [] -> ()
- | hd :: tl ->
- write_ligature (MatitaGtkMisc.utf8_string_length ligature) hd;
- next_ligatures <- tl @ [ hd ])
- | hd :: tl ->
- write_ligature 1 hd;
- next_ligatures <- tl @ [ hd ])
+ (match Virtuals.similar_symbols last_symbol with
+ | [] -> ()
+ | eqclass ->
+ similarsymbols_orig <- eqclass;
+ let is_used =
+ try Hashtbl.find similar_memory similarsymbols_orig
+ with Not_found ->
+ let is_used = List.map (fun x -> x,false) eqclass in
+ Hashtbl.add similar_memory eqclass is_used;
+ is_used
+ in
+ let hd, next, tl =
+ let used, unused =
+ List.partition (fun s -> List.assoc s is_used) eqclass
+ in
+ match used @ unused with a::b::c -> a,b,c | _ -> assert false
+ in
+ let hd, tl =
+ if hd = last_symbol then next, tl @ [hd] else hd, (next::tl)
+ in
+ old_used_memory <- List.assoc hd is_used;
+ let is_used =
+ (hd,true) :: List.filter (fun (x,_) -> x <> hd) is_used
+ in
+ Hashtbl.replace similar_memory similarsymbols_orig is_used;
+ write_similarsymbol hd;
+ similarsymbols <- tl @ [ hd ]))
+ else
+ match similarsymbols with
+ | [] -> ()
+ | hd :: tl ->
+ let is_used = Hashtbl.find similar_memory similarsymbols_orig in
+ let last = HExtlib.list_last tl in
+ let old_used_for_last = old_used_memory in
+ old_used_memory <- List.assoc hd is_used;
+ let is_used =
+ (hd, true) :: (last,old_used_for_last) ::
+ List.filter (fun (x,_) -> x <> last && x <> hd) is_used
+ in
+ Hashtbl.replace similar_memory similarsymbols_orig is_used;
+ similarsymbols <- tl @ [ hd ];
+ write_similarsymbol hd
method private externalEditor () =
let cmd = Helm_registry.get "matita.external_editor" in
@@ -1125,6 +1280,8 @@ class gui () =
source_view#source_buffer#begin_not_undoable_action ();
script#loadFromFile content;
source_view#source_buffer#end_not_undoable_action ();
+ source_view#buffer#move_mark `INSERT source_view#buffer#start_iter;
+ source_view#buffer#place_cursor source_view#buffer#start_iter;
console#message ("'"^file^"' loaded.");
self#_enableSaveTo file
@@ -1143,8 +1300,8 @@ class gui () =
self#main#saveMenuItem#misc#set_sensitive true
method console = console
- method sourceView: GSourceView.source_view =
- (source_view: GSourceView.source_view)
+ method sourceView: GSourceView2.source_view =
+ (source_view: GSourceView2.source_view)
method fileSel = fileSel
method findRepl = findRepl
method main = main
@@ -1152,12 +1309,12 @@ class gui () =
method newBrowserWin () =
object (self)
inherit browserWin ()
- val combo = GEdit.combo_box_entry ()
+ val combo = GEdit.entry ()
initializer
self#check_widgets ();
let combo_widget = combo#coerce in
uriHBox#pack ~from:`END ~fill:true ~expand:true combo_widget;
- combo#entry#misc#grab_focus ()
+ combo#misc#grab_focus ()
method browserUri = combo
end
@@ -1222,7 +1379,8 @@ class gui () =
method private updateFontSize () =
self#sourceView#misc#modify_font_by_name
- (sprintf "%s %d" BuildTimeConf.script_font font_size)
+ (sprintf "%s %d" BuildTimeConf.script_font font_size);
+ MatitaAutoGui.set_font_size font_size
method increaseFontSize () =
font_size <- font_size + 1;
@@ -1366,9 +1524,10 @@ class interpModel =
tree_store#get ~row:iter ~column:interp_no_col
end
+
let interactive_string_choice
text prefix_len ?(title = "") ?(msg = "") () ~id locs uris
-=
+=
let gui = instance () in
let dialog = gui#newUriDialog () in
dialog#uriEntryHBox#misc#hide ();
@@ -1384,13 +1543,15 @@ let interactive_string_choice
let rec colorize acc_len = function
| [] ->
let floc = HExtlib.floc_of_loc (acc_len,hack_len) in
- fst(MatitaGtkMisc.utf8_parsed_text text floc)
+ escape_pango_markup (fst(MatitaGtkMisc.utf8_parsed_text text floc))
| he::tl ->
let start, stop = HExtlib.loc_of_floc he in
let floc1 = HExtlib.floc_of_loc (acc_len,start) in
let str1,_=MatitaGtkMisc.utf8_parsed_text text floc1 in
let str2,_ = MatitaGtkMisc.utf8_parsed_text text he in
- str1 ^ "" ^ str2 ^ "" ^ colorize stop tl
+ escape_pango_markup str1 ^ "" ^
+ escape_pango_markup str2 ^ "" ^
+ colorize stop tl
in
(* List.iter (fun l -> let start, stop = HExtlib.loc_of_floc l in
Printf.eprintf "(%d,%d)" start stop) locs; *)
@@ -1492,8 +1653,10 @@ let interactive_interp_choice () text prefix_len choices =
let _ =
(* disambiguator callbacks *)
- GrafiteDisambiguator.set_choose_uris_callback (interactive_uri_choice ());
- GrafiteDisambiguator.set_choose_interp_callback (interactive_interp_choice ());
+ Disambiguate.set_choose_uris_callback
+ (fun ~selection_mode ?ok ?(enable_button_for_non_vars=false) ~title ~msg ->
+ interactive_uri_choice ~selection_mode ?ok_label:ok ~title ~msg ());
+ Disambiguate.set_choose_interp_callback (interactive_interp_choice ());
(* gtk initialization *)
GtkMain.Rc.add_default_file BuildTimeConf.gtkrc_file; (* loads gtk rc *)
GMathView.add_configuration_path BuildTimeConf.gtkmathview_conf;