-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prompt is printed with SGR 40, resulting in black bands on supporting terminals #2516
Comments
What about the green text? Using "revert default background" would cause the green text to be invisible when the background is green. I'm pretty sure that's why an explicit background color is used by default. Instead of changing the default, maybe it would be better to make it more easily configurable. |
That's a fair point, of course. 😄 |
I use green background in some console Windows. Why would it be "unexpected" for users to make choices about how they will use colors? Programs are not the only things allowed to choose colors. I think it's a mistake to label it as officially "unexpected" and therefore "unsupported". If a program makes it easily configurable, then ok, maybe the program can make assumptions since it lets the user override the configuration. That's why I suggested an effective solution could be to make it configurable. It is not currently configurable in Cmder (without editing Cmder scripts, which will be overwritten by the next update). |
I don’t really have a stake in what Cmder does. Personally, I prefer to use ConEmu directly and have my own script for setting up my command windows.† But in the relatively short time I’ve been working on Clink, I’ve seen several requests for Cmder to allow easy configuration of the lambda, and colors, etc. If Cmder makes the color and lambda character configurable, then it would seem very reasonable to use SGR 49, since the configurability would enable a user to change the green text color if they want to use a green background for the whole console. † (Actually I prefer to just use the default console window support in the OS -- I might use Windows Terminal, except that it doesn't seem to let me set the font, and I want to use Consolas NF or Fira Code NF.) |
I think for now we can add a little note to the wiki page where we detail how to setup the prompt for windows terminal and detail how to fix this and probably add a reference to this issue. |
Note that the SGR 40 is also used for Git status (Line 305) and for mercurial status (Line 350). I think that if the promt color is changed to another value than 40 (or made editable), git status and mercurial status should be edited in the same way. |
Is there a way to check the terminal at startup and set it according to that? |
Check for what, and set what? |
I'm not really sure how I could contribute and fix this issue on the main branch because I didn't manage to build the project in Visual Studio. However, if anyone is trying to fix this issue then you can create a file called
|
The values, so 40 if it's a legacy terminal and 49 if it's a terminal that supports extended/ custom backgrounds. |
How does one check what terminal system might be hosting it behind the scenes, and what settings are in effect in that terminal system that could be relevant? Also, I think the issue is about contrast between "current background color" vs "current foreground color". That's why 40 is used instead of 49. Since there's not a reliable way to check what terminal is being used or what settings are in effect for it, typically it's left as something for the user to configure. Since if the background is solid green, or a photo, both those are things the user had to configure. And they were given an easy way to configure them. So, it seems reasonable to continue with the existing model, and make Cmder have an easy way to configure the prompt colors instead of hard-coding them to 40 or 49. |
Using something like this: While it can be useful, it would really slow down the startup so, I think the best way would just be declaring another prompt by the user in a lua, which would give really good customization and control. It can also go another way and allow the config to be written/read from a file. |
In fact, Clink does something similar internally; see clink.getansihost() in Clink's Lua API. It's super fast in native code. But the result isn't fully reliable. The cited script detects some terminals. It doesn't detect their capabilities or configuration. The script can make some guesses, but it can't achieve a reliable answer. Here are some of the unreliable points:
I agree. At the same time, it seems to be a common point of user feedback. That makes me wonder if it might save user frustration and might save time offering support help, if Cmder had a simple configurable setting to change the lambda and/or the prompt color. |
See the PR #2523 |
@richyk1 thanks for your solution, but this till have some problem when directory with git infomation. the problem like this, when the git status is not clear, the cmder performace normal, but when the git status is clear, it not normal now. |
@lfire try the new build it has configurable prompt with no requirement for a custom prompt filter. There should be a All colors are configurable including git prompt xolors. |
@uinguyenhoangtho see my last comment on this. |
I have updated the CMDER, but it does not come with a "cmder_prompt_config.lua" file, so I created one. Do you have an example of a file? or can you point to some doc/example to fill this file? There is this file, but it is located inside the vendor folder, it should be inside the config or test folder? I have tried putting the file inside vendor and config folder, but it does not affect the settings, what I'm missing? |
You need to copy it from the vendor location to the config folder and remove |
@daxgames I did it, removed the .default, and moved to the config folder, I have changed some properties to test, like the symbol (prompt_lambSymbol), but it does not change anything |
Did you restart the session or start a new tab? |
@daxgames I've tested both, I also killed all the cmder.exe and ConEmu64.exe processes and opened a new cmder, but it does not change the settings |
I dont think that feature is in the realeased 1.3.18 Try this https://ci.appveyor.com/project/MartiUK/cmder/build/artifacts |
@daxgames you were right! using the version from your link works fine! Could you point me what is the right property to change to avoid the black bands? Changing all 40 to 49?
I can confirm that changing all the 40 to 49 fixes the black bands issues |
Good to know. |
I was racking my brain over these black bars. Thanks for the excellent explanation and detailed workaround. $CMDER_ROOT/config/cmder_prompt_config.lua change the colors |
Works great. Thanks. |
Originally from b0f034a: the default value of SGR 49 works best with both ConEmu and Windows Terminal, and both values don't take an effect on Cmder. The only reason I see to use an explicit black background for the prompt is the point by @chrisant996:
I'd argue that since the default terminal (ConEmu) and Cmd.exe won't be affected and most people would rather to see a transparent one in Windows Terminal, we should use SGR 49 as the default, and let the user to adjust the prompt background to their needs, if somehow they use the same background color (or a color close to the foreground) on their terminal (which will allow a high contrast setting). |
…#2560 the default value of SGR 49 works best with both ConEmu and Windows Terminal, and both values don't take an effect on Cmder. (ref: https://github.com/cmderdev/cmder/wiki/Seamless-Windows-Terminal-Integration)
@DRSDavidSoft to me it seems reasonable to default to SGR 49, and have doc/wiki text saying how to configure the prompt to work with non-black backgrounds. I don't know how broadly that viewpoint is shared, so I don't feel comfortable making a suggestion in either direction. |
@chrisant996 That's a good idea, and thank you for pointing it out. I've already described using a black color in the wiki: P.S. Hopefully, since Cmder is used by people with all kinds of color, shell, and terminal preferences, we could collect all customization and configuration tips in one place. Personally, I love Cmder since it's a precisely pre-configured package with best configurations collected over time by the community adding their bits and parts to the project. I'd also appreciate it if you could share your suggestions, especially in the personal preferences section 😄 |
Purpose of the issue
Version Information
This was migrated from microsoft/terminal#9693, and it appears to be valid with the latest code on
master
.The user is using cmder's shell configuration outside of ConEmu, so I understand if this is not a valid report.
Description of the issue
When updating the prompt here ...
cmder/vendor/clink.lua
Line 50 in c34eb73
... clink specifically requests graphical rendition
40
, "ANSI Color 0 Background". This works fairly well for the traditional Windows console and ConEmu, but it is not entirely correct. There is no guarantee that the user's background color is ANSI color 0! In certain terminals (Windows Terminal, gnome-terminal, ...) the user can specify a background color that cannot be represented via SGR, such as that of an image or a transparency effect.The result is that when the user has transparency enabled, their terminal looks somewhat like this:
The ideal solution would be to print using SGR
49
, "revert to default background". This has been supported on all versions of Windows whereENABLE_VIRTUAL_TERMINAL_PROCESSING
supports colors, so there is no compatibility risk.We had to fix a similar issue here in PowerShell: PowerShell/PSReadLine#1626
In short, the Windows console is getting better at determining when the user wanted a specific background color and when they wanted the default. I need to do an actual write-up about what's changed rather than writing a bunch of different GitHub comments, so that I can point users and developers at it.
The text was updated successfully, but these errors were encountered: