From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4a23491ada1f36bd X-Google-Attributes: gid103376,public From: dale@cs.rmit.edu.au (Dale Stanbrough) Subject: Re: Using Get_Immediate to read keystrokes. Date: 1998/08/30 Message-ID: #1/1 X-Deja-AN: 386089817 References: <98082016293577@psavax.pwfl.com> X-Complaints-To: abuse@cs.rmit.edu.au X-Trace: emu.cs.rmit.edu.au 904459654 29146 144.205.16.58 (30 Aug 1998 06:47:34 GMT) Organization: Department of Computer Science, RMIT NNTP-Posting-Date: 30 Aug 1998 06:47:34 GMT Newsgroups: comp.lang.ada Date: 1998-08-30T06:47:34+00:00 List-Id: Marin David Condic wrote: So I got a request from a user to improve the behavior of a little command line oriented application. Currently the application uses Ada.Text_IO.Get_Line to read in commands. The user wants to use the up-arrow key to recover previous commands. I'm thinking "No Problem" I've got a standard call in Text_IO called Get_Immediate - all I have to do is create a command buffer & do my own line editing & I can give him the desired feature and move on with my life. Well, using GNAT v3.09 on a Sun - SunOS 5.5.1, the behavior of Get_Immediate - while not irrational - is at least not exactly everything I want. I wrote a little quickie test program (below) which lets you see what the Get_Immediate sees for any given keystroke. My problem is that if I want to write my own little line editor to include a buffer of previous commands, you really don't want every keystroke echoed to the screen. Unfortunately, that's what happens - including escape sequences for the arrow keys, etc. Does anybody know of a trick on the Sun or using the GNAT compiler which will shut off character echoing so I can get the behavior I want? Or better yet - has someone got a piece of code that already implements a command line with a buffer? It seems you will be reinventing the (curses) wheel, and setting yourself up to maintaining a version for each new terminal with its own unique "up arrow key" encoding. Just do a few pragma imports, and you'll have all the functionality you need to cope with any terminal type Unix can throw at you. There is an Ada binding to one of the curses packages around. (i've also got one on my home page). BTW would not character'Image (ch) have done what you attempted to do in your large case statement? Dale