-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Colored console output #2308
Comments
\e in your echo command is not two characters but is instead an escape sequence, thus doing \e will never work in any case like this. |
Also, that is terminal specific, there are ways to use proper colors based on the detected terminal type. |
yes this is not portable sadly On Sun, Aug 2, 2015 at 7:53 PM, OvermindDL1 notifications@github.com
|
I guess we could have a Basically we could use Not sure if it's worth the pain though :) |
It looks like it's already possible, even though it's not particularly straightforward (but it could be abstracted by the user):
This should support any ANSI escape sequence. I haven't tested this on Windows yet, but Windows 10 is able to interpret ANSI escape sequences so it should work on Windows 10 as well. However, it won't work in the Output panel (escape codes will appear as-is). People writing libraries or plugins may also be interested in Edit: It seems ANSI escape code support should be enabled in the application code before it can work on Windows 10. |
Windows command line on any versions lower than Windows 10 does NOT support ANSI escape sequences, though. |
Remember to be able to disable text colours in the startup flags. |
You could use something like the public domain licensed single-file https://github.com/agauniyal/rang library or find something similar. I only tested it in linux, but it is supposed to work for windows as well. |
@lifelike Can that library work if you don't use the standard library to print text? Its README states:
Also, in general, we tend to favor libraries that don't use the C++ standard library. |
Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine. The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker. If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance! |
In an UNIX terminal, you can type this for example:
However, this doesn't work in Godot, the sequence will be output as plain text:
(There are two backslashes in order to actually print one backslash.)
It doesn't work with
printraw()
either.Either the sequences should be supported, or, better, there should be a cross-platform way of colouring console output, as Windows supports a subset of console colours too. Possible uses are:
The text was updated successfully, but these errors were encountered: