Path: 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: [ 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 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: > > [ 0 ; 0 H > [ 2 J No, VT100 terminals clear the entire screen no matter where the cursor is if you use " [ 2 J"... The control sequence is " Pn J", where is represented as 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 " [ H" does just fine. It is a special case of the sequence " [ 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 " H" to home the cursor and " 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: "" in the above text refers to the C0 escape character (hex 1B, octal 33, decimal 27). "" is an 8-bit C1 control (hex 9B, octal 233, decmial 155) which is represented in a 7-bit environment as followed by '['. Real VT100s do not understand 8-bit control characters, thus must use [. 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-----------