caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: tim@fungible.com (Tim Freeman)
To: zhaoway@public1.ptt.js.cn
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] read a key press
Date: Mon,  5 Aug 2002 03:59:36 -0700	[thread overview]
Message-ID: <20020805110558.E78B87F7E@lobus.fungible.com> (raw)
In-Reply-To: <3D4E4F1A.2050207@public1.ptt.js.cn> (message from zw on Mon, 05 Aug 2002 18:10:34 +0800)

>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


      reply	other threads:[~2002-08-05 11:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-05 10:10 zw
2002-08-05 10:59 ` Tim Freeman [this message]

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=20020805110558.E78B87F7E@lobus.fungible.com \
    --to=tim@fungible.com \
    --cc=caml-list@inria.fr \
    --cc=zhaoway@public1.ptt.js.cn \
    /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).