Article View: comp.lang.modula2
Article #4836Re: beginner's stupid question
From: Daniel A. Glasser
Date: Mon, 22 May 1989 17:42
Date: Mon, 22 May 1989 17:42
51 lines
3163 bytes
3163 bytes
In article <10265@socslgw.csl.sony.JUNET>, diamond@diamond.csl.sony.junet (Norman Diamond) writes:
> You have to put the cursor at the top of the screen and then clear the
> screen. The reason is that the VT100's "clear" function only operates
> from the current cursor position to the end of the screen. The escape
> codes are something like the following:
>
> <ESC> [ 0 ; 0 H
> <ESC> [ 2 J
No, VT100 terminals clear the entire screen no matter where the cursor is
if you use "<ESC> [ 2 J"... The control sequence is "<CSI> Pn J", where
<CSI> is represented as <ESC> followed by [, Pn is a decmial digit
representing the type of screen clear to do, and J is the final character
in the sequence. Possible values for Pn --
"0" -- Clear from cursor to end of page (default)
"1" -- Clear from beginning of page through cursor
"2" -- Clear entire page
If Pn is omitted, the default is performed. To move the cursor to the
home position, the sequence "<ESC> [ H" does just fine. It is a special
case of the sequence "<ESC> [ Pr ; Pc H", where Pr is the row number
(1 and up) and Pc is the column number, represented as ASCII decimal
strings. In both cases, the default is 1.
If you are dealing with VT52 style terminals, the sequences are different.
I think that they are "<ESC> H" to home the cursor and "<ESC> J" to clear
from the cursor through the end of the page.
Some other terminals use other sequences. If you are sure of your
collection of terminals, you can write code that will send the correct
sequences to each terminal type. If you are not sure what terminals
will be used to access your application, you might consider a micro-"TERMCAP"
module which accesses terminal descriptions from a file. You may only
need functions to home the cursor and clear the screen, or you may
wish to add cursor addressing, line clearing and highlighting
(bold/underscore/reverse/blink/etc.)
Good luck.
Daniel A. Glasser
PS: "<ESC>" in the above text refers to the C0 escape character
(hex 1B, octal 33, decimal 27). "<CSI>" is an 8-bit C1 control (hex 9B,
octal 233, decmial 155) which is represented in a 7-bit environment as
<ESC> followed by '['. Real VT100s do not understand 8-bit control
characters, thus must use <ESC>[. VT200s and VT300s understand both
when the communications channel is set to 8 bits.
--
_____________________________________________________________________________
Daniel A. Glasser One of those things that goes
uwvax!per2!dag "BUMP!!!(ouch)" in the night.
---Persoft, Inc.---------465 Science Drive-------Madison, WI 53711-----------
Technical Details
Message-ID:
<859@per2.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!dogie.macc.wisc.edu!uwvax!per2!dagReferences:
<8905180953.AA13531@jade.berkeley.edu> <10265@socslgw.csl.sony.JUNET>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!dogie.macc.wisc.edu!uwvax!per2!dag From: dag@per2.UUCP (Daniel A. Glasser) Newsgroups: comp.lang.modula2 Subject: Re: beginner's stupid question Summary: <ESC> [ 2 J clears entire screen. Message-ID: <859@per2.UUCP> Date: 22 May 89 17:42:58 GMT References: <8905180953.AA13531@jade.berkeley.edu> <10265@socslgw.csl.sony.JUNET> Organization: Persoft Inc., Madison, WI Lines: 51