Avoid ncurses. It contains too much baggage for the elegantly
simple functions you want.
write your own line input routine. Since you don't need or want
fancy screen functions this should be trivial.
> From [EMAIL PROTECTED] Mon Jan 8 10:28:58 2001
> Return-Path: <[EMAIL PROTECTED]>
> Received: from braille.uwo.ca (root@[129.100.109.30])
> by cougar.aero-vision.com (8.9.3/8.9.3) with ESMTP id KAA18728
> for <[EMAIL PROTECTED]>; Mon, 8 Jan 2001 10:28:57 -0500
> Received: from speech.braille.uwo.ca(localhost[127.0.0.1]) (4342 bytes) by
>braille.uwo.ca
> via smail with P:esmtp/R:inet_hosts/T:smtp
> (sender: <[EMAIL PROTECTED]>)
> id <[EMAIL PROTECTED]>
> for <[EMAIL PROTECTED]>; Mon, 8 Jan 2001 10:28:48 -0500 (EST)
> (Smail-3.2.0.102 1998-Aug-2 #2 built 1999-Sep-5)
> Received: from mail6.kscable.com(fe6.rdc-kc.rr.com[24.94.163.53]) (3733 bytes) by
>braille.uwo.ca
> via smail with P:esmtp/D:aliases/T:pipe
> (sender: <[EMAIL PROTECTED]>)
> id <[EMAIL PROTECTED]>
> for <[EMAIL PROTECTED]>; Mon, 8 Jan 2001 10:28:42 -0500 (EST)
> (Smail-3.2.0.102 1998-Aug-2 #2 built 1999-Sep-5)
> Received: from mattcamp.selfhost.com ([65.27.68.9]) by mail6.kscable.com with
>Microsoft SMTPSVC(5.5.1877.357.35);
> Mon, 8 Jan 2001 09:26:26 -0600
> Received: from mattcampbell by mattcamp.selfhost.com with local (Exim 3.12 #1
>(Debian))
> id 14Fe6p-0000NA-00
> for <[EMAIL PROTECTED]>; Mon, 08 Jan 2001 09:21:19 -0600
> Date: Mon, 8 Jan 2001 09:21:19 -0600
> From: Matthew Campbell <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: How to get keyboard input from the user
> Message-ID: <[EMAIL PROTECTED]>
> Mime-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> User-Agent: Mutt/1.2.5i
> Reply-To: [EMAIL PROTECTED]
> Sender: [EMAIL PROTECTED]
> Errors-To: [EMAIL PROTECTED]
> X-Mailman-Version: 1.1
> Precedence: bulk
> List-Id: list for the Text-Mode RealMedia Player <trplayer.braille.uwo.ca>
> X-BeenThere: [EMAIL PROTECTED]
>
> As some of you know, TRPlayer currently uses the slang library to get
> keyboard input from the user. This allowed me to implement keyboard
> commands, including use of the cursor keys, relatively quickly, but there
> are some problems:
>
> 1. On some systems (especially non-Linux systems), slang is a non-standard
> library, one more thing for the user to install.
>
> 2. slang assumes that the terminal is VT100-compatible and therefore uses
> hard-coded escape sequences instead of termcap or terminfo. This point may
> be irrelevant if everyone is using a VT100-compatible terminal now.
>
> 3. When waiting for the characters in the escape sequence for an extended
> key, slang has no timeout. In particular, this means that if you press
> escape while TRPlayer is running, slang will wait for the next character,
> the audio buffer will become empty, and the audio will stop until you press
> another key. TRPlayer should beep instead.
>
> 4. slang reads its input directly from the terminal device (possibly
> through /dev/tty), not from standard input. This means that even if you
> redirect standard input to another device or file, slang reads from the
> terminal on which the process started. TRPlayer works around this by
> running in line mode (not using slang at all) when it notices that standard
> input isn't a terminal. This allows TRPlayer to get its commands from
> another process or file. This approach would backfire, though, if standard
> input is redirected to another terminal. TRPlayer also has a
> non-interactive mode which is turned on using the -n option.
>
> The first alternative to slang that comes to mind is ncurses. In fact, I
> looked at this before I chose to use slang. The problem with ncurses is
> that the keyboard input functions are closely tied to the screen output
> system. Whenever you call the getch or wgetch function in ncurses, it
> refreshes the screen. So if I call getch or wgetch just after calling
> initscr, ncurses will clear the screen, and I'll probably have to use
> ncurses' screen output routines to output to the screen. I wanted the
> output of TRPlayer to remain line-oriented, and I didn't want it to
> automatically clear the screen. But these are just my preferences, and if
> others think the ncurses library would be the best solution, that's what
> I'll use.
>
> The other alternative that comes to mind is to write one's own keyboard
> input code. This code must be able to handle cursor movement keys, should
> read from standard input, and should have a timeout feature as ncurses does.
> Termcap/terminfo support would also be a good idea, though I suppose it's
> not required. This would automatically solve problem #1, at the expense of
> making TRPlayer larger.
>
> What do you all think would be the best way to go here?
>
> --
> Matt Campbell <http://www.pobox.com/~mattcampbell/> ICQ #: 33005941
>