Skip to content
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

[Bug]: Issues with reset codes #1

Open
MarketingPip opened this issue Oct 7, 2024 · 9 comments
Open

[Bug]: Issues with reset codes #1

MarketingPip opened this issue Oct 7, 2024 · 9 comments
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@MarketingPip
Copy link
Member

There is a current issue with reset codes - not allowing things like chalk to apply background colors properly to this.

As shown as below -

image

Mentioning the wizard @jcubic - to see if he can possibly look where the ANSI reset codes need placed to properly achieve this. As well in hopes he see's this / might want to grab this library.

@MarketingPip MarketingPip added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels Oct 7, 2024
@jcubic
Copy link

jcubic commented Oct 7, 2024

I think that you can't change this behavior in ctree, I think that this is chalk issue. Unless you want to remove all ANSI colors when used with pipe. This is how ls/grep and other commands work by default. You can force colors with --color flag.

@MarketingPip
Copy link
Member Author

@jcubic - you can (but it's a matter of properly applying the reset codes). Which I can not seem to figure out currently. And just figured your experience with escape sequences you might be able to see what's going wrong.

See here - as this is related to lolcat. (It appears I have a working formatted for piping colors from chalk bg colors etc - ie first match of BG code) correctly and returning a ANSI based result for terminal. (Stripping fg colors).

@jcubic
Copy link

jcubic commented Oct 7, 2024

I don't think that it will work, but you try to reset the color just after you use it. If you use it once for one character, reset it after that character.

But I think that it will work with chalk, it's really simple tool just add color at the beginning of the string. TO make it work you will need to use ANSI parser inside chalk, and it's not as trivial as adding color, I don't think that chalk is doing this, but I may be wrong.

@MarketingPip
Copy link
Member Author

MarketingPip commented Oct 7, 2024

@jcubic - when I completely remove the reset code in "ctree.js" - this is the results.

image

  • which it messes those two lines (and not sure how to properly format the reset codes to solve this).

(but as fair as I know - we should be able to pipe things like these to other things).

@jcubic
Copy link

jcubic commented Oct 7, 2024

Sorry, no idea how to fix this. I think that when you have Unix tools, only the last in pipe should change color.

@MarketingPip
Copy link
Member Author

@jcubic - correct - the last pipe is the final results with applied colors! But no worries - thank you for looking regardless!

@jcubic
Copy link

jcubic commented Oct 7, 2024

You can try to do what most tools are using, strip colors when using pipe.

@MarketingPip
Copy link
Member Author

@jcubic - I don't want to do that. I want to apply colors with a pipe sequence ;)

(I got lolcat working this way - as said so I can "pipe" into it) a lolcat modified string and apply my chalk BG to it without removing it. (Keeping both the foreground colors applied and background).

@MarketingPip
Copy link
Member Author

Noting here for self - the issue is due to this line of code. Applying resets are not needed for "/" etc (xmas text).

As well reset codes are not needed to be applied for most / all methods.

This should solve not being able to properly add bg codes to example:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants