class_codehighlighter.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/CodeHighlighter.xml.
  6. .. _class_CodeHighlighter:
  7. CodeHighlighter
  8. ===============
  9. **Inherits:** :ref:`SyntaxHighlighter<class_SyntaxHighlighter>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A syntax highlighter intended for code.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. By adjusting various properties of this resource, you can change the colors of strings, comments, numbers, and other text patterns inside a :ref:`TextEdit<class_TextEdit>` control.
  15. .. rst-class:: classref-reftable-group
  16. Properties
  17. ----------
  18. .. table::
  19. :widths: auto
  20. +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+
  21. | :ref:`Dictionary<class_Dictionary>` | :ref:`color_regions<class_CodeHighlighter_property_color_regions>` | ``{}`` |
  22. +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+
  23. | :ref:`Color<class_Color>` | :ref:`function_color<class_CodeHighlighter_property_function_color>` | ``Color(0, 0, 0, 1)`` |
  24. +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+
  25. | :ref:`Dictionary<class_Dictionary>` | :ref:`keyword_colors<class_CodeHighlighter_property_keyword_colors>` | ``{}`` |
  26. +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+
  27. | :ref:`Dictionary<class_Dictionary>` | :ref:`member_keyword_colors<class_CodeHighlighter_property_member_keyword_colors>` | ``{}`` |
  28. +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+
  29. | :ref:`Color<class_Color>` | :ref:`member_variable_color<class_CodeHighlighter_property_member_variable_color>` | ``Color(0, 0, 0, 1)`` |
  30. +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+
  31. | :ref:`Color<class_Color>` | :ref:`number_color<class_CodeHighlighter_property_number_color>` | ``Color(0, 0, 0, 1)`` |
  32. +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+
  33. | :ref:`Color<class_Color>` | :ref:`symbol_color<class_CodeHighlighter_property_symbol_color>` | ``Color(0, 0, 0, 1)`` |
  34. +-------------------------------------+------------------------------------------------------------------------------------+-----------------------+
  35. .. rst-class:: classref-reftable-group
  36. Methods
  37. -------
  38. .. table::
  39. :widths: auto
  40. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | |void| | :ref:`add_color_region<class_CodeHighlighter_method_add_color_region>`\ (\ start_key\: :ref:`String<class_String>`, end_key\: :ref:`String<class_String>`, color\: :ref:`Color<class_Color>`, line_only\: :ref:`bool<class_bool>` = false\ ) |
  42. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | |void| | :ref:`add_keyword_color<class_CodeHighlighter_method_add_keyword_color>`\ (\ keyword\: :ref:`String<class_String>`, color\: :ref:`Color<class_Color>`\ ) |
  44. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | |void| | :ref:`add_member_keyword_color<class_CodeHighlighter_method_add_member_keyword_color>`\ (\ member_keyword\: :ref:`String<class_String>`, color\: :ref:`Color<class_Color>`\ ) |
  46. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | |void| | :ref:`clear_color_regions<class_CodeHighlighter_method_clear_color_regions>`\ (\ ) |
  48. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | |void| | :ref:`clear_keyword_colors<class_CodeHighlighter_method_clear_keyword_colors>`\ (\ ) |
  50. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | |void| | :ref:`clear_member_keyword_colors<class_CodeHighlighter_method_clear_member_keyword_colors>`\ (\ ) |
  52. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Color<class_Color>` | :ref:`get_keyword_color<class_CodeHighlighter_method_get_keyword_color>`\ (\ keyword\: :ref:`String<class_String>`\ ) |const| |
  54. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Color<class_Color>` | :ref:`get_member_keyword_color<class_CodeHighlighter_method_get_member_keyword_color>`\ (\ member_keyword\: :ref:`String<class_String>`\ ) |const| |
  56. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`bool<class_bool>` | :ref:`has_color_region<class_CodeHighlighter_method_has_color_region>`\ (\ start_key\: :ref:`String<class_String>`\ ) |const| |
  58. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`bool<class_bool>` | :ref:`has_keyword_color<class_CodeHighlighter_method_has_keyword_color>`\ (\ keyword\: :ref:`String<class_String>`\ ) |const| |
  60. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`bool<class_bool>` | :ref:`has_member_keyword_color<class_CodeHighlighter_method_has_member_keyword_color>`\ (\ member_keyword\: :ref:`String<class_String>`\ ) |const| |
  62. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | |void| | :ref:`remove_color_region<class_CodeHighlighter_method_remove_color_region>`\ (\ start_key\: :ref:`String<class_String>`\ ) |
  64. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | |void| | :ref:`remove_keyword_color<class_CodeHighlighter_method_remove_keyword_color>`\ (\ keyword\: :ref:`String<class_String>`\ ) |
  66. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | |void| | :ref:`remove_member_keyword_color<class_CodeHighlighter_method_remove_member_keyword_color>`\ (\ member_keyword\: :ref:`String<class_String>`\ ) |
  68. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. .. rst-class:: classref-section-separator
  70. ----
  71. .. rst-class:: classref-descriptions-group
  72. Property Descriptions
  73. ---------------------
  74. .. _class_CodeHighlighter_property_color_regions:
  75. .. rst-class:: classref-property
  76. :ref:`Dictionary<class_Dictionary>` **color_regions** = ``{}`` :ref:`🔗<class_CodeHighlighter_property_color_regions>`
  77. .. rst-class:: classref-property-setget
  78. - |void| **set_color_regions**\ (\ value\: :ref:`Dictionary<class_Dictionary>`\ )
  79. - :ref:`Dictionary<class_Dictionary>` **get_color_regions**\ (\ )
  80. Sets the color regions. All existing regions will be removed. The :ref:`Dictionary<class_Dictionary>` key is the region start and end key, separated by a space. The value is the region color.
  81. .. rst-class:: classref-item-separator
  82. ----
  83. .. _class_CodeHighlighter_property_function_color:
  84. .. rst-class:: classref-property
  85. :ref:`Color<class_Color>` **function_color** = ``Color(0, 0, 0, 1)`` :ref:`🔗<class_CodeHighlighter_property_function_color>`
  86. .. rst-class:: classref-property-setget
  87. - |void| **set_function_color**\ (\ value\: :ref:`Color<class_Color>`\ )
  88. - :ref:`Color<class_Color>` **get_function_color**\ (\ )
  89. Sets color for functions. A function is a non-keyword string followed by a '('.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_CodeHighlighter_property_keyword_colors:
  93. .. rst-class:: classref-property
  94. :ref:`Dictionary<class_Dictionary>` **keyword_colors** = ``{}`` :ref:`🔗<class_CodeHighlighter_property_keyword_colors>`
  95. .. rst-class:: classref-property-setget
  96. - |void| **set_keyword_colors**\ (\ value\: :ref:`Dictionary<class_Dictionary>`\ )
  97. - :ref:`Dictionary<class_Dictionary>` **get_keyword_colors**\ (\ )
  98. Sets the keyword colors. All existing keywords will be removed. The :ref:`Dictionary<class_Dictionary>` key is the keyword. The value is the keyword color.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_CodeHighlighter_property_member_keyword_colors:
  102. .. rst-class:: classref-property
  103. :ref:`Dictionary<class_Dictionary>` **member_keyword_colors** = ``{}`` :ref:`🔗<class_CodeHighlighter_property_member_keyword_colors>`
  104. .. rst-class:: classref-property-setget
  105. - |void| **set_member_keyword_colors**\ (\ value\: :ref:`Dictionary<class_Dictionary>`\ )
  106. - :ref:`Dictionary<class_Dictionary>` **get_member_keyword_colors**\ (\ )
  107. Sets the member keyword colors. All existing member keyword will be removed. The :ref:`Dictionary<class_Dictionary>` key is the member keyword. The value is the member keyword color.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_CodeHighlighter_property_member_variable_color:
  111. .. rst-class:: classref-property
  112. :ref:`Color<class_Color>` **member_variable_color** = ``Color(0, 0, 0, 1)`` :ref:`🔗<class_CodeHighlighter_property_member_variable_color>`
  113. .. rst-class:: classref-property-setget
  114. - |void| **set_member_variable_color**\ (\ value\: :ref:`Color<class_Color>`\ )
  115. - :ref:`Color<class_Color>` **get_member_variable_color**\ (\ )
  116. Sets color for member variables. A member variable is non-keyword, non-function string proceeded with a '.'.
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_CodeHighlighter_property_number_color:
  120. .. rst-class:: classref-property
  121. :ref:`Color<class_Color>` **number_color** = ``Color(0, 0, 0, 1)`` :ref:`🔗<class_CodeHighlighter_property_number_color>`
  122. .. rst-class:: classref-property-setget
  123. - |void| **set_number_color**\ (\ value\: :ref:`Color<class_Color>`\ )
  124. - :ref:`Color<class_Color>` **get_number_color**\ (\ )
  125. Sets the color for numbers.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_CodeHighlighter_property_symbol_color:
  129. .. rst-class:: classref-property
  130. :ref:`Color<class_Color>` **symbol_color** = ``Color(0, 0, 0, 1)`` :ref:`🔗<class_CodeHighlighter_property_symbol_color>`
  131. .. rst-class:: classref-property-setget
  132. - |void| **set_symbol_color**\ (\ value\: :ref:`Color<class_Color>`\ )
  133. - :ref:`Color<class_Color>` **get_symbol_color**\ (\ )
  134. Sets the color for symbols.
  135. .. rst-class:: classref-section-separator
  136. ----
  137. .. rst-class:: classref-descriptions-group
  138. Method Descriptions
  139. -------------------
  140. .. _class_CodeHighlighter_method_add_color_region:
  141. .. rst-class:: classref-method
  142. |void| **add_color_region**\ (\ start_key\: :ref:`String<class_String>`, end_key\: :ref:`String<class_String>`, color\: :ref:`Color<class_Color>`, line_only\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_CodeHighlighter_method_add_color_region>`
  143. 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.
  144. If ``line_only`` is ``true`` or ``end_key`` is an empty :ref:`String<class_String>`, the region does not carry over to the next line.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_CodeHighlighter_method_add_keyword_color:
  148. .. rst-class:: classref-method
  149. |void| **add_keyword_color**\ (\ keyword\: :ref:`String<class_String>`, color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_CodeHighlighter_method_add_keyword_color>`
  150. Sets the color for a keyword.
  151. The keyword cannot contain any symbols except '\_'.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_CodeHighlighter_method_add_member_keyword_color:
  155. .. rst-class:: classref-method
  156. |void| **add_member_keyword_color**\ (\ member_keyword\: :ref:`String<class_String>`, color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_CodeHighlighter_method_add_member_keyword_color>`
  157. Sets the color for a member keyword.
  158. The member keyword cannot contain any symbols except '\_'.
  159. It will not be highlighted if preceded by a '.'.
  160. .. rst-class:: classref-item-separator
  161. ----
  162. .. _class_CodeHighlighter_method_clear_color_regions:
  163. .. rst-class:: classref-method
  164. |void| **clear_color_regions**\ (\ ) :ref:`🔗<class_CodeHighlighter_method_clear_color_regions>`
  165. Removes all color regions.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_CodeHighlighter_method_clear_keyword_colors:
  169. .. rst-class:: classref-method
  170. |void| **clear_keyword_colors**\ (\ ) :ref:`🔗<class_CodeHighlighter_method_clear_keyword_colors>`
  171. Removes all keywords.
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. _class_CodeHighlighter_method_clear_member_keyword_colors:
  175. .. rst-class:: classref-method
  176. |void| **clear_member_keyword_colors**\ (\ ) :ref:`🔗<class_CodeHighlighter_method_clear_member_keyword_colors>`
  177. Removes all member keywords.
  178. .. rst-class:: classref-item-separator
  179. ----
  180. .. _class_CodeHighlighter_method_get_keyword_color:
  181. .. rst-class:: classref-method
  182. :ref:`Color<class_Color>` **get_keyword_color**\ (\ keyword\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_CodeHighlighter_method_get_keyword_color>`
  183. Returns the color for a keyword.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_CodeHighlighter_method_get_member_keyword_color:
  187. .. rst-class:: classref-method
  188. :ref:`Color<class_Color>` **get_member_keyword_color**\ (\ member_keyword\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_CodeHighlighter_method_get_member_keyword_color>`
  189. Returns the color for a member keyword.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_CodeHighlighter_method_has_color_region:
  193. .. rst-class:: classref-method
  194. :ref:`bool<class_bool>` **has_color_region**\ (\ start_key\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_CodeHighlighter_method_has_color_region>`
  195. Returns ``true`` if the start key exists, else ``false``.
  196. .. rst-class:: classref-item-separator
  197. ----
  198. .. _class_CodeHighlighter_method_has_keyword_color:
  199. .. rst-class:: classref-method
  200. :ref:`bool<class_bool>` **has_keyword_color**\ (\ keyword\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_CodeHighlighter_method_has_keyword_color>`
  201. Returns ``true`` if the keyword exists, else ``false``.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_CodeHighlighter_method_has_member_keyword_color:
  205. .. rst-class:: classref-method
  206. :ref:`bool<class_bool>` **has_member_keyword_color**\ (\ member_keyword\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_CodeHighlighter_method_has_member_keyword_color>`
  207. Returns ``true`` if the member keyword exists, else ``false``.
  208. .. rst-class:: classref-item-separator
  209. ----
  210. .. _class_CodeHighlighter_method_remove_color_region:
  211. .. rst-class:: classref-method
  212. |void| **remove_color_region**\ (\ start_key\: :ref:`String<class_String>`\ ) :ref:`🔗<class_CodeHighlighter_method_remove_color_region>`
  213. Removes the color region that uses that start key.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_CodeHighlighter_method_remove_keyword_color:
  217. .. rst-class:: classref-method
  218. |void| **remove_keyword_color**\ (\ keyword\: :ref:`String<class_String>`\ ) :ref:`🔗<class_CodeHighlighter_method_remove_keyword_color>`
  219. Removes the keyword.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_CodeHighlighter_method_remove_member_keyword_color:
  223. .. rst-class:: classref-method
  224. |void| **remove_member_keyword_color**\ (\ member_keyword\: :ref:`String<class_String>`\ ) :ref:`🔗<class_CodeHighlighter_method_remove_member_keyword_color>`
  225. Removes the member keyword.
  226. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  227. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  228. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  229. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  230. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  231. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  232. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  233. .. |void| replace:: :abbr:`void (No return value.)`