[comp.unix] curses standout

exspes@gdr.bath.ac.uk (P E Smee) (07/04/90)

In article <3610@zorba.Tynan.COM> "raz(a" <uunet!NSFnet-Relay.AC.UK!raza%cs.heriot-watt.ac.uk> writes:
>the problem is that when i try and use the curses function standout(), it
>simply doesn't work! (this function is used with standend() to make text
>appear in reverse video).
>i am using a TELEVIDEO model 910+, 920c and 910g type terminal, the problem 
>is that the function DOES work with a vt100 type terminal.

The clue is that on a TVI9xxa the 'inverse video' and 'end inverse'
(termcap 'so' and 'se') eat a character position.  (sg != 0)  Many
versions of curses (for which read 'the 5 that I've tried on different
machines') will not use standout mode if sg is non-zero.  Not too
surprising as given the way normal curses works, having these extra
screen positions come and go would screw things up.

One possibility is to use some other (non-space-eating) mode, by
changing sg to 0 and so/se to point to strings which will put you
into/out of the mode.  Half-bright works OK on TVIs.  Except it may be
invisible if the terminal contrast is set wrong.

Failing that, you need to invent some other way of 'marking' things on
terminals where sg != 0.  Or, find/write a cleverer curses.
-- 
Paul Smee, Computing Service, University of Bristol, Bristol BS8 1UD, UK
 P.Smee@bristol.ac.uk - ..!uunet!ukc!bsmail!p.smee - Tel +44 272 303132

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (07/04/90)

As quoted from <3610@zorba.Tynan.COM> by raza@cs.heriot-watt.ac.uk:
+---------------
| the problem is that when i try and use the curses function standout(), it
| simply doesn't work! (this function is used with standend() to make text
| appear in reverse video).
| i am using a TELEVIDEO model 910+, 920c and 910g type terminal, the problem 
| is that the function DOES work with a vt100 type terminal.
+---------------

The Televideo 910/920 series terminal is possessed of an affliction known as
"attribute spaces", sometimes called "magic cookies".  This means that the
start-reverse-video and end-reverse-video sequences take up space on the
terminal display.  Moreover, the sequences are not applied to individual
characters; they're applied to the space on the screen between the standout()
and standend() sequences.  Some terminals enforce an automatic end-reverse-
video at the end of a physical line as well.  Curses was written for ANSI
X3.64 terminals, however; it assumes that attributes are stored as "extra
bits" in a character instead of in "invisible" character positions, and apply
to any characters output between the start-reverse-video and end-reverse-video
sequences regardless of screen position.

This can cause curses to fail in either of two ways:

(1) It can output the start-reverse-video sequence somewhere where it won't
    affect the text you want to show reversed; that is, after the text (with
    respect to the physical position on the terminal screen) or on a different
    line (of the terminal forces end-reverse-video at end of line);

(2) It can output the start-reverse-video sequence, then write over it with
    your message; since the terminal considers the attribute space to be like
    any other character, if something else is printed over it, it is replaced
    by the character.  As a result, the string comes out in normal video.

System V curses attempts to handle this "correctly"; it requires that the
terminfo entry spacify both "xmc#1" to indicate that attributes take up space
on the screen and "!msgr" to specify that attributes apply to screen positions
and not characters.  And it doesn't always get it right.

Alternatives:

(1) Use ANSI X3.64 compatible terminals like the VT100 or the Televideo 970.
    (Sometimes known as "Get a *real* terminal!" by snobs.)

(2) Many terminals of the Televideo persuasion support "protected" characters;
    often, the attribute used to indicate that a character is "protected" can
    be configured at terminal set-up or sometimes from software.  Moreover,
    the "protect" attribute can be set without actually activating write-
    protect mode.  (The usual escape sequences are <ESC>) to begin protect
    mode and <ESC>( to end it.)  If you can set the "protect attribute" to
    reversed and change the termcap/terminfo to use the start/end protect mode
    escape sequences, reverse video will work from curses: protect mode acts
    like ANSI X3.64 attributes, not like "attribute spaces".  (This is espec-
    ially useful on Wyse Technologies' terminals that lack ANSI compatibility;
    and the WY-75 actually uses this trick internally to make <ESC>[?m (where
    "?" is any number except 0) do ANSI-compliant reverse video.)

++Brandon
-- 
Me: Brandon S. Allbery			VHF: KB8JRR on 224.50 (Lake County, OH)
Internet: allbery@NCoast.ORG		Delphi: ALLBERY
uunet!cwjcc.cwru.edu!ncoast!allbery	America OnLine: BrandonA or KB8JRR

nts0302@dsacg3.dsac.dla.mil (Bob Fisher) (07/04/90)

> when i try and use the curses function standout(), it simply doesn't work!
> i am using a TELEVIDEO model 910+, 920c and 910g type terminal, the problem 
> is that the function DOES work with a vt100 type terminal.

If it works for vt100, that would seem to prove that the code is OK.

Have you checked the termcap/terminfo to see if "se" and "so" are defined
for the Televideo terminals?

-- 
Bob Fisher
US Defense Logistics Agency Systems Automation Center
DSAC-TSX, Box 1605, Columbus, OH 43216-5002     614-238-9071 (AV 850-9071)
bfisher@dsac.dla.mil		osu-cis!dsacg1!bfisher

jcg@tree.uucp (Chris Gonnerman) (07/04/90)

In article <3610@zorba.Tynan.COM>, raza@cs.heriot-watt.ac.uk writes:
> hiy!
> 
> i've got a HUGE problem trying to use curses and i'd be REALLY grateful
> if someone could help me to solve it.
> 
> the problem is that when i try and use the curses function standout(), it
> simply doesn't work! (this function is used with standend() to make text
> appear in reverse video).
> i am using a TELEVIDEO model 910+, 920c and 910g type terminal, the problem 
> is that the function DOES work with a vt100 type terminal.
[ code fragment deleted ]
> has anyone else had this specific type of problem ????
> raz

If you have a function in curses that works on one terminal reliably, but does
not on another, then the culprit may be the /etc/termcap or /usr/lib/terminfo/*
entry for that terminal.  On our system we have a lot of users with very
different terminal emulations, and it has been a battle to trim the terminfo's
or create new ones to support everyone.

I suggest, if you are not comfortable with the internal parts of your termcap
or terminfo system, that you might want to post a request to the net for an
appropriate definition.  If I had one for that terminal, I'd send it to you,
but so far no one has asked for Televideo support.  (Only a matter of time.)

Good luck!

-- 
 +----------------------------------------------------------------------------+
 | Chris Gonnerman (Mad Programmer At Large)     ... mail via UUCP only ...   |
 | @ the Tree BBS, Sacramento, CA              ucbvax!ucdavis!csusac!tree!jcg |
 +----------  DISCLAIMER: These opinions are mine... MINE, I say!  -----------+

kstock@gouldfr.encore.fr (Kevin STOCK - MIS (Compta)) (07/04/90)

> simply doesn't work! (this function is used with standend() to make text
> appear in reverse video).
> i am using a TELEVIDEO model 910+, 920c and 910g type terminal, the problem 
> is that the function DOES work with a vt100 type terminal.

Your program looked OK to me, except that refrsh() should be
refresh() - I assume that's just a typo. I suspect that your
termcap (or terminfo) doesn't include definitions for standout
and standend. For termcap, you need to add the fields so=... and
se=... (check the terminal manual for the exact sequences).

  ,---------------.
,-+-------------. |    Kevin Stock
| | E N C O R E | |
| `-------------+-'    kstock@gouldfr.encore.fr
`---------------'      kstock@gouldfr.UUCP

Any opinions expressed are my own, but may be reproduced under the terms
of the GNU licence. See the file COPYING at the end of this posting. :-)

peter@ficc.ferranti.com (Peter da Silva) (10/10/90)

In article <3647@zorba.Tynan.COM> exspes@gdr.bath.ac.uk (P E Smee) writes:
> The clue is that on a TVI9xxa the 'inverse video' and 'end inverse'
> (termcap 'so' and 'se') eat a character position.

Sometimes. You can turn that off, but it still treats standout weirdly.
I think you can handle that by telling curses not to move while in
standout mode. It's a pain.

If we didn't have some 400 of the things floating around, I'd probably be
advocating a mass boycott of Televideo terminals. Maybe we could all get
together and hols a mass rally... burn the damned monstrosities or something.

Anyway, try putting your terminal into "attribute nospace" mode, take out
the "xm" flag, and add "xs". You should already have "ms" disabled.

The following advice probably works better:

> One possibility is to use some other (non-space-eating) mode, by
> changing sg to 0 and so/se to point to strings which will put you
> into/out of the mode.  Half-bright works OK on TVIs.  Except it may be
> invisible if the terminal contrast is set wrong.

Note that this means you use the foreground/background or protected/unprotected
attribute to change the mode.

What I do is make write-protect the normal mode. Here's my Zentech Zephyr
variant:

#
# Intel NRM terminals ... Zentec Zephyr in reverse write-protect.
#
zw|weird:\
	:am:bs:cm=\E=%+ %+ :cl=1^Z\E):co#80:ho=^^:li#24:ma=^K^P:nd=^L:up=^K:\
	:im=\Eq\E):ei=\Er\E):al=\EE\E):dl=\ER\E):cd=\EY:dc=\EW\E):\
	:xt:so=\E(:se=\E):vs=\E):ce=\ET:is=\E):

The ultimate solution is violent defenestration of the offending terminals.
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.
<peter@ficc.ferranti.com>

peter@ficc.ferranti.com (Peter da Silva) (10/10/90)

In article <3653@zorba.Tynan.COM> uunet!ncoast.ORG!allbery (Brandon S. Allbery KB8JRR) writes:
> Curses was written for ANSI X3.64 terminals, however

Minor nitpick... curses was written "for" adm3a, hp2621, and h19 terminals
initially. And the h19s were typically used in VT52 mode, so ANSI sequences
never came into things. Luckily the Heath and HP terminals were reasonably
sane about attributes, and the adms didn't have any.

(the HP terminals were the prettiest, but the escape sequences were even
longer than ANSI, so the Heaths became the terminal of choice at 1200 baud.
The HP terminals took over the VAX computer room where they had 9600 baud
connections.)
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.
<peter@ficc.ferranti.com>

kpv@ulysses.att.com (Phong Vo[drew]) (10/11/90)

In article <2128@megadon.UUCP>, peter@ficc.ferranti.com (Peter da Silva) writes:
: In article <3653@zorba.Tynan.COM> uunet!ncoast.ORG!allbery (Brandon S. Allbery KB8JRR) writes:
: > Curses was written for ANSI X3.64 terminals, however
: 
: Minor nitpick... curses was written "for" adm3a, hp2621, and h19 terminals
: Peter da Silva.   `-_-'

Maybe I lost some early part of the thread, but curses,
at least the one that I wrote (SysVr3.2 or later), is for all
character terminals that can place the cursor at a random point on the screen.
It handles video attributes for all the HP26* and TVI* terminals
efficiently and correctly (as correct as possible for the TVI-variety).
It also knows about multi-byte/multi-column characters (Japanese, Chinese).
	Phong Vo, att!ulysses!kpv

dig@peritek.UUCP (Dave Gotwisner) (10/17/90)

In article <2182@megadon.UUCP>, kpv@ulysses.att.com (Phong Vo[drew]) writes:
# In article <2128@megadon.UUCP>, peter@ficc.ferranti.com (Peter da Silva) writes:
# : In article <3653@zorba.Tynan.COM> uunet!ncoast.ORG!allbery (Brandon S. Allbery KB8JRR) writes:
# : > Curses was written for ANSI X3.64 terminals, however
# : 
# : Minor nitpick... curses was written "for" adm3a, hp2621, and h19 terminals
# : Peter da Silva.   `-_-'
# 
# Maybe I lost some early part of the thread, but curses,
# at least the one that I wrote (SysVr3.2 or later), is for all
# character terminals that can place the cursor at a random point on the screen.
# It handles video attributes for all the HP26* and TVI* terminals
# efficiently and correctly (as correct as possible for the TVI-variety).
# It also knows about multi-byte/multi-column characters (Japanese, Chinese).
# 	Phong Vo, att!ulysses!kpv

Ah, but what Peter meant (I think) is that the original 4BSD (or 2BSD, or
Version 7, or Version 6) curses from U.C. Berkeley, although designed to
be terminal independent, started with the terminals which people at U. C. had,
namely ADM3A, HP2621, H19 (or Z19) terminals, plus some few which other
grad students had at home/in the lab (like Televideo, ADS, and a few others)
and submitted TERMCAP entries for.  It was definitely NOT written specifically
for ANSI X3.64 terminals (although Z19/H19 emulated this spec).

AT&T of course, took the curses/termcap implementation and changed it to their
curses/terminfo (compiled termcap entries) implementation.
-- 
------------------------------------------------------------------------------
Dave Gotwisner					UUCP:  ...!unisoft!peritek!dig
Peritek Corporation				       ...!vsi1!peritek!dig
5550 Redwood Road
Oakland, CA 94619				Phone: 1-415-531-6500