comp.lang.ada
 help / color / mirror / Atom feed
* How can I clear the screen?
@ 1996-03-27  0:00 Jason Powell
  1996-03-29  0:00 ` steved
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Powell @ 1996-03-27  0:00 UTC (permalink / raw)


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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How can I clear the screen?
  1996-03-27  0:00 How can I clear the screen? Jason Powell
@ 1996-03-29  0:00 ` steved
  1996-03-29  0:00   ` Hung Huynh
  1996-03-30  0:00   ` Keith Thompson
  0 siblings, 2 replies; 7+ messages in thread
From: steved @ 1996-03-29  0:00 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How can I clear the screen?
  1996-03-29  0:00 ` steved
@ 1996-03-29  0:00   ` Hung Huynh
  1996-03-29  0:00     ` Ted Dennison
  1996-03-30  0:00   ` Keith Thompson
  1 sibling, 1 reply; 7+ messages in thread
From: Hung Huynh @ 1996-03-29  0:00 UTC (permalink / raw)
  To: Steve Doiel

> 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.

Hi! I tried your package in a unix xterm window and it worked fine.
But could you explain how this procedure work? I'm a novice.

------------------------------------------
 PROCEDURE ClearScreen IS

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

I understand that your CSI is equal to  ESC & "[" , but why does the
output of the string "ESC[2J" cause a screen clear? Does it have something
to do with ANSI?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How can I clear the screen?
  1996-03-29  0:00   ` Hung Huynh
@ 1996-03-29  0:00     ` Ted Dennison
  0 siblings, 0 replies; 7+ messages in thread
From: Ted Dennison @ 1996-03-29  0:00 UTC (permalink / raw)


Hung Huynh wrote:
> I understand that your CSI is equal to  ESC & "[" , but why does the
> output of the string "ESC[2J" cause a screen clear? Does it have something
> to do with ANSI?

It has everything to do with ANSI/VT100. If the text display this is
being written to supports ANSI/VT100/VT220 etc., then this will clear
the screen. If it does not, then you will likely see some random
garbage with a "2J" at the end.

-- 
T.E.D.          
                |  Work - mailto:dennison@escmail.orl.mmc.com  |
                |  Home - mailto:dennison@iag.net              |
                |  URL  - http://www.iag.net/~dennison         |




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How can I clear the screen?
  1996-03-29  0:00 ` steved
  1996-03-29  0:00   ` Hung Huynh
@ 1996-03-30  0:00   ` Keith Thompson
  1996-03-31  0:00     ` Hung Huynh
  1 sibling, 1 reply; 7+ messages in thread
From: Keith Thompson @ 1996-03-30  0:00 UTC (permalink / raw)


In <4jfqqv$ekh@news.pacifier.com> steved@pacifier.com@199.2.117.163   (Steve Doiel) writes:
> 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.
[spec and body of Terminal package deleted]

This implementation assumes a terminal or emulator that accepts
VT100-style control codes (also referred to as ANSI, since there's an
ANSI standard for this).  These days that's almost a safe assumption,
since the vast majority of modern text-mode terminals and emulators,
including xterm, at least have a mode in which they emulate a VT100.

Full generality would require something like Unix's termcap, terminfo,
or curses interface.

-- 
Keith Thompson (The_Other_Keith) kst@thomsoft.com
TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718
This sig uses the word "Exon" in violation of the Communications Decency Act.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How can I clear the screen?
  1996-03-30  0:00   ` Keith Thompson
@ 1996-03-31  0:00     ` Hung Huynh
  1996-04-02  0:00       ` Michael A. Packer
  0 siblings, 1 reply; 7+ messages in thread
From: Hung Huynh @ 1996-03-31  0:00 UTC (permalink / raw)




:This implementation assumes a terminal or emulator that accepts
:VT100-style control codes (also referred to as ANSI, since there's an


Anyone know where to get by a list of the VT100-style control codes?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How can I clear the screen?
  1996-03-31  0:00     ` Hung Huynh
@ 1996-04-02  0:00       ` Michael A. Packer
  0 siblings, 0 replies; 7+ messages in thread
From: Michael A. Packer @ 1996-04-02  0:00 UTC (permalink / raw)


Hung Huynh (d95hung@dtek.chalmers.se) wrote:
: 
: 
: :This implementation assumes a terminal or emulator that accepts
: :VT100-style control codes (also referred to as ANSI, since there's an
: 
: 
: Anyone know where to get by a list of the VT100-style control codes?

let me go search.....i know i have this somewhere...


                              ANSI ESCAPE SEQUENCES
===============================================================================
Wherever you see '#', that should be replaced by the appropriate number.

        ESC code sequence                       Function
       -------------------              ---------------------------
Cursor Controls:
         ESC[#;#H or ESC[#;#f           Moves cusor to line #, column #
         ESC[#A                         Moves cursor up # lines
         ESC[#B                         Moves cursor down # lines
         ESC[#C                         Moves cursor forward # spaces
         ESC[#D                         Moves cursor back # spaces
         ESC[#;#R                       Reports current cursor line & column
         ESC[s                          Saves cursor position for recall later
         ESC[u                          Return to saved cursor position

Erase Functions:
         ESC[2J                         Clear screen and home cursor
         ESC[K                          Clear to end of line

Set Graphics Rendition:
         ESC[#;#;....;#m                Set display attributes where # is
                                            0 for normal display
                                            1 for bold on
                                            4 underline (mono only)
                                            5 blink on
                                            7 reverse video on
                                            8 nondisplayed (invisible)
                                            30 black foreground 
                                            31 red foreground 
                                            32 green foreground 
                                            33 yellow foreground 
                                            34 blue foreground 
                                            35 magenta foreground 
                                            36 cyan foreground 
                                            37 white foreground
                                            40 black background
                                            41 red background
                                            42 green background
                                            43 yellow background
                                            44 blue background
                                            45 magenta background
                                            46 cyan background
                                            47 white background

         ESC[=#;7h or                   Put screen in indicated mode where # is
         ESC[=h or                          0 for 40 x 25 black & white
         ESC[=0h or                         1 for 40 x 25 color
         ESC[?7h                            2 for 80 x 25 b&w
                                            3 for 80 x 25 color
                                            4 for 320 x 200 color graphics
                                            5 for 320 x 200 b & w graphics
                                            6 for 640 x 200 b & w graphics
                                            7 to wrap at end of line 

         ESC[=#;7l or ESC[=l or         Resets mode # set with above command
         ESC[=0l or ESC[?7l

Keyboard Reassignments:
         ESC[#;#;...p                   Keyboard reassignment. The first ASCII
         or ESC["string"p               code defines which code is to be 
         or ESC[#;"string";#;           changed. The remaining codes define
            #;"string";#p               what it is to be changed to.

         E.g. Reassign the Q and q keys to the A and a keys (and vice versa).
         ESC [65;81p                    A becomes Q
         ESC [97;113p                   a becomes q
         ESC [81;65p                    Q becomes A
         ESC [113;97p                   q becomes a

         E.g. Reassign the F10 key to a DIR command.
         ESC [0;68;"dir";13p            The 0;68 is the extended ASCII code 
                                        for the F10 key and 13 is the ASCII
                                        code for a carriage return.
         
         Other function key codes       F1=59,F2=60,F3=61,F4=62,F5=63
                                        F6=64,F7=65,F8=66,F9=67,F10=68
-- 
Michael Packer  Ph. 540-831-5978  Radford Univ. CS Systems Administrator
pac@runet.edu   Fax 540-831-5970  http://www.runet.edu/~pac          
   All I ask is a chance to prove that money can't make me happy.   
     Make it idiot proof and someone will make a better idiot.     




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1996-04-02  0:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-03-27  0:00 How can I clear the screen? Jason Powell
1996-03-29  0:00 ` steved
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

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