From: dale@cs.rmit.edu.au (Dale Stanbrough)
Subject: Re: Using Get_Immediate to read keystrokes.
Date: 1998/08/30
Date: 1998-08-30T06:47:34+00:00 [thread overview]
Message-ID: <dale-3008981652550001@dale.bu.cs.rmit.edu.au> (raw)
In-Reply-To: 98082016293577@psavax.pwfl.com
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
prev parent reply other threads:[~1998-08-30 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <98082016293577@psavax.pwfl.com>
1998-08-26 0:00 ` Using Get_Immediate to read keystrokes John McCabe
1998-08-26 0:00 ` David C. Hoos, Sr.
1998-08-27 0:00 ` Jerry van Dijk
1998-08-26 0:00 ` John McCabe
1998-08-30 0:00 ` Dale Stanbrough [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox