From 5bb6fcef52674f899b22b61ee843e9eadf733deb Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 29 Nov 2024 01:51:44 +0100 Subject: [PATCH] Document `print_rich()` in BBCode in RichTextLabel While `print_rich()` works independently of RichTextLabel, it still makes use of BBCode. --- tutorials/ui/bbcode_in_richtextlabel.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tutorials/ui/bbcode_in_richtextlabel.rst b/tutorials/ui/bbcode_in_richtextlabel.rst index 24b1a4c93c10..a0a900017d91 100644 --- a/tutorials/ui/bbcode_in_richtextlabel.rst +++ b/tutorials/ui/bbcode_in_richtextlabel.rst @@ -1147,3 +1147,26 @@ This will add a few new BBCode commands, which can be used like so: [center][ghost]This is a custom [matrix]effect[/matrix][/ghost] made in [pulse freq=5.0 height=2.0][pulse color=#00FFAA freq=2.0]GDScript[/pulse][/pulse].[/center] + +Printing rich text to the console +--------------------------------- + +Using :ref:`print_rich`, you can print +rich text to the editor Output panel and standard output (visible when the user +runs the project from a terminal). This works by converting the BBCode to +`ANSI escape codes `__ that the +terminal understands. + +In the editor output, all BBCode tags are recognized as usual. In the terminal +output, only a subset of BBCode tags will work, as documented in the linked +``print_rich()`` method description above. In the terminal, the colors will look +different depending on the user's theme, while colors in the editor will use the +same colors as they would in the project. + +.. note:: + + To print error and warning messages that can be filtered by type in the + editor Output panel, use + :ref:`@GlobalScope.push_error` and + :ref:`@GlobalScope.push_warning` + instead of ``print_rich()``.