aboutsummaryrefslogtreecommitdiff
path: root/ide
diff options
context:
space:
mode:
authorHugo Herbelin2018-11-03 15:41:30 +0100
committerHugo Herbelin2019-09-10 12:03:18 +0200
commit9ef674aff93396262966de8f9a583e1eae7889b9 (patch)
tree15a7ddca6b6ef4db0fa8da6b31152cf94162e774 /ide
parent1503ab7737efb29bc17c22a242e9f66be50a0762 (diff)
CoqIDE: Letting flash notices being treated sequentially.
Diffstat (limited to 'ide')
-rw-r--r--ide/ideutils.ml31
1 files changed, 30 insertions, 1 deletions
diff --git a/ide/ideutils.ml b/ide/ideutils.ml
index 246254c6a5..4b156065f3 100644
--- a/ide/ideutils.ml
+++ b/ide/ideutils.ml
@@ -34,9 +34,38 @@ let push_info,pop_info,clear_info =
(fun () -> decr size; status_context#pop ()),
(fun () -> for _i = 1 to !size do status_context#pop () done; size := 0)
+type 'a mlist = Nil | Cons of { hd : 'a ; mutable tl : 'a mlist }
+
+let enqueue a x =
+ let rec aux x = match x with
+ | Nil -> assert false
+ | Cons p ->
+ match p.tl with
+ | Nil -> p.tl <- Cons { hd = a ; tl = Nil }
+ | _ -> aux p.tl in
+ match !x with
+ | Nil -> x := Cons { hd = a ; tl = Nil }
+ | _ -> aux !x
+
+let pop = function
+ | Cons p -> p.tl
+ | Nil -> assert false
+
let flash_info =
+ let queue = ref Nil in
let flash_context = status#new_context ~name:"Flash" in
- (fun ?(delay=5000) s -> flash_context#flash ~delay s)
+ let rec process () = match !queue with
+ | Cons { hd = (delay,text) } ->
+ let msg = flash_context#push text in
+ ignore (Glib.Timeout.add ~ms:delay ~callback:(fun () ->
+ flash_context#remove msg;
+ queue := pop !queue;
+ process (); false))
+ | Nil -> () in
+ fun ?(delay=5000) text ->
+ let processing = !queue <> Nil in
+ enqueue (delay,text) queue;
+ if not processing then process ()
(* Note: Setting the same attribute with two separate tags appears to use
the first value applied and not the second. I saw this trying to set the background