Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!seas.gwu.edu!mfeldman
From: mfeldman@seas.gwu.edu (Michael Feldman)
Newsgroups: comp.lang.ada
Subject: Re: Programming Question
Message-ID: <2562@sparko.gwu.edu>
Date: 18 Jan 91 03:24:47 GMT
References: <27954d2b.64e9@petunia.CalPoly.EDU>
Reply-To: mfeldman@seas.gwu.edu ()
Distribution: na
Organization: The George Washington University, Washington D.C.
Lines: 72
In article <27954d2b.64e9@petunia.CalPoly.EDU> ssenkere@polyslo.CalPoly.EDU () writes:
>
>Is there a way to access the cursor keys in ADA. Let me re-phrase that.
>Of course there IS a way... but with the standard packages provided... can
>it be easily done. Is there something similiar to the PUT(ascii.bs); for
>the backspace key....??
There's nothing standard. Text_IO doesn't really provide this kind of stuff.
If you are on a PC running Meridian Ada, say, I think they may have a package
that does it. Have a look at their package "tty."
>
>Also... Is there any commands in the standard packages to place the cursor
>at a specific spot on the screen? Like playing the cursor at the 10th
>column, 10th row and then do a PUT at that spot. It is important not to
>delete anything on the line previous to this 10th spot as well. (which is
>why I ask about maybe the cursors being accessable)
This is quite easy to do using ASCII characters. Assuming you have a VT100-
compatible terminal (a PC with ANSI.SYS installed in CONFIG.SYS will do
the same thing), here is a package to handle this. You can make whatever
changes you need to make. Output is much easier than input!
>
By the way - getting a _single character_ from the keyboard is not part of
Text_IO, which usually buffers input waiting for a CR. This has been
discussed often on this group. Ada9x will, I presume, try to find a
fix for this.
---- cut here for code ----
package VT100 is
----------------------------------------------------------
-- Procedures for drawing pictures of the solution on VDU.
-- ClearScreen and SetCursorAt are device-specific
----------------------------------------------------------
SCREEN_DEPTH : constant INTEGER := 24;
SCREEN_WIDTH : constant INTEGER := 80;
subtype DEPTH is INTEGER range 1..SCREEN_DEPTH;
subtype WIDTH is INTEGER range 1..SCREEN_WIDTH;
procedure ClearScreen;
procedure SetCursorAt( A: WIDTH; D : DEPTH);
end VT100;
with TEXT_IO;
package body VT100 is
package My_Int_IO is new Text_IO.Integer_IO(Integer);
----------------------------------------------------------
-- Procedures for drawing pictures on VT100
-- ClearScreen and SetCursorAt are terminal-specific
----------------------------------------------------------
procedure ClearScreen is
begin
Text_IO.PUT( ASCII.ESC & "[2J" );
end ClearScreen;
procedure SetCursorAt(A: WIDTH; D : DEPTH) is
begin
Text_IO.NEW_LINE;
-- the NEW_LINE clears the output buffer; most systems need this
Text_IO.PUT( ASCII.ESC & "[" );
My_Int_IO.PUT( D, 1 );
Text_IO.PUT( ';' );
My_Int_IO.PUT( A, 1 );
Text_IO.PUT( 'f' );
end SetCursorAt;
end VT100;