comp.lang.ada
 help / color / mirror / Atom feed
From: steved@pacifier.com@199.2.117.163   (Steve Doiel)
Subject: Re: How can I clear the screen?
Date: 1996/03/29
Date: 1996-03-29T00:00:00+00:00	[thread overview]
Message-ID: <4jfqqv$ekh@news.pacifier.com> (raw)
In-Reply-To: 4jbr2n$djp@daily-planet.nodak.edu

In <4jbr2n$djp@daily-planet.nodak.edu>, jpowell@badlands.NoDak.edu (Jason Powell) writes:
>I want to clear the screen and start at the top with the next line.  How 
>can I do that?  Thanks in advance.
>
>Jason Powell
>
>=> A mathematician is a machine for converting coffee into theorms.
>
Well, you don't describe your platform or environment, but the following
works in a text mode window using GNAT on OS/2.  It isn't the most
elegant set of routines or methods, but they work for me.  I believe they
rely on the ole ANSI.SYS (or equivalent for OS/2) driver.

-- File: terminal.ads

PACKAGE Terminal IS

  -- Cooridinates are such that row 1, column 1 is at the top left corner
  -- of the terminal display.

  PROCEDURE ClearScreen;

  PROCEDURE CursorPosn( row, col : Natural );

  PROCEDURE CursorUp( rows : Natural := 0 );

  PROCEDURE CursorDown( rows : Natural := 0 );

  PROCEDURE CursorForward( chars : Natural := 0 );

  PROCEDURE CursorBack( chars : Natural := 0 );

END Terminal;

-- File: terminal.adb

WITH Text_Io;
 USE Text_Io;

WITH Ada.Characters.Latin_1;
 USE Ada.Characters.Latin_1;

PACKAGE BODY Terminal IS

PACKAGE NatIo IS NEW Text_Io.Integer_Io( Natural );
USE NatIo;

  CSI : CONSTANT String := ESC & "[";

PROCEDURE ClearScreen IS

BEGIN
  Put( CSI & "2J" );
END ClearScreen;


PROCEDURE CursorPosn( row, col : Natural ) IS

BEGIN
  Put( CSI );
  Put( row, 0 );
  Put( ";" );
  Put( col, 0 );
  Put( "H" );
END CursorPosn;

PROCEDURE CursorUp( rows : Natural := 0 ) IS

BEGIN
  Put( CSI );
  IF rows > 0 THEN
    Put( rows, 0 );
  END IF;
  Put( "A" );
END CursorUp;

PROCEDURE CursorDown( rows : Natural := 0 ) IS

BEGIN
  Put( CSI );
  IF rows > 0 THEN
    Put( rows, 0 );
  END IF;
  Put( "B" );
END CursorDown;

PROCEDURE CursorForward( chars : Natural := 0 ) IS

BEGIN
  Put( CSI );
  IF chars > 0 THEN
    Put( chars, 0 );
  END IF;
  Put( "C" );
END CursorForward;

PROCEDURE CursorBack( chars : Natural := 0 ) IS

BEGIN
  Put( CSI );
  IF chars > 0 THEN
    Put( chars, 0 );
  END IF;
  Put( "D" );
END CursorBack;

END Terminal;

I hope this helps,

Steve Doiel




  reply	other threads:[~1996-03-29  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-27  0:00 How can I clear the screen? Jason Powell
1996-03-29  0:00 ` steved [this message]
1996-03-29  0:00   ` Hung Huynh
1996-03-29  0:00     ` Ted Dennison
1996-03-30  0:00   ` Keith Thompson
1996-03-31  0:00     ` Hung Huynh
1996-04-02  0:00       ` Michael A. Packer
replies disabled

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