Re: Is there a getch()?

From: Eric Green (egreen@cypronet.com)
Date: 02/07/96


>This is more of a general c question I think.  I want someone to be able
>to type in a letter and have my code react immediately (not after they
>press enter).  All of the ansi c books I have say to use getch().  I
>don't have getch().  It is supposed to be in stdio.h or conio.h.  I don't
>have a conio.h and it isn't in stdio.h.  I am running linux(bunch of
>different versions) with gnu c 2.6.3.  Is there another name for getch()?

If you want to read less than one line at a time, then you have to get the
telnet client from line mode into character mode.  To do this, you have to
request the client suppresses go ahead, explained in rfc 858.  This is
similar to turning echo off:

        void noncanonical_on(struct descriptor_data *d)
        {
            char on_string[] = { IAC, WILL, TELOPT_SGA, 0 };
            SEND_TO_Q(on_string[], d);
        }

>From what i've been able to figure out, you have to turn off echoing, and
handle that yourself.  Otherwise backspaces come out as ^H, and returns as
^M.  In order to support noncanonical input, you have to rewrite
process_input to handle echoing, and to react immediately to certain
sequences.

I am trying this stuff for a better string editor.  To reduce the network
load, the connection in question will only be switched to handle
noncanonical input when the editor is invoked, and switched back to normal
after.

A good reference for this stuff might be a chat server which supports this
stuff.

Eric



This archive was generated by hypermail 2b30 : 12/07/00 PST