let squel ~f_init ~f_end ~f_key ~f_mouse ~f_except =
f_init () ;
try
while true do
try
let s = Graphics.wait_next_event [Graphics.Button_down; Graphics.Key_pressed]
in
if s.Graphics.keypressed then f_key s.Graphics.key
else
if s.Graphics.button
then f_mouse s.Graphics.mouse_x s.Graphics.mouse_y
with
| Fin -> raise Fin
| e -> f_except e
done
with
Fin -> f_end ()