caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Berke Durak <durak@liafa.jussieu.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Timeout patch to X11 Graphics module
Date: Fri, 6 Sep 2002 16:40:03 +0200	[thread overview]
Message-ID: <20020906164003.C21965@liafa.jussieu.fr> (raw)

Hello,

Since I had problems with threads, and since the required feature does
not really need threads, I've done a little patch to the Graphics module.
Well, in fact, the X11 version of the Graphics module. Someone needs to fix
this for Win32.

A new Timeout of float constructor is available in the Graphics.event type :

type event =
    Button_down                 (** A mouse button is pressed *)
  | Button_up                   (** A mouse button is released *)
  | Key_pressed                 (** A key is pressed *)
  | Mouse_motion                (** The mouse is moved *)           
  | Poll                        (** Don't wait; return immediately *)
  | Timeout of float            (** No event occurs in the specified number of seconds *)

A new timedout field has been added to Graphics.status record type :

type status =
  { mouse_x : int;              (** X coordinate of the mouse *)
    mouse_y : int;              (** Y coordinate of the mouse *)
    button : bool;              (** true if a mouse button is pressed *)
    keypressed : bool;          (** true if a key has been pressed *)
    key : char;                 (** the character for the key pressed *) 
    timedout : bool;            (** true only if no event occured in the given time *)
  }

For example the expression

	wait_next_event [Key_pressed;Mouse_motion;Timeout 3.0]

will return when the mouse is moved, a key is pressed or if 3 seconds
pass, whichever comes first. In the first two cases, the timedout
field will be false. In the last case, it will be true and other
fields will be meaningless (zero or false, actually).

The patch is available at

	http://www.liafa.jussieu.fr/~durak/ocaml-306-graph.patch

Apply it by typing (sorry I'm not an expert in making patches, hope this is correct)

	cd /usr/local/src/ocaml-3.06 && patch -p6 </path/ocaml-306-graph.patch

assuming that your Ocaml sources are in /usr/local/src/ocaml-3.06 and
that the patch is /path/ocaml-306-graph.patch.

I guess it will work with previous versions.

Note that it seems that recompiling the whole Ocaml is unnecessary ;
just type

   cd /usr/local/src/ocaml-3.06/otherlibs/graph && make && make allopt && make install.

Now I can concentrate on implementing ``Standard Tetris'' !!
--
Berke Durak
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


             reply	other threads:[~2002-09-06 14:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-06 14:40 Berke Durak [this message]
2002-09-06 14:53 ` Berke Durak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020906164003.C21965@liafa.jussieu.fr \
    --to=durak@liafa.jussieu.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).