conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.22k stars 979 forks source link

[bug] Conan is unusable on white terminal theme (default for Gnome terminal, etc) #12891

Open lpapp opened 1 year ago

lpapp commented 1 year ago

Environment details

Steps to reproduce

  1. Run conan search boost/1.76@ or something similar.

Screenshot 2023-01-11 at 16 44 51

See the yellow and grey characters.

I have been using this setup for years, but I have never encountered any issues with any other commands, not even a wide variety of vim syntax highlighting for various languages. I think those two colours should be adjusted for conan.

It is pretty much a blocker for usability.

Logs

No response

memsharded commented 1 year ago

There is an env-var CONAN_COLOR_DARK you can set to change the color scheme. It is also possible to disable color with NO_COLOR env-var.

Please try that and let us know. If there is some robust multi-platform way to detect background color from Python it would be fantastic to know it, so this is not necessary.

lpapp commented 1 year ago

Thanks.

I changed gnome-terminal to dark background as a quick workaround.

There must be a way since other programmers have not suffered from this in my experience. E.g. vim syntax highlighting may need to work with many colours for certain languages, but I have never found it unreadable.

memsharded commented 1 year ago

There must be a way since other programmers have not suffered from this in my experience. E.g. vim syntax highlighting may need to work with many colours for certain languages, but I have never found it unreadable

Yes, but such programs also typically operate at a lower OS level, it might be a bit easier to obtain that than from Python. I have checked a bit possibilities to auto-detect terminal background and it seems pretty challenging...

SSE4 commented 1 year ago

Thanks.

I changed gnome-terminal to dark background as a quick workaround.

There must be a way since other programmers have not suffered from this in my experience. E.g. vim syntax highlighting may need to work with many colours for certain languages, but I have never found it unreadable.

vim suffers from the same issue from my personal experience, I had to put set background=dark to my ~/.vimrc many times.

there could be some ways to detect dark modes via python, e.g.:

import subprocess

def detectDarkModeGnome():
    '''Detects dark mode in GNOME'''
    getArgs = ['gsettings', 'get', 'org.gnome.desktop.interface', 'gtk-theme']

    currentTheme = subprocess.run(
        getArgs, capture_output=True
    ).stdout.decode("utf-8").strip().strip("'")

    darkIndicator = '-dark'
    if currentTheme.endswith(darkIndicator):
        return True
    return False

but I don't think they all are reliable, as there are hundreds of various terminals and desktop systems on Linux. even on Windows, there is a variety of terminal, and having dark theme activates as Windows theme doesn't necessarily mean terminal uses dark theme as well.

lpapp commented 1 year ago

Do you have concrete reproduction steps for vim? I could try. I have personally never noticed unreadable characters with this theme in vim for C++ and Python, at least.

I did notice that vim at least did not pick these colours, but more like orange / amber instead of yellow, etc. Maybe, conan could match more vim's colour selection as they have proven over the decades?

SSE4 commented 1 year ago

Do you have concrete reproduction steps for vim? I could try. I have personally never noticed unreadable characters with this theme in vim for C++ and Python, at least.

right now, out of my mind, no, but I can post as soon as it happens again. I remember it happened over SSH for sure.

Paultergeist commented 1 year ago

Do you have concrete reproduction steps for vim?

If you run Vim with set background=light in dark terminal or with set background=dark in light terminal you'll get improper selection of colors. In my case if I do set bg& (set default value) it guesses wrong and sets bg=light. After that the text is hard to read and in diff mode it's literally eye bleed. bg=light diff in dark terminal:

image

bg=light in dark terminal:

image

bg=dark in light terminal:

image

bg=dark in dark terminal:

image

Have you tried CONAN_COLOR_DARK? It should work fine in your light terminal.

image
sztomi commented 6 months ago

The workaround works, but maybe the usage of color in conan could be reconsidered at this point. I'm not suggesting not to use color at all, but maybe turn the knob down a bit: use fewer colors that work in both dark and light terminals; simply highlight fewer things. Typography (in this context: special characters) and spacing can be used to distinguish conan's own output where important. Highlighting less would be especially helpful in my opinion. If everything is highlighted, nothing is distinguished. For example, from the above screenshot I'd argue that there is little benefit to coloring every little thing.

memsharded commented 6 months ago

Conan 2 output has already improved over the output, with more spacing and characters highlights like:

======== Installing packages ========

And more indenting and structure:

 zstd
    zstd/1.5.5
      revisions
        b87dc3b185caa4b122979ac4ae8ef7e8 (2023-11-03 21:26:49 UTC)
          packages
            c60581f2463ba21c248b22570dc9f7e6dcb636f7
              info
                settings
                  arch: x86_64
                  build_type: Release
                  compiler: msvc
                  compiler.runtime: dynamic
                  compiler.runtime_type: Release
                  compiler.version: 193
                  os: Windows
                options
                  build_programs: True
                  shared: False
                  threading: True

which will help with clarity even when colors are disabled

I agree that having something that would work both in dark and light terminals would be great. This is some colored output:

image

image

This is without changing anything, exact same colors, with a cmder "tomorrow" color-scheme terminal. And we kind of like it, it is not that everything is highlighted, and it is nice to have the colors, we think they help in general more than not having them. And it seems that modern terminals can do a good job printing those colors.

It is true that other terminals will not produce same nice view, but also if we have to drop yellow, green, cyan and grey, which are problematic in those terminals, and given that red is only typically used for errors, that leaves a much reduced palette for everyone, not sure if it is better.