summaryrefslogtreecommitdiffstats
path: root/otherlibs/labltk/browser
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/labltk/browser')
-rw-r--r--otherlibs/labltk/browser/editor.ml14
-rw-r--r--otherlibs/labltk/browser/main.ml8
2 files changed, 15 insertions, 7 deletions
diff --git a/otherlibs/labltk/browser/editor.ml b/otherlibs/labltk/browser/editor.ml
index ceadef8f7..a8cca85ac 100644
--- a/otherlibs/labltk/browser/editor.ml
+++ b/otherlibs/labltk/browser/editor.ml
@@ -402,12 +402,14 @@ class editor ~top ~menus = object (self)
if txt.name <> name then current_dir <- Filename.dirname name;
try
if Sys.file_exists name then
- if txt.name = name then
- Sys.rename name (name ^ "~")
- else begin match
- Jg_message.ask ~master:top ~title:"Save"
- ("File `" ^ name ^ "' exists. Overwrite it?")
- with `yes -> () | `no | `cancel -> raise Exit
+ if txt.name = name then begin
+ let backup = name ^ "~" in
+ if Sys.file_exists backup then Sys.remove backup;
+ try Sys.rename name backup with Sys_error _ -> ()
+ end else begin
+ match Jg_message.ask ~master:top ~title:"Save"
+ ("File `" ^ name ^ "' exists. Overwrite it?")
+ with `yes -> () | `no | `cancel -> raise Exit
end;
let file = open_out name in
let text = Text.get txt.tw ~start:tstart ~stop:(tposend 1) in
diff --git a/otherlibs/labltk/browser/main.ml b/otherlibs/labltk/browser/main.ml
index 427395d34..935203401 100644
--- a/otherlibs/labltk/browser/main.ml
+++ b/otherlibs/labltk/browser/main.ml
@@ -62,6 +62,11 @@ let _ =
Searchpos.view_defined_ref := (fun s ~env -> Viewer.view_defined s ~env);
Searchpos.editor_ref := Editor.f;
+ let is_win32 = Sys.os_type = "Win32" in
+ if is_win32 then
+ Format.pp_set_formatter_output_functions Format.err_formatter
+ (fun _ _ _ -> ()) (fun _ -> ());
+
let top = openTk ~clas:"OCamlBrowser" () in
Jg_config.init ();
@@ -74,6 +79,7 @@ let _ =
while true do
try
- Printexc.print mainLoop ()
+ if is_win32 then mainLoop ()
+ else Printexc.print mainLoop ()
with Protocol.TkError _ -> ()
done