[comp.unix.questions] Termcap/terminfo magic cookies

dce@mips.UUCP (10/28/87)

According to the 4.3BSD manual, termcap(5):

	sg  num  Number of garbage chars left by so or se (default 0)

According to SVID Vol 2.:

	magic_cookie-glitch  xmc  sg  # of blank characters left by smso or
								    rmso


Now, the question I have is what is the difference between not defining
these and defining them to be 0?

From my standpoint, they mean the same thing. If a terminal has a 0-width
magic cookie, that means it puts 0 extra characters when it switches to
standout mode. If it doesn't have a magic cookie, that means it doesn't
put out any extra characters when it switches to standout mode.

Even if I was educated in the South, I'm pretty sure that "0" and "not any"
mean the same thing in this case.

Can anyone help out with this?

-- 
David Elliott		dce@mips.com  or  {ames,decwrl,prls}!mips!dce

allbery@ncoast.UUCP (Brandon Allbery) (11/05/87)

As quoted from <846@quacky.UUCP> by dce@mips.UUCP (David Elliott):
+---------------
| Now, the question I have is what is the difference between not defining
| these and defining them to be 0?
| 
| From my standpoint, they mean the same thing. If a terminal has a 0-width
| magic cookie, that means it puts 0 extra characters when it switches to
| standout mode. If it doesn't have a magic cookie, that means it doesn't
| put out any extra characters when it switches to standout mode.
+---------------

I believe the idea is that a zero-width magic cookie is still a magic cookie.
Why?  Well, the purpose of the "magic cookie" is to inform the video hardware
that all characters output from the screen position of the cookie to the next
magic cookie or to the end of the screen.On the other hand, NO magic cookie
means that an sg/smso will simply set a flag somewhere such that subsequent
characters recieved from the terminal's input stream will come out in the
specified attribute, _regardless_of_screen_position_.

Of course, my understanding was that this was SUPPOSED to be flagged in
termcap with the boolean "ms" attribute (terminfo: "msgr")....
-- 
Brandon S. Allbery		     necntc!ncoast!allbery@harvard.harvard.edu
 {harvard!necntc,well!hoptoad,sun!mandrill!hal,uunet!hnsurg3}!ncoast!allbery

flee@gondor.psu.edu (Felix Lee) (11/06/87)

In article <5187@ncoast.UUCP> allbery@ncoast.UUCP (Brandon Allbery) writes:
>As quoted from <6625@brl-smoke.ARPA> by gwyn@brl-smoke.ARPA (Doug Gwyn ):
>+---------------
>| The developer is wrong.  I know that some people have tried to give
>| special semantics to sg#0 and ug#0, but it has never to my knowledge
>| been adopted in the official termcap (or terminfo) documentation,
>+---------------

System Vr3 curses recognizes the difference between xmc#0 and no xmc at all.
The System Vr3 programmer's reference manual documents xmc# (and all the
other glitches) much better than all previous manuals.

Saying xmc#0 is *not* the same as saying msgr.  Msgr just says that the
terminal won't take you out of any display modes when you move the cursor or
send a newline.  The "magic cookie" glitch refers to terminals that use
field mark characters on the screen to change display modes, instead of
having attribute bits for each character.  IBM 3270 terminals are probably
the most widespread magic-cookie terminals.

"Magic cookie" terminals require a different display algorithm.  Say you
move to a highlighted area of the screen and print "hello".  On a "normal"
terminal, "hello" will not be highlighted (if you're not in highlighted
mode).  On a magic cookie terminal, "hello" will be highlighted, since it's
within the area delimited by the "start-highlight" and "end-highlight"
magic cookies.

Anyone want to know the semantics of xenl/xn?
--
Felix Lee	flee@gondor.psu.edu	{cbosgd,cmcl2}!psuvax1!gondor!flee

chris@mimsy.UUCP (Chris Torek) (11/12/87)

In article <5185@ncoast.UUCP> allbery@ncoast.UUCP (Brandon Allbery) writes:
>I believe the idea is that a zero-width magic cookie is still a magic cookie.

Yes and no.

>Why?  Well, the purpose of the "magic cookie" is to inform the video hardware
>that all characters output from the screen position of the cookie to the next
>magic cookie or to the end of the screen.On the other hand, NO magic cookie
>means that an sg/smso will simply set a flag somewhere such that subsequent
>characters recieved from the terminal's input stream will come out in the
>specified attribute, _regardless_of_screen_position_.

This may be true of terminfo.  It is not true of termcap.  This
relates back to my gripe about :xn:.  `sg#', in combination with
`:xs:', provides exactly enough information about a terminal so
that `vi' and `more' can work.  It does not provide enough information
to deduce just what is really going on inside the terminal.  vi
and more only ever highlight entire lines, and this is all termcap
properly describes.

>Of course, my understanding was that this was SUPPOSED to be flagged in
>termcap with the boolean "ms" attribute (terminfo: "msgr")....

No, `ms' means only what it says: the terminal can move the cursor
while in standout mode without leaving standout mode.  vi does not
need to know how standout works, so termcap does not say.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris