:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/4.3/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/4.3/doc/classes/CodeHighlighter.xml. .. _class_CodeHighlighter: CodeHighlighter =============== **Inherits:** :ref:`SyntaxHighlighter` **<** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` A syntax highlighter intended for code. .. rst-class:: classref-introduction-group Description ----------- By adjusting various properties of this resource, you can change the colors of strings, comments, numbers, and other text patterns inside a :ref:`TextEdit` control. .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+ | :ref:`Dictionary` | :ref:`color_regions` | ``{}`` | +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+ | :ref:`Color` | :ref:`function_color` | ``Color(0, 0, 0, 1)`` | +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+ | :ref:`Dictionary` | :ref:`keyword_colors` | ``{}`` | +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+ | :ref:`Dictionary` | :ref:`member_keyword_colors` | ``{}`` | +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+ | :ref:`Color` | :ref:`member_variable_color` | ``Color(0, 0, 0, 1)`` | +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+ | :ref:`Color` | :ref:`number_color` | ``Color(0, 0, 0, 1)`` | +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+ | :ref:`Color` | :ref:`symbol_color` | ``Color(0, 0, 0, 1)`` | +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_color_region`\ (\ start_key\: :ref:`String`, end_key\: :ref:`String`, color\: :ref:`Color`, line_only\: :ref:`bool` = false\ ) | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_keyword_color`\ (\ keyword\: :ref:`String`, color\: :ref:`Color`\ ) | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_member_keyword_color`\ (\ member_keyword\: :ref:`String`, color\: :ref:`Color`\ ) | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`clear_color_regions`\ (\ ) | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`clear_keyword_colors`\ (\ ) | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`clear_member_keyword_colors`\ (\ ) | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`get_keyword_color`\ (\ keyword\: :ref:`String`\ ) |const| | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`get_member_keyword_color`\ (\ member_keyword\: :ref:`String`\ ) |const| | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_color_region`\ (\ start_key\: :ref:`String`\ ) |const| | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_keyword_color`\ (\ keyword\: :ref:`String`\ ) |const| | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_member_keyword_color`\ (\ member_keyword\: :ref:`String`\ ) |const| | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_color_region`\ (\ start_key\: :ref:`String`\ ) | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_keyword_color`\ (\ keyword\: :ref:`String`\ ) | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_member_keyword_color`\ (\ member_keyword\: :ref:`String`\ ) | +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_CodeHighlighter_property_color_regions: .. rst-class:: classref-property :ref:`Dictionary` **color_regions** = ``{}`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_color_regions**\ (\ value\: :ref:`Dictionary`\ ) - :ref:`Dictionary` **get_color_regions**\ (\ ) Sets the color regions. All existing regions will be removed. The :ref:`Dictionary` key is the region start and end key, separated by a space. The value is the region color. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_property_function_color: .. rst-class:: classref-property :ref:`Color` **function_color** = ``Color(0, 0, 0, 1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_function_color**\ (\ value\: :ref:`Color`\ ) - :ref:`Color` **get_function_color**\ (\ ) Sets color for functions. A function is a non-keyword string followed by a '('. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_property_keyword_colors: .. rst-class:: classref-property :ref:`Dictionary` **keyword_colors** = ``{}`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_keyword_colors**\ (\ value\: :ref:`Dictionary`\ ) - :ref:`Dictionary` **get_keyword_colors**\ (\ ) Sets the keyword colors. All existing keywords will be removed. The :ref:`Dictionary` key is the keyword. The value is the keyword color. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_property_member_keyword_colors: .. rst-class:: classref-property :ref:`Dictionary` **member_keyword_colors** = ``{}`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_member_keyword_colors**\ (\ value\: :ref:`Dictionary`\ ) - :ref:`Dictionary` **get_member_keyword_colors**\ (\ ) Sets the member keyword colors. All existing member keyword will be removed. The :ref:`Dictionary` key is the member keyword. The value is the member keyword color. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_property_member_variable_color: .. rst-class:: classref-property :ref:`Color` **member_variable_color** = ``Color(0, 0, 0, 1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_member_variable_color**\ (\ value\: :ref:`Color`\ ) - :ref:`Color` **get_member_variable_color**\ (\ ) Sets color for member variables. A member variable is non-keyword, non-function string proceeded with a '.'. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_property_number_color: .. rst-class:: classref-property :ref:`Color` **number_color** = ``Color(0, 0, 0, 1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_number_color**\ (\ value\: :ref:`Color`\ ) - :ref:`Color` **get_number_color**\ (\ ) Sets the color for numbers. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_property_symbol_color: .. rst-class:: classref-property :ref:`Color` **symbol_color** = ``Color(0, 0, 0, 1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_symbol_color**\ (\ value\: :ref:`Color`\ ) - :ref:`Color` **get_symbol_color**\ (\ ) Sets the color for symbols. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_CodeHighlighter_method_add_color_region: .. rst-class:: classref-method |void| **add_color_region**\ (\ start_key\: :ref:`String`, end_key\: :ref:`String`, color\: :ref:`Color`, line_only\: :ref:`bool` = false\ ) :ref:`🔗` Adds a color region (such as for comments or strings) from ``start_key`` to ``end_key``. Both keys should be symbols, and ``start_key`` must not be shared with other delimiters. If ``line_only`` is ``true`` or ``end_key`` is an empty :ref:`String`, the region does not carry over to the next line. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_add_keyword_color: .. rst-class:: classref-method |void| **add_keyword_color**\ (\ keyword\: :ref:`String`, color\: :ref:`Color`\ ) :ref:`🔗` Sets the color for a keyword. The keyword cannot contain any symbols except '\_'. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_add_member_keyword_color: .. rst-class:: classref-method |void| **add_member_keyword_color**\ (\ member_keyword\: :ref:`String`, color\: :ref:`Color`\ ) :ref:`🔗` Sets the color for a member keyword. The member keyword cannot contain any symbols except '\_'. It will not be highlighted if preceded by a '.'. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_clear_color_regions: .. rst-class:: classref-method |void| **clear_color_regions**\ (\ ) :ref:`🔗` Removes all color regions. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_clear_keyword_colors: .. rst-class:: classref-method |void| **clear_keyword_colors**\ (\ ) :ref:`🔗` Removes all keywords. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_clear_member_keyword_colors: .. rst-class:: classref-method |void| **clear_member_keyword_colors**\ (\ ) :ref:`🔗` Removes all member keywords. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_get_keyword_color: .. rst-class:: classref-method :ref:`Color` **get_keyword_color**\ (\ keyword\: :ref:`String`\ ) |const| :ref:`🔗` Returns the color for a keyword. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_get_member_keyword_color: .. rst-class:: classref-method :ref:`Color` **get_member_keyword_color**\ (\ member_keyword\: :ref:`String`\ ) |const| :ref:`🔗` Returns the color for a member keyword. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_has_color_region: .. rst-class:: classref-method :ref:`bool` **has_color_region**\ (\ start_key\: :ref:`String`\ ) |const| :ref:`🔗` Returns ``true`` if the start key exists, else ``false``. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_has_keyword_color: .. rst-class:: classref-method :ref:`bool` **has_keyword_color**\ (\ keyword\: :ref:`String`\ ) |const| :ref:`🔗` Returns ``true`` if the keyword exists, else ``false``. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_has_member_keyword_color: .. rst-class:: classref-method :ref:`bool` **has_member_keyword_color**\ (\ member_keyword\: :ref:`String`\ ) |const| :ref:`🔗` Returns ``true`` if the member keyword exists, else ``false``. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_remove_color_region: .. rst-class:: classref-method |void| **remove_color_region**\ (\ start_key\: :ref:`String`\ ) :ref:`🔗` Removes the color region that uses that start key. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_remove_keyword_color: .. rst-class:: classref-method |void| **remove_keyword_color**\ (\ keyword\: :ref:`String`\ ) :ref:`🔗` Removes the keyword. .. rst-class:: classref-item-separator ---- .. _class_CodeHighlighter_method_remove_member_keyword_color: .. rst-class:: classref-method |void| **remove_member_keyword_color**\ (\ member_keyword\: :ref:`String`\ ) :ref:`🔗` Removes the member keyword. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`