contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.39k stars 101 forks source link

TERM variable in default-config is ignored #1599

Open herrhotzenplotz opened 5 days ago

herrhotzenplotz commented 5 days ago

When I use a default-generated config file the declared TERM environment variable is ignored. This manifests in that whenever one launches contour TERM is set to vt100.

I built contour through my FreeBSD Port at https://github.com/herrhotzenplotz/ports-overlay/tree/master/x11/contour/.

Yaraslaut commented 5 days ago

What happens when you do export TERM=contour inside the shell? Also, we are trying to set TERM to contour while starting terminal, so maybe terminfo file is missing, and exort TERM=contour will tell you about it

herrhotzenplotz commented 5 days ago

What happens when you do export TERM=contour inside the shell?

Of course that works. It's just annoying that everytime I use an ncurses application it starts up in black/white and scrolling in less(1) is dead-slow. Then you quit said application, update your environment and start over.

Also, we are trying to set TERM to contour while starting terminal, so maybe terminfo file is missing

the terminfo is installed correctly:

nico@hades:~ $ find /usr/local/share/terminfo/
/usr/local/share/terminfo/
/usr/local/share/terminfo/c
/usr/local/share/terminfo/c/contour
/usr/local/share/terminfo/c/contour-latest
nico@hades:~ $ 

and exort TERM=contour will tell you about it

running export TERM=... will tell you nothing. It just sets the shell variable and then exports it to the environment. Unless this is something shell/OS-specific.

Yaraslaut commented 5 days ago

Thanks @herrhotzenplotz, will try to figure out what is happening

When you export TERM, shell checks if you can set it

➜  ~ export TERM=asdfasdf
zsh: can't find terminal definition for asdfasdf
herrhotzenplotz commented 5 days ago

You're assuming that I am using zsh. However I am using FreeBSD's /bin/sh (which itself is an enhanced version of ash).

Yaraslaut commented 5 days ago

You're assuming that I am using zsh. However I am using FreeBSD's /bin/sh (which itself is an enhanced version of ash).

oh, right, i forgot that this is only zsh implementation

herrhotzenplotz commented 4 days ago

Ok, after some debugging and reading I figured out that the problem is that contour has a hardcoded terminfo search path for /usr/share/terminfo. It completely ignores its installation prefix which is where the CMakeLists.txt outputs the compiled terminfo file. So, rather looking for /usr/share/terminfo (which doesn't even exist on FreeBSD) it should be looking in ${PREFIX}/share/terminfo. This will also fix the problem on other BSDs.

Yaraslaut commented 4 days ago

This is from man tic

       Libraries that read terminfo entries are expected to check in succession

       •   a location specified with the TERMINFO environment variable,

       •   $HOME/.terminfo,

       •   directories listed in the TERMINFO_DIRS environment variable,

       •   a compiled-in list of directories (/usr/share/terminfo), and

       •   the system terminfo database (/usr/share/terminfo).

If you have a custom path for terminfo files add it into TERMINFO_DIRS

herrhotzenplotz commented 4 days ago

If you have a custom path for terminfo files add it into TERMINFO_DIRS

It is not a custom path. The manual page you're looking at is generated at the build time of ncurses. Here I get the following:

       The results are normally placed in the system terminfo database
       /usr/local/share/terminfo.  The compiled terminal description can be
       placed in a different terminfo database.  There are two ways to achieve
       this:

       •   First, you may override the system default either by using the -o
           option, or by setting the variable TERMINFO in your shell
           environment to a valid database location.

       •   Secondly, if tic cannot write in /usr/local/share/terminfo or the
           location specified using your TERMINFO variable, it looks for the
           directory $HOME/.terminfo (or hashed database $HOME/.terminfo.db);
           if that location exists, the entry is placed there.

       Libraries that read terminfo entries are expected to check in
       succession

       •   a location specified with the TERMINFO environment variable,

       •   $HOME/.terminfo,

       •   directories listed in the TERMINFO_DIRS environment variable,

       •   a compiled-in list of directories
           (/usr/local/share/terminfo:/usr/local/share/site-terminfo), and

       •   the system terminfo database (/usr/local/share/terminfo).

       The Fetching Compiled Descriptions section in the terminfo(5) manual
       goes into further detail.

(this is from the man page installed from ports)

Linux systems generally dump everything in /usr. *BSD-Systems among other Unix systems split out things under different prefixes for some neat seperation. As for FreeBSD, ports and binary packages are installed in /usr/local, on NetBSD pkgsrc typically installs into /usr/pkg.

Every terminal emulator in ports (that I use and have used) installs its terminfo files under $PREFIX/share/terminfo and it works flawlessly.

Note that there is also a system-provided tic in /usr/bin/tic and it has the same paths as you noted above. However since we're building contour as a package we want the terminfo not to leak outside the prefix and it should thus be installed in /usr/local/share/terminfo and contour should, just like any other terminal emulator, look there.

Yaraslaut commented 4 days ago

Will it be sufficient then if we add /usr/local/share/terminfo in one of the possible locations of terminfo ?