comp.lang.ada
 help / color / mirror / Atom feed
From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: Programming Question
Date: 18 Jan 91 03:24:47 GMT	[thread overview]
Message-ID: <2562@sparko.gwu.edu> (raw)
In-Reply-To: 27954d2b.64e9@petunia.CalPoly.EDU

In article <27954d2b.64e9@petunia.CalPoly.EDU> ssenkere@polyslo.CalPoly.EDU (<Scimitar>) 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;

  parent reply	other threads:[~1991-01-18  3:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-01-17  7:07 Programming Question <agate!bionet!uwm.edu!zaphod.mps.ohio-state.edu!usc!petunia!news@ucbvax.Berkeley.EDU>
1991-01-17 12:49 ` (George C. Harrison) Norfolk State University
1991-01-18  3:24 ` Michael Feldman [this message]
1991-01-18 19:03   ` Arthur Evans
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox