comp.lang.ada
 help / color / mirror / Atom feed
From: kst@sd.aonix.com (Keith Thompson)
Subject: Re: Clear Screen
Date: 1997/02/28
Date: 1997-02-28T00:00:00+00:00	[thread overview]
Message-ID: <E6AFB1.Ap2@thomsoft.com> (raw)
In-Reply-To: dewar.856916794@merv


In <dewar.856916794@merv> dewar@merv.cs.nyu.edu (Robert Dewar) writes:
[...]
>     Clear_Screen : constant String := Ascii.ESC & "[2J";

On a more or less VT100-compatible terminal or emulator, the sequence
ESC [ 2 J will clear the screen without moving the cursor.  No problem
if that's what you want, but you usually want to move the cursor to the
upper left corner of the screen (window, whatever).

>      Put_Line (Clear_Screen);

And, of course, this will move the cursor down one line after clearing
the screen.

This might be closer to what you want:

    Clear_Screen : constant String := Ascii.ESC & "[H" & Ascii.ESC & "[2J";
    ...
    Put(Clear_Screen);

If the lack of a newline causes buffering problems, you might consider
writing to Standard_Error and/or calling Ada.Text_IO.Flush.

If you're on a Unix system and you may be using a non-VT100-compatible
terminal (unlikely these days), you might want to do something like this:

   with Interfaces.C;
   with Ada.Text_IO;
   procedure Clear_Screen is
      function System(S: String) return Interfaces.C.Int;
      pragma Import(C, System, "system");
      Command : constant String := "clear" & Ascii.Nul;
      Result : Interfaces.C.Int;
      use type Interfaces.C.Int;
   begin
      Result := System(Command);
      if Result /= 0 then
	 Ada.Text_IO.Put_Line
	    ( Ada.Text_IO.Standard_Error,
	      "clear failed, result = " & Interfaces.C.Int'Image(Result));
      end if;
   end Clear_Screen;

though it's likely to be inefficient.

If you're using an Etch-A-Sketch (R) compatible display, you need to
print a message asking the operator to turn it upside-down.

-- 
Keith Thompson (The_Other_Keith) kst@sd.aonix.com <http://www.aonix.com> <*>
TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706
"Humor is such a subjective thing." -- Cartagia




  parent reply	other threads:[~1997-02-28  0:00 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <330D0C26.6331@videotron.ca>
1997-02-21  0:00 ` Clear Screen Larry Kilgallen
1997-02-22  0:00   ` Albert K. Lee
1997-02-22  0:00     ` Tom Moran
1997-02-23  0:00       ` Tom Moran
1997-02-24  0:00       ` Jean-Etienne Doucet
1997-02-25  0:00         ` Robert Dewar
1997-02-26  0:00           ` Geert Bosch
1997-02-27  0:00             ` Robert Dewar
1997-02-28  0:00               ` Norman H. Cohen
1997-03-03  0:00                 ` Keith Thompson
1997-03-03  0:00                   ` Robert Dewar
1997-03-05  0:00                     ` Keith Thompson
1997-02-27  0:00           ` Robert I. Eachus
1997-03-01  0:00             ` Robert Dewar
1997-02-28  0:00           ` Keith Thompson [this message]
1997-03-03  0:00           ` Robert I. Eachus
1997-03-05  0:00             ` Robert Dewar
1997-02-26  0:00       ` Keith Thompson
1997-02-24  0:00     ` Robert Dewar
1997-02-24  0:00 ` Thomas Koenig
1997-02-28  0:00   ` bill
1997-03-04  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-03-06  0:00 ` Robert Dewar
1997-03-06  0:00   ` Larry Kilgallen
1997-03-06  0:00     ` Robert Dewar
1997-03-06  0:00 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-03-23  0:00 Brian Hyatt
1997-03-25  0:00 ` Albert K. Lee
1997-03-25  0:00   ` Michael F Brenner
2000-05-27  0:00 Karlene
2000-05-27  0:00 ` David C. Hoos, Sr.
2000-05-28  0:00   ` MARIE Eric
2000-05-28  0:00     ` Sune Falck
2000-05-28  0:00       ` Tarjei Tj�stheim Jensen
2000-05-29  0:00       ` MARIE Eric
2000-05-27  0:00 ` Robert Dewar
2000-05-29  0:00 ` Pascal Obry
2001-11-06 20:19 Clear screen David Tumpa
2001-11-06 21:25 ` Adrian Knoth
2001-11-07  9:07 ` John McCabe
2001-11-07 16:37   ` Jeffrey Carter
2001-11-07 16:52 ` Darren New
2001-11-07 17:07   ` Preben Randhol
2001-11-07 18:59   ` tmoran
2001-11-07 19:42   ` Larry Kilgallen
2001-11-07 21:31     ` Darren New
2001-11-08  9:30       ` Preben Randhol
2001-11-08 16:40         ` Darren New
2001-11-08 19:36           ` Pascal Obry
2001-11-07 22:04     ` Jeffrey Carter
2001-11-13 15:34   ` John English
2001-11-25 22:05     ` Nick Roberts
2001-11-26 10:58       ` John English
2001-12-05 23:05       ` Daniel Krupke
2001-12-06  1:59         ` Larry Kilgallen
2001-12-06  8:13         ` John English
replies disabled

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