delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/20/06:35:36

Date: Thu, 20 Apr 2000 05:22:52 -0400 (EDT)
Message-Id: <200004200922.FAA15714@indy.delorie.com>
From: Eli Zaretskii <eliz AT delorie DOT com>
To: "Edward Griffin" <edward AT neptune DOT greatxscape DOT net>
CC: djgpp AT delorie DOT com
In-reply-to: <8djplv$27o$1@news6.svr.pol.co.uk>
(edward AT neptune DOT greatxscape DOT net)
Subject: Re: Fustrated person ranting about text input
References: <8djplv$27o$1 AT news6 DOT svr DOT pol DOT co DOT uk>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: "Edward Griffin" <edward AT neptune DOT greatxscape DOT net>
> Newsgroups: comp.os.msdos.djgpp
> Date: Wed, 19 Apr 2000 08:30:51 +0100
> 
> I'm writting a server program for a network game and I need to write my own
> custom text input function. The program runs in text mode so I don't need
> any graphical stuff. It currently handles IPX packets and sends them to
> other computers on the network. When it's not doing that, I want it to be
> checking for keypresses, and if it gets one, add the letter to a string, and
> display the text on the screen.
> 
> It also needs to understand delete, pgup, pgdn, enter and esc seperately.
> How should I go about doing this? There are so many functions like getch,
> kbhit, getche, putchar, getchar etc. I've tried hundreds of combinations and
> I can't get it to work.

I'm sorry that you are frustrated, but I find it unfortunate that you
didn't tell more about the specific problems that you encountered with
the various input functions.  This puts a damper on the effectiveness
of the help we could give you.

Anyway, here are two simple alternatives:

  - If you don't need this code to be portable to other platforms like
    Linux, use `kbhit' to check whether a key was pressed and
    `getxkey' to read the keys;

  - If portability to Unix/Linux *is* an issue, use `tcsetattr' to put
    the console into single-character raw-mode input mode, call
    `select' to check for keypresses and use `getc' (NOT `getch'!) to
    read the keys one by one.  Note that this alternative does NOT
    support special keys like PgDn etc., as there's no portable way of
    reading these keys.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019