Subject: please allow for specifying more than one terminal type

From: Wouter Verhelst <[email-masked]>
Date: Sun, 19 Mar 2006 12:45:08 +0100

Package: ncurses
Severity: wishlist

Hi,

I'm currently using rxvt-unicode as my primary x-terminal-emulator, as
it has exactly those features I need, and nothing more. I love it,
except for one thing... it's rather new(ish), and many hosts do not have
a termcap entry for it yet. As a result, ncurses fails to initialize in
most cases--and those programs that do work do so by assuming I have
vt100 or something, which is horrible.

It'd be nice if I could say something along the lines of "I'm really
working from rxvt-unicode; but if you don't know that, then you can use
a generic xterm termcap entry, which for all practical matters is really
the same thing". Something like

TERM=rxvt-unicode:xterm

would be great. I didn't see whether something like that is available by
looking at the docs that I found, but perhaps I missed it; in that case,
a pointer would be nice ;-)

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: powerpc (ppc)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15.6
Locale: LANG=nl_BE.UTF-8@euro, LC_CTYPE=nl_BE.UTF-8@euro (charmap=UTF-8)

---

From: Thomas Dickey <[email-masked]>
Date: Sun, 19 Mar 2006 08:49:20 -0500 (EST)

> Severity: wishlist

This is a bug in rxvt-unicode rather than ncurses.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

---

From: Daniel Jacobowitz <[email-masked]>
Date: Sun, 19 Mar 2006 11:33:22 -0500

> This is a bug in rxvt-unicode rather than ncurses.

Huh?  How?

1.  Open rxvt-unicode on host A.  This host has rxvt-unicode
    installed, and presumably has a termcap entry for it.
2.  SSH to host B.  This older host does not.

Wouter wants host B to see a value in $TERM that can fall back to
xterm, if I understand right.

Obviously this wouldn't be helpful for years...

-- 
Daniel Jacobowitz
CodeSourcery

---

From: Thomas Dickey <[email-masked]>
Date: Sun, 19 Mar 2006 11:52:13 -0500 (EST)

> 2.  SSH to host B.  This older host does not.

For this case, we can't solve his problem (simply because differences in 
function keys, etc., mean there is in general no well-defined subset to 
fall back to).

For the usual case (fallback to existing values) it's certainly doable 
since xterm does _that_.

---

From: Daniel Jacobowitz <[email-masked]>
Date: Sun, 19 Mar 2006 12:07:04 -0500

> For the usual case (fallback to existing values) it's certainly doable 

Sorry, you've totally lost me.

This is about the TERM value set by the terminal emulator, for maximum
compatibility across multiple hosts, including hosts other than the one
on which it is running.  How can rxvt-unicode - or xterm - do anything
about that?

I'd love to be able to set "TERMLIST=screen;vt100" and have some smart
curses library go "I don't know what screen is, but here, have a
vt100".

-- 
Daniel Jacobowitz
CodeSourcery

---

From: Wouter Verhelst <[email-masked]>
Date: Sun, 19 Mar 2006 18:21:23 +0100

> xterm, if I understand right.

Yes, you do.

> Obviously this wouldn't be helpful for years...

Obviously.

-- 
Fun will now commence
  -- Seven Of Nine, "Ashes to Ashes", stardate 53679.4

---

From: Thomas Dickey <[email-masked]>
Date: Sun, 19 Mar 2006 12:27:07 -0500 (EST)

> on which it is running.  How can rxvt-unicode - or xterm - do anything

nothing - right now I'm using HPUX on one of my windows.  Changing ncurses
wouldn't help there.

> curses library go "I don't know what screen is, but here, have a

I don't know - what comes to my mind is the repeated scenario of the
gnome-terminal, etc., users complaining that ncurses must have bugs
because it's supposed to be "xterm" and isn't working just like xterm.

---

From: Wouter Verhelst <[email-masked]>
Date: Sun, 19 Mar 2006 18:30:06 +0100

> function keys, etc., mean there is in general no well-defined subset to 

Sure; however, my experience is that most terminal emulators support at
least a useful subset of xterm. The fact that they don't map 100% is
precisely the reason why I don't want to go ahead and say TERM=xterm
everywhere. However, if I log in to a host where rxvt-unicode isn't in
termcap (or whatever), it'd be great if ncurses could just walk some
environment variable until it finds a name that it does, in fact, know.

That can't be done currently, which means that every time I log in to a
host that does not have an rxvt-unicode termcap entry, I need to say
"export TERM=xterm", or I get stuff like

wouter@pop:~$ top
'rxvt-unicode': unknown terminal type.
wouter@pop:~$ 

Other applications, like 'less' and 'vim', do give me some full-screen
interface, but one that doesn't do proper scrolling, colors, or anything
similar.

> For the usual case (fallback to existing values) it's certainly doable 

That's very nice, but not very useful. It's not the terminal emulator
that needs to fall back, it's the ncurses-using application that would
need to do so.

---

From: Thomas Dickey <[email-masked]>
Date: Sun, 19 Mar 2006 12:49:33 -0500 (EST)

> environment variable until it finds a name that it does, in fact, know.

Stuff like this (in your .login) is already portable, works on every
unix platform.

#!/bin/sh
for name in foo bar xterm
do
         if ( tput -T$name am 2>/dev/null )
         then
                 echo ok $name
         fi
done

---

From: Wouter Verhelst <[email-masked]>
Date: Mon, 20 Mar 2006 09:07:29 +0100

>         if ( tput -T$name am 2>/dev/null )

Yes; but if I then change my terminal (temporarily or permanently), it
does break.

---

From: Thomas Dickey <[email-masked]>
Date: Mon, 20 Mar 2006 04:40:38 -0500 (EST)

> Yes; but if I then change my terminal (temporarily or permanently), it

not under the same assumptions that your suggestion requires.

---

From: Daniel Jacobowitz <[email-masked]>
Date: Mon, 20 Mar 2006 08:47:49 -0500

> Yes; but if I then change my terminal (temporarily or permanently), it

Certainly you can get around that.

if test "$TERM" = dtterm || "$TERM" = rxvt-unicode; then
  if ( tput -T$name am 2>/dev/null ); then
    :
  elif (tput -Txterm am 2>/dev/null ); then
    TERM=xterm
  fi
fi

And so on.

-- 
Daniel Jacobowitz
CodeSourcery