-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Add print_rich() for printing with BBCode #60675
Add print_rich() for printing with BBCode #60675
Conversation
I think I fixed all the workflow issues (ran the scripts on my pc and it worked), and re-based on the master branch. |
I squashed all my commits, re-based them on master, did a check with clang_format.sh and also fixed an issue with one of the Linux workflow builds (made a mistake in the mono stuff, the function name wasn't correct). So normally all workflow checks should be good now. |
Fixed the workflow issue which was happening. Sorry about that. ^^" |
I don't think this would work with all terminals, which makes this not usable in the final export, right? |
It uses ANSI so it should be supported by nearly all terminals I think, but I could be wrong of course. For which terminals would this not work? |
This should work well in exported projects, unless you're targeting old Windows versions.
Footnotes
|
There are 44 |
I'd say the set of If making it faster is desired, we can check for the presence of a tag before running its relevant replacements. For instance, if there is no The above optimization will be more useful if we decide to support all named colors. I've only added support for 12 named colors or so right now, but we have more than 200 in the engine. |
Like Calinou suggested, I've added the 2 biggest pieces ([color=] and [bgcolor=]) inside of an if statement to see if the string contains any color or bgcolor tags. Hope this helps with the speed concern. |
The static checks failed because of the color tags I used in the example for the docs, so I changed the example. There was also a small mistake in the GlobalScope documentation which I have changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good to merge (preferably after #44118), although I have a concern about the editor UX related to filtering messages – see above.
Fixed the filtering message thing. The normal print messages and print_rich messages are being filtered by the same button now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved in PR review meeting, the code seems good and the feature is nice to have.
Would be worth a rebase to make sure it still builds and works fine before merging.
@akien-mga Rebased and checked, still working. Thanks for approving this! ^^/ |
Thanks! And congrats for your first merged Godot contribution 🎉 |
Best feature ever!
|
Hello! I believe nested color tags work as I would expect, but they don't seem to filter from the text logs correctly. Edit: To clarify, the nested opening tag is not filtered from the text logs but its corresponding closing tag is. |
Nested color tags work in the editor Output panel (it's displayed using RichTextLabel), but terminal printing does not handle nested color tags as it uses a separate BBCode implementation. Also, terminal printing does not handle color tags other than a few basic colors ( |
To clarify, I mean on-disk plaintext file log output generated by debug builds, if that isn't the same thing in this context as terminal printing. Understood about the color support, though. Thanks for the tip there! |
That's a consequence of terminal printing (stdout). What you see in the log file is directly based on stdout with ANSI escape codes stripped since 4.3. Since terminal printing never replaced the |
Understood, thanks. I figured that's what the answer was once you clarified that silver is only accidentally working. I'll stick to supported codes for the time being. Thanks! |
This is an attempt to make pull request #33541 work.
The addition is a 'print_rich()' function which allows the use of BBCode for printing. It prints in both in color, bold, italic, underline in the editor output and in the console through ANSI. (With the help of @Calinou for the conversion strings)
Like you can see in this screenshot, when using print(...) everything gets printed like you've typed it.
But when you use print_rich(...), BBCodes will be used.
I was also able to make the folding work that happens with the other types of logs aswell.
Sorry in advance if the way I made this work isn't very clean, I hope you guys can give me advice on how to improve this code. I tried my best and this is my first time actually working on the Godot engine. But it works. 😄