caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] interrupt OCaml when using the Graphics library
@ 2013-02-27 18:35 Alain Coste
  2013-02-28  0:39 ` ygrek
  0 siblings, 1 reply; 2+ messages in thread
From: Alain Coste @ 2013-02-27 18:35 UTC (permalink / raw)
  To: caml-list

Hello
I work with OCaml-4 and windows XP.
I am using the Graphics library, and I don't know how to wake-up OCaml when 
it is suspended waiting for an event in the graphic window.
Some cases when this happens:
   - I interrupt OCaml with ^C; nothing happens until I move the mouse or 
clic in the graphic window.
   - The graphic window is killed (click on  X in the window title); here 
things are worse as I can no longer send an event to the window; OCaml is 
definitly blocked.
   - The graphic window is resized (with the mouse); my program cannot 
update the contents of the window until I release the mouse button and move 
the mouse (or click) inside the window.

When OCaml runs in text mode (ie not in the graphic window) it can also get 
suspended waiting for input on stdin, but the process which runs OCaml 
(XEmacs with comint in my case) can simply send a character to its stdin 
after sending sigint, OCaml is waked-up and processes the interrupt.

I have tried to change the behavior of OCaml with Sys.signal, but this 
doesn't work as OCaml doesn't recognize sigint while it is suspended.

The only workaround I found is to ask XEmacs to run an ahk script which 
posts a message or sends a click to the graphic window;
but this works only if the window is still alive and is rather convoluted...

I suppose there is a better method to do this, but I am stuck down.

Alain Coste 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] interrupt OCaml when using the Graphics library
  2013-02-27 18:35 [Caml-list] interrupt OCaml when using the Graphics library Alain Coste
@ 2013-02-28  0:39 ` ygrek
  0 siblings, 0 replies; 2+ messages in thread
From: ygrek @ 2013-02-28  0:39 UTC (permalink / raw)
  To: caml-list

On Wed, 27 Feb 2013 19:35:52 +0100
Alain Coste <alaincoste@club-internet.fr> wrote:

> I am using the Graphics library, and I don't know how to wake-up OCaml when 
> it is suspended waiting for an event in the graphic window.

Graphics module is suitable for education or very simple drawings when you need to
quickly dump something on the screen. If you want to do anything more fancy, especially
interacting with a user, you are better off with some OCaml GL library.

-- 
 ygrek
 http://ygrek.org.ua

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-28  0:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-27 18:35 [Caml-list] interrupt OCaml when using the Graphics library Alain Coste
2013-02-28  0:39 ` ygrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).