comp.lang.ada
 help / color / mirror / Atom feed
From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: GOTOXY in Ada ?
Date: 8 Dec 1994 21:59:32 -0500
Date: 1994-12-08T21:59:32-05:00	[thread overview]
Message-ID: <3c8h6k$da7@felix.seas.gwu.edu> (raw)
In-Reply-To: 3c4a9a$1lts@obelix.uni-muenster.de

In article <3c4a9a$1lts@obelix.uni-muenster.de>,
Jan Ahlers <ahlersj@comix.uni-muenster.de> wrote:
>Hi all !
>
>I know this is a rather simple question, but I'll ask it anyways ;-)
>
>Is there an equivalent in Ada to the gotoxy command in Pascal (-> put the
>cursor at column x, row y) ? Answers would be greatly appreciated !

gotoxy is in no way a Pascal command. Some implementers (e.g. Borland)
put it in as a predefined procedure, but it is certainly not part of
the language. It is also not part of Ada, but it's quite easy to do
with a small package. This package assumes a vt100-ish terminal,
such as ansi.sys on your PC.

This package will get you started; you can add terminal capabilities
as you choose. 

Mike Feldman

--- cut here ---

-- spec
PACKAGE Screen IS

-- Procedures for drawing pictures on ANSI Terminal Screen
-- Michael Feldman, The George Washington University, Washington, DC

  ScreenHeight : CONSTANT Integer := 24;
  ScreenWidth : CONSTANT Integer := 80;

  SUBTYPE Height IS Integer RANGE 1..ScreenHeight;
  SUBTYPE Width  IS Integer RANGE 1..ScreenWidth;

  TYPE Position IS RECORD
    Row   : Height := 1;
    Column: Width := 1;
  END RECORD;

  PROCEDURE Beep; 
  -- Pre:  none
  -- Post: the terminal beeps once
  
  PROCEDURE ClearScreen; 
  -- Pre:  none
  -- Post: the terminal screen is cleared
  
  PROCEDURE MoveCursor (To: IN Position);
  -- Pre:  To is defined
  -- Post: the terminal cursor is moved to the given position
  
END Screen;   

-- body

WITH Text_IO;
PACKAGE BODY Screen IS

-- Michael Feldman, The George Washington University, Washington, DC

  PACKAGE My_Int_IO IS NEW Text_IO.Integer_IO (Num => Integer);

-- Procedures for drawing pictures on ANSI Terminal Screen
-- These procedures will work correctly only if the actual
-- terminal is ANSI compatible. ANSI.SYS on a DOS machine
-- will suffice.

  PROCEDURE Beep IS
  BEGIN
    Text_IO.Put (Item => ASCII.BEL);
  END Beep;

  PROCEDURE ClearScreen IS
  BEGIN
    Text_IO.Put (Item => ASCII.ESC);
    Text_IO.Put (Item => "[2J");
  END ClearScreen;

  PROCEDURE MoveCursor (To: IN Position) IS
  BEGIN                                                
    Text_IO.New_Line;  -- this avoids OS terminal buffer overflow
    Text_IO.Put (Item => ASCII.ESC);
    Text_IO.Put ("[");
    My_Int_IO.Put (Item => To.Row, Width => 1);
    Text_IO.Put (Item => ';');
    My_Int_IO.Put (Item => To.Column, Width => 1);
    Text_IO.Put (Item => 'f');
  END MoveCursor;  

END Screen;



  parent reply	other threads:[~1994-12-09  2:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-12-07 12:36 GOTOXY in Ada ? Jan Ahlers
1994-12-08 13:04 ` Philip Brashear
1994-12-09  4:19   ` Dave Retherford
1994-12-12  8:45     ` Keith Thompson
1994-12-13 10:09     ` Andre Spiegel
1994-12-09  2:59 ` Michael Feldman [this message]
1994-12-09 15:22 ` Do-While Jones
1994-12-10 21:00   ` Michael Feldman
  -- strict thread matches above, loose matches on Subject: below --
1994-12-20  2:06 GOTOXY IN ADA ? Michael Hagerty
replies disabled

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