javaterminal / TerminalFX

Java FX Terminal Emulator
MIT License
277 stars 52 forks source link

ANSI color codes - mixed results #17

Open mishaxz opened 5 years ago

mishaxz commented 5 years ago

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  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  STYLES 
echo ^<ESC^>[0m Reset
echo ^<ESC^>[1m Bold
echo ^<ESC^>[4m Underline
echo ^<ESC^>[7m Inverse
echo.
echo  NORMAL FOREGROUND COLORS 
echo ^<ESC^>[30m Black (black)
echo ^<ESC^>[31m Red
echo ^<ESC^>[32m Green
echo ^<ESC^>[33m Yellow
echo ^<ESC^>[34m Blue
echo ^<ESC^>[35m Magenta
echo ^<ESC^>[36m Cyan
echo ^<ESC^>[37m White
echo.
echo  NORMAL BACKGROUND COLORS 
echo ^<ESC^>[40m Black
echo ^<ESC^>[41m Red
echo ^<ESC^>[42m Green
echo ^<ESC^>[43m Yellow
echo ^<ESC^>[44m Blue
echo ^<ESC^>[45m Magenta
echo ^<ESC^>[46m Cyan
echo ^<ESC^>[47m White (white)
echo.
echo  STRONG FOREGROUND COLORS 
echo ^<ESC^>[90m White
echo ^<ESC^>[91m Red
echo ^<ESC^>[92m Green
echo ^<ESC^>[93m Yellow
echo ^<ESC^>[94m Blue
echo ^<ESC^>[95m Magenta
echo ^<ESC^>[96m Cyan
echo ^<ESC^>[97m White
echo.
echo  STRONG BACKGROUND COLORS 
echo ^<ESC^>[100m Black
echo ^<ESC^>[101m Red
echo ^<ESC^>[102m Green
echo ^<ESC^>[103m Yellow
echo ^<ESC^>[104m Blue
echo ^<ESC^>[105m Magenta
echo ^<ESC^>[106m Cyan
echo ^<ESC^>[107m White
echo.
echo  COMBINATIONS 
echo ^<ESC^>[31m                     red foreground color
echo ^<ESC^>[7m                      inverse foreground ^<-^> background
echo ^<ESC^>[7;31m                   inverse red foreground color
echo ^<ESC^>[7m and nested ^<ESC^>[31m before nested
echo ^<ESC^>[31m and nested ^<ESC^>[7m before nested
pause
sghpjuikit commented 5 years ago

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

mishaxz commented 5 years ago

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 commented 5 years ago

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 commented 2 years ago

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