Skip to content

Commit

Permalink
Document print_rich() in BBCode in RichTextLabel
Browse files Browse the repository at this point in the history
While `print_rich()` works independently of RichTextLabel, it still
makes use of BBCode.
  • Loading branch information
Calinou committed Nov 29, 2024
1 parent feb1db0 commit 5bb6fce
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tutorials/ui/bbcode_in_richtextlabel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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<class_@GlobalScope_method_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 <https://en.wikipedia.org/wiki/ANSI_escape_code>`__ 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<class_@GlobalScope_method_push_error>` and
:ref:`@GlobalScope.push_warning<class_@GlobalScope_method_push_warning>`
instead of ``print_rich()``.

0 comments on commit 5bb6fce

Please sign in to comment.