comp.lang.ada
 help / color / mirror / Atom feed
* Re: Using Get_Immediate to read keystrokes.
       [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
  3 siblings, 1 reply; 5+ messages in thread
From: David C. Hoos, Sr. @ 1998-08-26  0:00 UTC (permalink / raw)



Marin David Condic, 561.796.8997, M/S 731-96 wrote in message
<98082016293577@psavax.pwfl.com>...
>    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 see no evidence that this hasd been answered, so I'll tell you how I do
it.

I use Ada subprograms pragma-interfaced (is that a word?) to the tcgetattr
and tcsetattr functions.  If memory serves me correctly, I have three
subprograms, viz.:

One is Set_Echo_Mode with an enumeration parameter (On, Off), and the other
two are called Save_Console_State and Restore_Console_State.

I got the Idea to use these functions from reading the a-sysdep.c file in
the gnat distribution.

Hope this helps,

David C. Hoos, Sr.







^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using Get_Immediate to read keystrokes.
       [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-26  0:00 ` John McCabe
  1998-08-30  0:00 ` Dale Stanbrough
  3 siblings, 0 replies; 5+ messages in thread
From: John McCabe @ 1998-08-26  0:00 UTC (permalink / raw)




-- 
Best Regards
John McCabe

=====================================================================
Not necessarily my company or service providers opinions.
=====================================================================






^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using Get_Immediate to read keystrokes.
       [not found] <98082016293577@psavax.pwfl.com>
@ 1998-08-26  0:00 ` John McCabe
  1998-08-26  0:00 ` David C. Hoos, Sr.
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: John McCabe @ 1998-08-26  0:00 UTC (permalink / raw)


"Marin David Condic, 561.796.8997, M/S 731-96" <condicma@PWFL.COM> wrote:

>    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?

The command "stty -echo" stops the terminal from echoing characters. 
There ought to be some way of making this happen from inside the program 
although I haven't tried it.

>     Or better yet - has someone got a piece of code that already
>    implements a command line with a buffer?


-- 
Best Regards
John McCabe

=====================================================================
Not necessarily my company or service providers opinions.
=====================================================================






^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using Get_Immediate to read keystrokes.
  1998-08-26  0:00 ` David C. Hoos, Sr.
@ 1998-08-27  0:00   ` Jerry van Dijk
  0 siblings, 0 replies; 5+ messages in thread
From: Jerry van Dijk @ 1998-08-27  0:00 UTC (permalink / raw)


David C. Hoos, Sr. (david.c.hoos.sr@ada95.com) wrote:

: One is Set_Echo_Mode with an enumeration parameter (On, Off), and the other
: two are called Save_Console_State and Restore_Console_State.

: I got the Idea to use these functions from reading the a-sysdep.c file in
: the gnat distribution.

Or even better, use the equivalent functions from a POSIX binding...

Jerry.
-- 
-- Jerry van Dijk  | email: jdijk@acm.org
-- Leiden, Holland | member Team-Ada
-- Ada & Win32: http://stad.dsl.nl/~jvandyk




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using Get_Immediate to read keystrokes.
       [not found] <98082016293577@psavax.pwfl.com>
                   ` (2 preceding siblings ...)
  1998-08-26  0:00 ` John McCabe
@ 1998-08-30  0:00 ` Dale Stanbrough
  3 siblings, 0 replies; 5+ messages in thread
From: Dale Stanbrough @ 1998-08-30  0:00 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-08-30  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox