cmderdev / cmder

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

[Bug] background color #2872

Closed kkm closed 8 months ago

kkm commented 10 months ago

Version Information

Cmder version: latest
Operating system: windows

nodejs:
console.log("color background".yellow.inverse) doesnt work on cmder.

Cmder Edition

Cmder Full (with Git)

Description of the issue

color problem doesnt show background.

How to reproduce

No response

Additional context

No response

Checklist

DRSDavidSoft commented 8 months ago

@kkm Hi there, sorry for the delayed response.

Cmder is a pre-configured bundle that consists of a terminal emulator (ConEmu in this case) and some shells. Once you run node.js, Cmder is no longer in control of the output or how it is displayed, which means if there are any issues, it is related to ConEmu.

However, I have personally verified that npm packages work well with ConEmu and Cmder, since all that packages like this are doing is generating some escape code sequences, which will make the text appear in different styles and colors universally in all VT100-like terminals (like ConEmu), regardless of the runtime and software package that generates it. This means that colors.js works as intended in Cmder, too.

Please add some screenshots and tests in other terminals to see if your code is only breaking on Cmder, otherwise we might not be able to help you.

P.S. I strongly suggest switching to a better and sane alternative to the abandoned colors.js package, such as chalk. This is because the Marak, who is the original author of colors.js went ballistic last year and decided to vandalize their own package: https://github.com/Marak/colors.js/issues/285 which means, the latest "official" release from them contains an intentional "bug" that causes an infinite loop and the rest of your code not running at all. It's a great troll effort, but unfortunately the side effect is that you'll be unable to use the latest release in your project.

Either revert back to an un-ruined version of colors.js, or switch to chalk.js which has a different syntax, thus requiring a re-factoring, but it works well and as intended. chalk is what I use in my own projects and it works without any issues.

kkm commented 5 months ago

cmder: image

Windows Terminal via Powershell: image

const colors = require('colors');
console.log("Text Green Only".green);
console.log("Green Text with Background".green.inverse);

@DRSDavidSoft okay thanks for recommend chalk and I didnt know before.