Re: tmux-direct entry only has 8 colors

2024-03-13 Thread Thomas Klausner
On Wed, Jan 31, 2024 at 10:31:41PM +0100, Thomas Klausner wrote:
> I've tried to get my terminal+tmux to display true colors today using
> the latest terminfo as imported to NetBSD.

I debugged this a bit further.  It works fine if I just use two
entries, but as soon as a third in the style of kitty+setal is added,
it breaks.


--- terminfotest2 ---
kitty+setal|set underline colors (nonstandard),
setal=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm,

minfirst|TermInfo Test,
# if the second number is >32767, it disappears!
   use=min, use=max,
maxfirst|TermInfo Test,
# putting the bigger one first makes "promotion" happen.
   use=max, use=min,

max|any number > INT16_MAX,
   colors#16777216,

min|any num < INT16_MAX,
   colors#8,

kittymin|kitty+min,
use=kitty+setal, use=min, use=max
kittymax|kitty+max,
use=kitty+setal, use=max, use=min
--- end of terminfotest2 ---

> tic -x terminfotest2

> infocmp -1x -A /home/wiz/terminfotest2.cdb minfirst
# Reconstructed from /home/wiz/terminfotest2.cdb
minfirst|TermInfo Test,
colors#8,
> infocmp -1x -A /home/wiz/terminfotest2.cdb maxfirst
# Reconstructed from /home/wiz/terminfotest2.cdb
maxfirst|TermInfo Test,
colors#16777216,

Here you can see the first encountered definition wins.

> infocmp -1x -A /home/wiz/terminfotest2.cdb kittymin
# Reconstructed from /home/wiz/terminfotest2.cdb
kittymin|kitty+min,
colors#8,
setal=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm,
> infocmp -1x -A /home/wiz/terminfotest2.cdb kittymax
# Reconstructed from /home/wiz/terminfotest2.cdb
kittymax|kitty+max,
colors#8,
setal=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm,

but here it doesn't any longer, or kitty+setal's non-definition counts
as an colors#8?

I've filed PR 58034 for this. Roy, Christos, can either of you please
take a look?

Thanks,
 Thomas


Re: tmux-direct entry only has 8 colors

2024-02-02 Thread RVP

On Thu, 1 Feb 2024, RVP wrote:


 (xterm-direct analyzed this way also only reports

 xterm-direct|xterm with direct-color indexing,
 ...
colors#0x7fff, cols#80, it#8, lines#24, pairs#0x7fff,
 ...
) 



Same bug, I think: if any num. capability has a value >0x7fff
(INT16_MAX), then that terminfo entry should get "promoted" to use
32-bit integers. This isn't happening.



... is what I said, but, that's not right. Since this output is from
the _ncurses infocmp_ rather than the BSD one, that clamping is expected,
(so Tom Dickey told me), when ncurses isn't compiled with `--enable-widec'.

You can see this happening when you install ncurses:

```
$ make install
[...]
/bin/sh ./run_tic.sh
** Building terminfo database, please wait...
Running sh ../../ncurses-6.4/misc/shlib tic to install /tmp/N/share/terminfo ...

You may see messages regarding extended capabilities, e.g., AX.
These are extended terminal capabilities which are compiled
using
tic -x
If you have ncurses 4.2 applications, you should read the INSTALL
document, and install the terminfo without the -x option.

ncurses 6.4.20221231
"terminfo.tmp", line 1232, col 36, terminal 'fbterm': limiting value of `pairs' 
from 0x1 to 0x7fff
"terminfo.tmp", line 5326, col 36, terminal 'xterm+256color': limiting value of 
`pairs' from 0x1 to 0x7fff
"terminfo.tmp", line 5358, col 36, terminal 'xterm+256setaf': limiting value of 
`pairs' from 0x1 to 0x7fff
"terminfo.tmp", line 5405, col 25, terminal 'xterm+direct2': limiting value of 
`colors' from 0x100 to 0x7fff
"terminfo.tmp", line 5405, col 40, terminal 'xterm+direct2': limiting value of 
`pairs' from 0x1 to 0x7fff
"terminfo.tmp", line 5420, col 25, terminal 'xterm+direct': limiting value of 
`colors' from 0x100 to 0x7fff
"terminfo.tmp", line 5420, col 40, terminal 'xterm+direct': limiting value of 
`pairs' from 0x1 to 0x7fff
"terminfo.tmp", line 5442, col 25, terminal 'xterm+indirect': limiting value of 
`colors' from 0x100 to 0x7fff
"terminfo.tmp", line 5442, col 40, terminal 'xterm+indirect': limiting value of 
`pairs' from 0x1 to 0x7fff
"terminfo.tmp", line 8597, col 36, terminal 'dvtm-256color': limiting value of 
`pairs' from 0x1 to 0x7fff
1814 entries written to /tmp/N/share/terminfo
[...]
$
```

Sorry for the mixup!

-RVP


Re: tmux-direct entry only has 8 colors

2024-02-02 Thread RVP

On Thu, 1 Feb 2024, Martin Husemann wrote:


This is fallout from usr.bin/tic.c:

--
revision 1.33
date: 2020-03-27 16:11:57 +0100;  author: christos;  state: Exp;  lines: +21 
-17;  commitid: 2Q6C4aNTDvrFf32C;
As described in tech-userlevel:
- Store new format entries as @v3
- Lookup first @v3 and then  if that is not found.



... is what the log says, but, what's actually stored is `,v3`:

```
$ fgrep -q @v3 /usr/share/misc/terminfo.cdb || echo not found
not found
$ fgrep -q ,v3 /usr/share/misc/terminfo.cdb && echo found
found
$
```

-RVP


Re: tmux-direct entry only has 8 colors

2024-02-01 Thread Martin Husemann
On Thu, Feb 01, 2024 at 03:13:42PM +, RVP wrote:
> This looks like a bug in NetBSD. Minimal reproducer:
> 
> ```
> $ cat tit
> tit|TermInfo Test,
> # if the second number is >32767, it disappears!
> use=num, use=max,
> # putting the bigger one first makes "promotion" happen.
> #   use=max, use=num,
> 
> max|any number > INT16_MAX,
> colors#32768,
> 
> num|any num < INT16_MAX,
> num#111,
> 
> $ tic -x tit

This is fallout from usr.bin/tic.c:

--
revision 1.33
date: 2020-03-27 16:11:57 +0100;  author: christos;  state: Exp;  lines: +21 
-17;  commitid: 2Q6C4aNTDvrFf32C;
As described in tech-userlevel:
- Modify the writing code to only write entries in the new
  format for the terminal descriptions that require it.
- Store new format entries as @v3
- Store old format entries with clamped values as  for
  backwards compatibility
- Lookup first @v3 and then  if that is not found.
- Don't create terminfo2 anymore; old programs keep working with
  clamped entries, and new programs be able to use the wide
  fields with using the original db file.
--

especially this part of process_entry:

if (tic->rtype == TERMINFO_RTYPE)
return process_entry(, flags | TIC_COMPAT_V1);


but I don't understand how it is supposed to work.

Martin


Re: tmux-direct entry only has 8 colors

2024-02-01 Thread RVP

On Wed, 31 Jan 2024, Thomas Klausner wrote:


infocmp kitty+setal

kitty+setal|set underline colors (nonstandard),

Compare that to terminfo.src:

kitty+setal|set underline colors (nonstandard),
   setal=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1
 %{255}%&%dm,

Seems like NetBSD's infocmp (or terminfo) doesn't support setal,
sounds like a bug.



You have to use `infocmp -x' to see "extra" capabilities like `setal'.


Again, a couple things seem to get lost (RGB, CO#8, initc@, setb@,
setf@) but the colors are there.



Ditto.


I looked at the 'use' and some of them are empty (which makes me think
NetBSD's infocmp or terminfo are missing more features) and then I
found:

# Reconstructed from /usr/share/misc/terminfo.cdb
screen|VT 100/ANSI X3.64 virtual terminal,
   am, km, mir, msgr, xenl,
   colors#8, cols#80, it#8, lines#24, pairs#64,
...

So it looks to me like the 'colors' from the 'screen' entry via the
'tmux' entry overwrite the colors defined by 'xterm+direct'.



This looks like a bug in NetBSD. Minimal reproducer:

```
$ cat tit
tit|TermInfo Test,
# if the second number is >32767, it disappears!
use=num, use=max,
# putting the bigger one first makes "promotion" happen.
#   use=max, use=num,

max|any number > INT16_MAX,
colors#32768,

num|any num < INT16_MAX,
num#111,

$ tic -x tit

$ infocmp -1x -A /tmp/tit.cdb tit
# Reconstructed from /tmp/tit.cdb
tit|TermInfo Test,
num#111,

$ /opt/ncurses/bin/tic -x -o tit.d tit

$ /opt/ncurses/bin/infocmp -1x -A tit.d tit
#   Reconstructed via infocmp from file: tit.d/t/tit
tit|TermInfo Test,
colors#0x8000,
num#111,

$
```


(xterm-direct analyzed this way also only reports

xterm-direct|xterm with direct-color indexing,
...
   colors#0x7fff, cols#80, it#8, lines#24, pairs#0x7fff,
...
)



Same bug, I think: if any num. capability has a value >0x7fff
(INT16_MAX), then that terminfo entry should get "promoted" to use
32-bit integers. This isn't happening.


Then it'd be time for a bug report...



Yes :)

-RVP