Lf: colors not working properly

Created on 19 Sep 2020  ยท  6Comments  ยท  Source: gokcehan/lf

If I set TCELL_TRUECOLOR=on
chafa will generate 24-bit fake image previews in lf which is great, but a side effect is that
basic 8 colors will not be as I define them in my terminal (which is st).
Instead they will be much dimmer, making lf not so contrastful as I would like it, and I can't figure out how to properly set those
as I don't know why they are being set so in the first place.
For the files, I can set 24-bit color escape sequences in LS_COLORS but I can't do that for the previewer,
nor for lf's marks on files (selection/copy/cut).

question

All 6 comments

@lucas-mior To be honest, I don't know much about this either. What program do you use in your previewer to color the output? Maybe there is an option to output true colors?

Unfortunately selection/copy/cut colors are not configurable at the moment.

I think the issue is not that the previewer can't output true colors, nor that I wish to change selection/copy/cut colors.
It seems that for whaterver reason, lf (or maybe tcell) overrides my 8 basic colors (color pallete) that I set via my terminal (colors 0-7) and when the previewer calls for those colors, they show weirdly.
I say that because I have some preview scripts that use some ANSI escape sequences to print colored output on the preview pane.
For instance:
printf "\033[31m red output" called from the previewer
will print red output in a very dim red, although in the shell using the same terminal it will correctly print using the red I defined as color 1 (which is #ff0000, a bright red).

@lucas-mior Color escape codes are not printed to the terminal directly, but instead parsed by lf to be converted to tcell styles. That is why you see a difference in your shell and preview pane. But I think the underlying problem is tcell specific. Tcell readme states:

When using TrueColor, programs will display the colors that the programmer intended, overriding any โ€œthemesโ€ you may have set in your terminal emulator. (For some cases, accurate color fidelity is more important than respecting themes. For other cases, such as typical text apps that only use a few colors, its more desirable to respect the themes that the user has established.)

The question is whether it is possible for tcell to keep the theme as it is and also support true color at the same time. It is an interesting question but unfortunately I don't know the answer to that. I feel like it should be possible but I don't know if there is a technical limitation for this. Also note that there is an ongoing version 2.0 development in tcell and I think there are color related changes so maybe things might change in this next version.

cc @Provessor

@gokcehan @lucas-mior I opened an issue at tcell about it and it is already implemented in v2. I've thought about hacking a solution together so lf won't parse the colours and instead just strip bad escape sequences from the output but never did anything about it. Mostly because the default behaviour is the same as the termbox backend.

I have done a bit of work on a v2 port which mostly works (except colors_test.go needs another rewrite) but haven't done anything serious about it yet.

Not sure whether this is related, I just upgraded to master and my LS_COLORS variable no longer seems to have any affect. Everything is just monochrome (background is black, foreground is white) except line numbers which are yellow. I'm running inside tmux and my TERM is set to screen-256color. I see the docs mention your terminal should end with truecolor and I tried setting it to screen-truecolor but then lf crashed.

zsh: can't find terminal definition for xterm-truecolor
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xa48 pc=0x50ef2f]

goroutine 1 [running]:
github.com/gdamore/tcell/terminfo.LookupTerminfo(0xc000018345, 0xf, 0xc000018345, 0xf, 0x63ac7b)
    /home/mohkale/programming/.modules/go/src/github.com/gdamore/tcell/terminfo/terminfo.go:743 +0x10f
github.com/gdamore/tcell.NewTerminfoScreen(0xc0000cbd90, 0x7b7ef0, 0x64a8a0, 0xc0000cbd90)
    /home/mohkale/programming/.modules/go/src/github.com/gdamore/tcell/tscreen.go:44 +0x65
github.com/gdamore/tcell.NewScreen(0x8, 0x63ac7b, 0x1, 0x0)
    /home/mohkale/programming/.modules/go/src/github.com/gdamore/tcell/screen.go:208 +0x25
main.run()
    /home/mohkale/programming/.modules/go/src/github.com/gokcehan/lf/client.go:19 +0x4e
main.main()
    /home/mohkale/programming/.modules/go/src/github.com/gokcehan/lf/main.go:269 +0xbb8

Running TCELL_TRUECOLOR=on lf doesn't seem to change this. Is there a reason the color256 options was depreciated. I didn't mind using it at all.

@mohkale You are probably looking for #460

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ipstone picture ipstone  ยท  6Comments

BachoSeven picture BachoSeven  ยท  9Comments

wheatdog picture wheatdog  ยท  6Comments

muellerto picture muellerto  ยท  8Comments

johnhk picture johnhk  ยท  8Comments