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

ANSI color codes - mixed results #17

Open
mishaxz opened this issue Jan 22, 2019 · 4 comments
Open

ANSI color codes - mixed results #17

mishaxz opened this issue Jan 22, 2019 · 4 comments

Comments

@mishaxz
Copy link

mishaxz commented Jan 22, 2019

note: the following are not correct because pasting them in this github form doesn't work, so just assume they are that special ansi escape code symbol.

when I try to output ANSI color codes from my java program that I run under TerminalFX, it doesn't work. However, my codes are like this �[33m and they work in various other terminals.

but in TerminalFX I get

?[0mRESET?[0m
?[1mBOLD?[0m
?[4mUNDERLINE?[0m
?[7mINVERSE?[0m
?[30mBLACK?[0m
?[31mRED?[0m
?[32mGREEN?[0m
?[33mORANGE?[0m
?[34mBLUE?[0m
?[35mMAGENTA?[0m
?[36mCYAN?[0m
?[37mLIGHT_GRAY?[0m
?[41mBG_RED?[0m
?[42mBG_GREEN?[0m

would you know what I'm doing wrong? is there any way to run a java program under TerminalFX and be able to display ansi colors from it?

however, if I run the following in TerminalFX, it displays colors fine.

win10colors.cmd

this works, displays colors in TerminalFX

@echo off
cls
echo �[101;93m STYLES �[0m
echo ^<ESC^>[0m �[0mReset�[0m
echo ^<ESC^>[1m �[1mBold�[0m
echo ^<ESC^>[4m �[4mUnderline�[0m
echo ^<ESC^>[7m �[7mInverse�[0m
echo.
echo �[101;93m NORMAL FOREGROUND COLORS �[0m
echo ^<ESC^>[30m �[30mBlack�[0m (black)
echo ^<ESC^>[31m �[31mRed�[0m
echo ^<ESC^>[32m �[32mGreen�[0m
echo ^<ESC^>[33m �[33mYellow�[0m
echo ^<ESC^>[34m �[34mBlue�[0m
echo ^<ESC^>[35m �[35mMagenta�[0m
echo ^<ESC^>[36m �[36mCyan�[0m
echo ^<ESC^>[37m �[37mWhite�[0m
echo.
echo �[101;93m NORMAL BACKGROUND COLORS �[0m
echo ^<ESC^>[40m �[40mBlack�[0m
echo ^<ESC^>[41m �[41mRed�[0m
echo ^<ESC^>[42m �[42mGreen�[0m
echo ^<ESC^>[43m �[43mYellow�[0m
echo ^<ESC^>[44m �[44mBlue�[0m
echo ^<ESC^>[45m �[45mMagenta�[0m
echo ^<ESC^>[46m �[46mCyan�[0m
echo ^<ESC^>[47m �[47mWhite�[0m (white)
echo.
echo �[101;93m STRONG FOREGROUND COLORS �[0m
echo ^<ESC^>[90m �[90mWhite�[0m
echo ^<ESC^>[91m �[91mRed�[0m
echo ^<ESC^>[92m �[92mGreen�[0m
echo ^<ESC^>[93m �[93mYellow�[0m
echo ^<ESC^>[94m �[94mBlue�[0m
echo ^<ESC^>[95m �[95mMagenta�[0m
echo ^<ESC^>[96m �[96mCyan�[0m
echo ^<ESC^>[97m �[97mWhite�[0m
echo.
echo �[101;93m STRONG BACKGROUND COLORS �[0m
echo ^<ESC^>[100m �[100mBlack�[0m
echo ^<ESC^>[101m �[101mRed�[0m
echo ^<ESC^>[102m �[102mGreen�[0m
echo ^<ESC^>[103m �[103mYellow�[0m
echo ^<ESC^>[104m �[104mBlue�[0m
echo ^<ESC^>[105m �[105mMagenta�[0m
echo ^<ESC^>[106m �[106mCyan�[0m
echo ^<ESC^>[107m �[107mWhite�[0m
echo.
echo �[101;93m COMBINATIONS �[0m
echo ^<ESC^>[31m                     �[31mred foreground color�[0m
echo ^<ESC^>[7m                      �[7minverse foreground ^<-^> background�[0m
echo ^<ESC^>[7;31m                   �[7;31minverse red foreground color�[0m
echo ^<ESC^>[7m and nested ^<ESC^>[31m �[7mbefore �[31mnested�[0m
echo ^<ESC^>[31m and nested ^<ESC^>[7m �[31mbefore �[7mnested�[0m
pause
@sghpjuikit
Copy link

@mishaxz Am I correct to assume you are running into this on Win10? Does it affect other platforms?

@mishaxz
Copy link
Author

mishaxz commented Jun 19, 2019

windows 10 yes, I don't know I haven't tried other platforms. I can't remember much what I was doing at that time with this but definitely only on windows 10.

@myrlyn
Copy link

myrlyn commented Sep 12, 2019

This needs to be broadened to address escape sequences in general - terminal resizing, and other usage of escape characters to query the terminal/terminfo should be fixed as well.

@Eesha-Jain
Copy link

It should work depending on what platform you are using. For example, if you use Eclipse, then the first part of this video talks about how to add ANSI (and then proceeds to integrate ANSI with Java): https://www.youtube.com/watch?v=IzYCYXfVTF8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants