neilpa / cmd-colors-solarized

Solarized color settings for Windows command prompt
1.11k stars 176 forks source link

Powershell Dark screenshot unreproducible #16

Closed TBBle closed 7 years ago

TBBle commented 7 years ago

Something's wrong with either the registry file or the screenshot.

It's pretty clear in the registry file (and the given command color 01) that "Black" (base03) should be the background colour.

However, the shown example has Black visible against the background, and "DarkGray" (base02) is invisible, suggesting that is set as the background colour.

I confirmed against http://ethanschoonover.com/solarized#usage-development that base03 should be the background colour, and base02 is for background highlight, so I suspect the screenshot is incorrect. It also doesn't match the equivalent result in mintty (e.g. https://github.com/mavnn/mintty-colors-solarized)

Setting the following in my profile.ps1 got me much closer to what I expected:

$Host.PrivateData.ErrorBackgroundColor = "DarkGray"
$Host.PrivateData.WarningBackgroundColor = "DarkGray"
$Host.PrivateData.DebugBackgroundColor = "DarkGray"
$Host.PrivateData.VerboseBackgroundColor = "DarkGray"

This is with Windows 10 anniversary edition.

I also noticed that I never get the solid colour blocks demonstrating background colours. I replaced the "`t" with eight spaces, I suspect tabs are see-through in newer PowerShell releases.

One more note, I had to add the following to my profile.ps1, as the default colouring for both Parameters and Operators was "DarkGray":

Set-PSReadlineOption -TokenKind Parameter -ForegroundColor DarkMagenta -BackgroundColor Black
Set-PSReadlineOption -TokenKind Operator -ForegroundColor DarkMagenta -BackgroundColor Black

I also just found https://www.reddit.com/r/PowerShell/comments/4aw3wa/solarized_powershell_console/ which gives Powershell script for updating the colours stored in console shortcuts.

neilpa commented 7 years ago

That screenshot was from before #2 and I never regenerated a new one. I'm not using Windows or Powershell these days (or even have access to a Windows 10 box) so I can't fix it. I'd be happy to update the screenshots if you open a PR with the fixes.

TBBle commented 7 years ago

Sounds fair. I'll look into doing that when I have a chance.

rbeesley commented 7 years ago

Where would that be defined? I'm looking at colors.sh and base03 is defined as esc[1;30;40m, and according to http://ascii-table.com/ansi-escape-sequences.php, this is bold;black;black. The difference between base02 and base03 is only the bold attribute. The changes I've made in WSL look correct if I flip the definitions of base02 and base03 in the script, so I think the shell script might be wrong.

Out-Colors.ps1 on the other hand has more issues. I can also start to look at that since I think the registry definitions are correct.

rbeesley commented 7 years ago

I looked at mintty color settings and I agree with TBBle, Base02 and Base03 are probably flipped in the registry.

mintty: echo -ne '\eP\e]4;0;#073642\a' # black -> Base02 echo -ne '\eP\e]4;8;#002B36\a' # bold black -> Base03

Solarized: base03 #002b36 8/4 brblack 234 #1c1c1c 15 -12 -12 0 43 54 193 100 21 base02 #073642 0/4 black 235 #262626 20 -12 -12 7 54 66 192 90 26

ansicolors: export base03='\033[1;30;40m' # should be bold/bright black export base02='\033[0;30;40m' # should be black

This makes the colors inverted in colors.sh, which looks to be defining the ansicolors correctly. If this can be resolved in WSL, then those registry values should be the basis for fixing the PowerShell profile.

rbeesley commented 7 years ago

And I've flipped my opinion again. Look at the table with PuTTY, ANSI, and TERMCOL values added:

NR TERMCOL cmd.exe PowerShell PuTTY SOLARIZED HEX DWORD ANSI
00 brblack Black Black Colour7 / Colour2 / Colour4 base03 #002b36 00362b00 ESC[0;30m
01 brblue Blue DarkBlue Colour15 / Colour0 base0 #839496 00969483 ESC[0;34m
02 brgreen Green DarkGreen Colour11 base01 #586e75 00756e58 ESC[0;32m
03 brcyan Aqua DarkCyan Colour19 / Colour1 base1 #93a1a1 00a1a193 ESC[0;36m
04 brred Red DarkRed Colour9 orange #cb4b16 00164bcb ESC[0;31m
05 brmagenta Purple DarkMagenta Colour17 violet #6c71c4 00c4716c ESC[0;35m
06 bryellow Yellow DarkYellow Colour13 base00 #657b83 00837b65 ESC[0;33m
07 white White Gray Colour20 / Colour5 base2 #eee8d5 00d5e8ee ESC[0;37m
08 black Gray DarkGray Colour6 / Colour3 base02 #073642 00423607 ESC[1;30m
09 blue LightBlue Blue Colour14 blue #268bd2 00d28b26 ESC[1;34m
10 green LightGreen Green Colour10 green #859900 00009985 ESC[1;32m
11 cyan LightAqua Cyan Colour18 cyan #2aa198 0098a12a ESC[1;36m
12 red LightRed Red Colour8 red #dc322f 002f32dc ESC[1;31m
13 magenta LightPurple Magenta Colour16 magenta #d33682 008236d3 ESC[1;35m
14 yellow LightYellow Yellow Colour12 yellow #b58900 000089b5 ESC[1;33m
15 brwhite BrightWhite White Colour21 base3 #fdf6e3 00e3f6fd ESC[1;37m

This is the legend for what those PuTTY values are:

PuTTY Code PuTTY Color
Colour0 Default Foreground
Colour1 Default Foreground Bold
Colour2 Default Background
Colour3 Default Background Bold
Colour4 Cursor Text
Colour5 Cursor Color
Colour6 ANSI Black
Colour7 ANSI Black Bold
Colour8 ANSI Red
Colour9 ANSI Red Bold
Colour10 ANSI Green
Colour11 ANSI Green Bold
Colour12 ANSI Yellow
Colour13 ANSI Yellow Bold
Colour14 ANSI Blue
Colour15 ANSI Blue Bold
Colour16 ANSI Magenta
Colour17 ANSI Magenta Bold
Colour18 ANSI Cyan
Colour19 ANSI Cyan Bold
Colour20 ANSI White
Colour21 ANSI White Bold

Throw out colors 0-5 for our purpose and just look at 6-21. Colour6 is ANSI Black and that corresponds with base02, or Gray/DarkGray. Colour7 is ANSI Black Bold corresponding with base03, or Black.

Therefore with the mapping in the registry files, the Default Background is brblack/Black/Black/base03/#002b36/ANSI Black Bold and the other entry should be black/Gray/DarkGray/base02/#073642/ANSI Black.

It feels weird defining the ANSI Bold Black as the darker of the two colors, but that appears to be how it should be mapped as the rest of the table aligns.

So, looking at the most important of these settings, things should be mapped like this:

SOLARIZED HEX Role
base03 #002b36 Dark Background
base02 #073642 Dark Background Highlights
base00 #657b83 Light Foreground Text
base0 #839496 Dark Foreground Text
base2 #eee8d5 Light Background Highlights
base3 #fdf6e3 Light Background

ESC[0;30;40 should therefore match base03.

The registry files are correct and the colors.sh script is slightly wrong. With that resolved, I think we can focus on the PowerShell side now.

neilpa commented 7 years ago

@rbeesley This is an excellent analysis/breakdown. Would you want to open a PR that adds the above big table and a bit of explanation to the README?

rbeesley commented 7 years ago

Yeah, I have a bunch of other things open, but I'll clean things up and submit another PR once I've made the final changes.

I started looking at PS and the only thing which strikes me as needing to be fixed are the PSReadLine settings. With the registry settings applied some of the colors aren't being smart. Notably the arguments are showing in base02, so they show more like comments.

My primary reason for using this wasn't for PS, but it was for assigning terminal colors for WSL. It just needs to be resolved across the board and that will require some tweaking in a PS profile. Not ideal maybe, but it seems like the best way to keep things aligned with the rest of the Solarized projects.

rbeesley commented 7 years ago

The changes in my repro are the ones I'm working on. I'll submit when I'm satisfied with the update. @TBBle, in case you aren't following, the registry looks correct but the PSReadLine options will need to be tweaked to make it more usable. I think this is what you're seeing.

TBBle commented 7 years ago

Yeah, that seems to match what I experienced. As noted at the bottom of my original report, Parameter and Token were the two which were unreadable (using background-highlight on background by default) but I didn't really try hard to work out any other improvements, as I am not in Powershell that often.

Just reading back on my original report, I may not have been clear. I also believed that the registry was correct, and the screenshot incorrect.

neilpa commented 7 years ago

Resolved by #17