[comp.lang.c] ANSI ESCAPE SEQUENCES

PRASAD@cc.utah.edu (11/12/90)

Hi
	This is my first posting to this newsgroup
I wanted to know the ANSI screen control escape sequences
e.g
clear screen
position cursor
etc
thanks in advance
Prasad

jpr@jpradley.uucp (Jean-Pierre Radley) (11/12/90)

In article <102019@cc.utah.edu> PRASAD@cc.utah.edu writes:
>	This is my first posting to this newsgroup
>I wanted to know the ANSI screen control escape sequences
>e.g
>clear screen
>position cursor
>etc

1) This is comp.lang.c, and your question isn't about the C language, now, is
   it?

2) Your /etc/termcap file should answer your question.

 Jean-Pierre Radley          HIGH-Q	     jpr@jpradley	CIS: 72160,1341

chris@mimsy.umd.edu (Chris Torek) (11/12/90)

In article <102019@cc.utah.edu> PRASAD@cc.utah.edu writes:
>	This is my first posting to this newsgroup

So?  :-)

>I wanted to know the ANSI screen control escape sequences
>e.g
>clear screen
>position cursor
>etc

See ANSI standard X3.64 (I have no idea what the date suffix is).
Note that it has no relation at all to X3.159-1989.  In other words,
the sequences recommeded by ANSI for screen control have absolutely
nothing to do with `ANSI C'; in fact, you can use ANSI C on a system
that does not have a screen.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris

demoel@ruunsa.fys.ruu.nl (Ed de_Moel) (11/12/90)

In <102019@cc.utah.edu> PRASAD@cc.utah.edu writes:


>Hi
>	This is my first posting to this newsgroup
>I wanted to know the ANSI screen control escape sequences
>e.g
>clear screen
>position cursor
>etc
>thanks in advance
>Prasad


The ANSI standard for device control (not just CRT's but any
output device!) exists since 1979. It really amazes me
that UNIX people, unlike the rest of the world keep using
non-standard (and hence non-portable) code using termcaps
libraries.

(Sorry, this was really aimed at a different letter in this
group).

Your escape-sequences are:

 Position cursor:   <esc> [ y-coordinate ; x-coordinate H
 Clear screen:      <esc> [ J

The coordinate system for a CRT is:
 - left upper corner is <esc>[1;1H
 - right lower corner is <esc>[24;80H

Note that cursor positioning and erasing are separate operations,
so if you want to clear the screen and put the cursor in the upper
left corner:
    <esc>[H<esc>[J
(Hey: 1;1 is obviously default).

The above codes are for 7-bit transmission, but will also work
for 8-bit transmission. If you are using 8-bit transmission, you
may abbreviate <esc>[ to <csi>.

Note: <esc> = ASCII code 27 (decimal)    7-bit introducer 1st char
      ;     =            27 + 32         parameter-separator
      [     =            27 + 64         7-bit introducer 2nd char
      <csi> =            27 + 128        8-bit introducer only char

The complete text of ANSI X3-64/1979 can be obtained through
your national normalization institute, which is probably
ANSI in New York.

Success !
Ed.

gwyn@smoke.brl.mil (Doug Gwyn) (11/12/90)

In article <1746@ruunsa.fys.ruu.nl> demoel@ruunsa.fys.ruu.nl (Ed de_Moel) writes:
-The ANSI standard for device control (not just CRT's but any
-output device!) exists since 1979. It really amazes me
-that UNIX people, unlike the rest of the world keep using
-non-standard (and hence non-portable) code using termcaps
-libraries.

It amazes me that people really think that X3.64 has been universally
implemented on all display devices.  The slightest understanding of
termcap would demonstrate otherwise.

chris@mimsy.umd.edu (Chris Torek) (11/13/90)

In article <1746@ruunsa.fys.ruu.nl> demoel@ruunsa.fys.ruu.nl
(Ed de_Moel) writes:
>The ANSI standard for device control (not just CRT's but any
>output device!) exists since 1979. It really amazes me
>that UNIX people, unlike the rest of the world keep using
>non-standard (and hence non-portable) code using termcaps libraries.

Tell that to the manufacturers of about half the terminals in use at
our University, none of whom saw fit to implement X3.64.

If our software required ANSI terminals, it would not work.

In addition, merely knowing that a terminal's software followed the
recommendations in X3.64 is not enough to control it fully, because
you have no idea:
 - whether the device implements underline, bold, italics, etc
 - how many rows and columns there are
 - whether the device is a CRT or a printer
 - if the device is a CRT, which editing modes it implements
and so on.

X3.64 is a good (if annoyingly complicated) start, but it is not The Answer.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris

seanf@sco.COM (Sean Fagan) (11/16/90)

In article <1746@ruunsa.fys.ruu.nl> demoel@ruunsa.fys.ruu.nl (Ed de_Moel) writes:
>The ANSI standard for device control (not just CRT's but any
>output device!) exists since 1979. It really amazes me
>that UNIX people, unlike the rest of the world keep using
>non-standard (and hence non-portable) code using termcaps
>libraries.

Oh, really?

Please tell me what the "portable" way to write an editor is?

Remember that it needs to work on Unix, under, say, at least 100 different
terminals, under MS-DOS, on an Amiga, under X, etc.

-- 
-----------------+
Sean Eric Fagan  | "*Never* knock on Death's door:  ring the bell and 
seanf@sco.COM    |   run away!  Death hates that!"
uunet!sco!seanf  |     -- Dr. Mike Stratford (Matt Frewer, "Doctor, Doctor")
(408) 458-1422   | Any opinions expressed are my own, not my employers'.