cmderdev / cmder

Lovely console emulator package for Windows
https://cmder.app
MIT License
25.92k stars 2.03k forks source link

Support of 24 bits color is random #1530

Closed ddorn closed 6 years ago

ddorn commented 7 years ago

I was trying to use 24 bits ansi colors escape sequences in a simple python script

import colorsys

for i in range(255):
    color = colorsys.hsv_to_rgb(i / 255, 1, 1)
    color = int(color[0] * 255), int(color[1] * 255), int(color[2] * 255)
    print('\x1b[48;2;{0};{1};{2}m \x1b[0m'.format(*color), end='')
print('End')

Which doesn't seems to work after a first try because the colors are replaced by the closest one in the 16 palette. image

However, if I run

type "%ConEmuBaseDir%\Addons\AnsiColors256.ans"

before, it kinda works : image And it will work untill I run cls.

I don't know if this is intended, a bug or something that cmder / ConEmu just doesn't support.

I am on Windows Pro Fall Update (version 1709 build 16299.19) I have TrueMod (24 bit color) support checked

Thanks for having done such a great console ! It rocks ! ;)

RyanQuey commented 4 years ago

type "%ConEmuBaseDir%\Addons\AnsiColors256.ans"

Just curious, since I ran into this as well. How did you figure out how to run this to fix the 24 bit issue?

ddorn commented 4 years ago

Sorry, I can't remember and I switched to linux in the mean time so I've lost any configuration :/ I hope you will find your luck with this !

niteshb commented 4 years ago

This needs to be reopened. The behaviour is indeed random as stated in the original post

00-kat commented 9 months ago

I know this is an old post, but:

If you open %ConEmuBaseDir%\Addons\AnsiColors256.ans in vim, it shows that the file starts with this: . That is, ^[[32766S^[[32766H. I don't know what either does (I think maybe it's clear screen, then move cursor down 32766 lines, but that's just a guess).

Weirdly, adding echo  (echo ^[[32766H) to user_profile.cmd fixes it until cls is run. Of course, this moves the prompt to the bottom of the screen though. Edit: using echo  (echo ^[[32766H^[[2J) works.

I have no idea why printing a specific ANSI escape code (p.s., smaller numbers don't seem to work, but I only tried 1, 2, 3, 30 and 32. 32766 is also two less than 32768, i.e. two less than 2¹⁵) does this, and I have no idea why this is the case. The number is also so weird, and the connection to being two less than a power of 2 seems weird, since 30 didn't work. I also don't understand why the number is that large.

Some last minute things: Doesn't work in WSL. Tried Fish + Zellij, Zsh and Bash, so probably not a shell issue. Works in PowerShell and Nushell though, so this is probably not something Command Prompt specific.

chrisant996 commented 9 months ago

It does seem strange that scrolling is required before 8-bit or 24-bit color can work in ConEmu, but that's a ConEmu thing, not a Cmder thing.

Does the same thing happen in ConEmu by itself, without the Cmder initialization script? This is very likely a ConEmu issue, not a Cmder issue.

Cmder is not a terminal emulator. Cmder delegates all terminal emulator to whatever terminal emulator you're using. By default, that's ConEmu for Cmder, although you can configure Cmder to work in any terminal emulator.

The Cmder package includes the ConEmu terminal emulator. Issues in the ConEmu terminal emulator need to be filed in the ConEmu repo so they're visible to the owners/maintainers of ConEmu.

The escape codes you mentioned are CSI n S (Scroll Up) and CSI n H (Cursor Position). A good introductory article about escape codes is here: ANSI escape code (wikipedia). I agree that it's mysterious why those codes would make a difference for ConEmu's support of 8-bit or 24-bit color -- it's most likely a bug in ConEmu, so filing an issue in the ConEmu repo is the way to try to get attention/resolution.