[comp.lang.c] Curses differences on 4.3 and Ultrix V2.2

Peter_Cutting@newcastle.ac.uk (P. G. Cutting) (09/16/88)

I wrote a simple windowing system using Curses on a 4.3 machine. Eventually
it worked but now when I recompile it and run it on an Ultrix machine the 
windows get messed up. I have checked Termcap entries and STTY entries which
seem OK, and so I conclude that there are differences between Curses on the
two machines. Can any one back up this conclusion and maybe suggest where the
problem might be.

Thanks .     Peter_Cutting@uk.ac.newcastle
ARPA	: Peter_Cutting%newcastle.ac.uk@cs.ucl.ac.uk
JANET	: Peter_Cutting@uk.ac.newcastle
UUCP	: PGC@cheviot.UUCP

spolsky-avram@CS.YALE.EDU (Joel Spolsky) (09/18/88)

In article <3711@cheviot.newcastle.ac.uk> Peter_Cutting@newcastle.ac.uk (P. G. Cutting) writes:
| 
| I wrote a simple windowing system using Curses on a 4.3 machine. Eventually
| it worked but now when I recompile it and run it on an Ultrix machine the 
| windows get messed up. I have checked Termcap entries and STTY entries which
| seem OK, and so I conclude that there are differences between Curses on the
| two machines. Can any one back up this conclusion and maybe suggest where the
| problem might be.

I also noticed that Ultrix Curses were weird. I am sure that Ultrix
Curses are very different than (from?) System V Curses; they could
also be quite different from BSD Curses. One problem I noted with
Ultrix Curses is that only one highlighting mode is supported.

Joel Spolsky             bitnet: spolsky@yalecs     uucp: ...!yale!spolsky
Yale University          arpa:   spolsky@yale.edu   voicenet: 203-436-1483
"You can't expect to wield supreme executive power just 'cause 
some watery tart threw a sword at you!!"

predict@charon.unm.edu (Andrew R. Large) (09/19/88)

In article <...> spolsky-avram@CS.YALE.EDU (Joel Spolsky) writes:
>In article <...> Peter_Cutting@newcastle.ac.uk (P. G. Cutting) writes:
>| 
>| [ ... problems with Ultrix curses when 4.3 works fine ...]
>
>I also noticed that Ultrix Curses were weird. I am sure that Ultrix
>Curses are very different than (from?) System V Curses; they could
>also be quite different from BSD Curses. One problem I noted with
>Ultrix Curses is that only one highlighting mode is supported.
>

In porting sc (the Spreadsheet Calculator from comp.sources.unix) to
Ultrix some time back, I ran across a problem with the nonl() function.
Ultrix seems to have problems outputting things correctly when CR-LF
mapping isn't done.  If you have any calls to nonl(), try taking them
out and see if it does the trick.

Only one highlighting mode?  You mean there is more than one way to do reverse
video?  Or are you talking about another attribute (like bold text)?

-- Andy

-- 

 -=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
   *                          Andrew R. Large                              *
  **  (work) 505/255-8611 ------|     Univ of New Mexico EECE Department   **
 ***  (home) 505/888-4010       |---> Management Sciences, Inc. [MSI]      ***
****                            _Babooshka!_                               ****
 ***  Usenet: {convex,gatech,ucbvax,csu-cs,anl-mcs}!unmvax!charon!predict  ***
  **  Internet: predict@charon.UNM.EDU                                     **
   *          If I am quoted, my employers will deny my existence.         *
 -=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

jpn@teddy.UUCP (John P. Nelson) (09/23/88)

| I wrote a simple windowing system using Curses on a 4.3 machine. Eventually
| it worked but now when I recompile it and run it on an Ultrix machine the 
| windows get messed up. I have checked Termcap entries and STTY entries which
| seem OK, and so I conclude that there are differences between Curses on the
| two machines. Can any one back up this conclusion and maybe suggest where the
| problem might be.

The Ultrix "curses.h" has a bug in the definition of the nl() and nonl()
functions.  In fact, the header has comments showing how some dec programmer
"fixed" it (it's quite clear he didn't understand it).  I have reported this
bug to DEC for every release since 1.1.  It's STILL broken in 3.0!

Dec defines the macros this way:

#define nl()	(_tty.sg_flags |= CRMOD,_pfast = _rawmode,NONL = 0,stty(_tty_ch, &_tty))
#define nonl()	(_tty.sg_flags &= ~CRMOD, _pfast = TRUE, NONL = 1,stty(_tty_ch, &_tty))

However, they SHOULD be defined as:

#define nl()	(_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty))
#define nonl()	(_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty))
-- 
     john nelson

UUCP:	{decvax,mit-eddie}!genrad!teddy!jpn
smail:	jpn@teddy.genrad.com

terry@wsccs.UUCP (Every system needs one) (09/24/88)

In article <38132@yale-celray.yale.UUCP>, spolsky-avram@CS.YALE.EDU (Joel Spolsky) writes:
> In article <3711@cheviot.newcastle.ac.uk> Peter_Cutting@newcastle.ac.uk (P. G. Cutting) writes:
> | 
> | I wrote a simple windowing system using Curses on a 4.3 machine. Eventually
> | it worked but now when I recompile it and run it on an Ultrix machine the 
> | windows get messed up. I have checked Termcap entries and STTY entries which
> | seem OK, and so I conclude that there are differences between Curses on the
> | two machines. Can any one back up this conclusion and maybe suggest where the
> | problem might be.
> 
> I also noticed that Ultrix Curses were weird. I am sure that Ultrix
> Curses are very different than (from?) System V Curses; they could
> also be quite different from BSD Curses. One problem I noted with
> Ultrix Curses is that only one highlighting mode is supported.
> 
> Joel Spolsky             bitnet: spolsky@yalecs     uucp: ...!yale!spolsky
> Yale University          arpa:   spolsky@yale.edu   voicenet: 203-436-1483
> "You can't expect to wield supreme executive power just 'cause 
> some watery tart threw a sword at you!!"

Use '-lcurses' instead of '-ltermcap' to get the additional highlighting
modes... this, of course, assumes you have good /usr/lib/terminfo/*
entries, an unlikely event, especially if you have televideo/wyse/liberty
hardware.

If you are using VTxxx terminals, use the '-nam' version.  ALL curses have
a well known bug with AM and XN terminals.  The assumption that a linefeed
is ignored after a carriage return is good enough to cause "vi" to work,
but is certainly not the way the things work.  VTxxx series terminals do
NOT "ignore the LF"; instead, they wrap before character 81, not after
character 80.  The assumption built into curses is that AM:XN terminals
do not work this way.

In the long run, you are better off writing your own system, especially
if you expect your program to be commercially viable.

A number of companies have taken this to exteremes, however, and have
rewritten the entire termcap/termlib concept and come up with their
own files (Wordperfect and Microsoft Word spring to mind).  This is
generally a bad approach, as debug time becomes nearly infinite unless
you own every terminal you run on.  Since it is unrealistic to expect
your end users to consult you prior to buying equipment, or to ignore
you if you recommend more expensive equipment, you lose.

A less extreme, but, IMHO, equally bogus approach is to include your own
termcap file.  This gets rid of all problems on equipment you own, and
allows you to update entries "borrowed" from someone else's unmodified
termcap, but eventually you will pay the same in technical support.
Besides, the assumption that all curses systems are created equal is valid.

To the first poster:  perhaps you need to flush your output file descriptors,
especially if you've duplicated them and are using more than one to talk to
the same device (frequntly done in initial home-brew window systems); you
are not guaranteed a particular flushing order unless you forcibly flush
your buffers or use on fd.  Flushing under BSD should be done anyway
(unless you set your output buffer way down, effectively flushing after
each write) to allow the system to do a single blocked writei() at the
kernel level -- much more efficient, and you'll look faster.


| Terry Lambert           UUCP: ...{ decvax, ihnp4 } ...utah-cs!century!terry |
| @ Century Software        OR: ...utah-cs!uplherc!sp7040!obie!wsccs!terry    |
| SLC, Utah                                                                   |
|                   These opinions are not my companies, but if you find them |
|                   useful, send a $20.00 donation to Brisbane Australia...   |
|                   'I have an eight user poetic liscence' - me               |