From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA18878; Mon, 5 Aug 2002 13:06:03 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA18773 for ; Mon, 5 Aug 2002 13:06:02 +0200 (MET DST) Received: from lobus.fungible.com (adsl-64-161-114-6.dsl.snfc21.pacbell.net [64.161.114.6]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g75B60D19870 for ; Mon, 5 Aug 2002 13:06:01 +0200 (MET DST) Received: by lobus.fungible.com (Postfix, from userid 1000) id E78B87F7E; Mon, 5 Aug 2002 04:05:58 -0700 (PDT) Date: Mon, 5 Aug 2002 03:59:36 -0700 From-Tims-Fingers: true To: zhaoway@public1.ptt.js.cn Cc: caml-list@inria.fr In-reply-to: <3D4E4F1A.2050207@public1.ptt.js.cn> (message from zw on Mon, 05 Aug 2002 18:10:34 +0800) Subject: Re: [Caml-list] read a key press References: <3D4E4F1A.2050207@public1.ptt.js.cn> Message-Id: <20020805110558.E78B87F7E@lobus.fungible.com> From: tim@fungible.com (Tim Freeman) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >I want to write a small echo program (for self amusement). It's like >that everytime I press a character key, there's a hook function got >called. Somewhat like a event loop. The operating system is buffering your line of input so it can process any rubouts you might do. There are lots of ways to invoke OCAML in different operating systems, so there isn't one way to get it to work. I just had this dialogue under an xterm in linux that does something resembling what you want: lobus:~> stty cbreak; ocaml Objective Caml version 3.04 # 3+4;; - : int = 7 # read_char stdin;; Unbound value read_char # input_char stdin;; x- : char = 'x' # The "stty cbreak" gets rid of line buffering, so backspace becomes a normal input character instead of rubbing out the previous character. -- Tim Freeman tim@fungible.com GPG public key fingerprint ECDF 46F8 3B80 BB9E 575D 7180 76DF FE00 34B1 5C78 ------------------- 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