class_codehighlighter.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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>` **(** :ref:`String<class_String>` start_key, :ref:`String<class_String>` end_key, :ref:`Color<class_Color>` color, :ref:`bool<class_bool>` line_only=false **)** |
  42. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`add_keyword_color<class_CodeHighlighter_method_add_keyword_color>` **(** :ref:`String<class_String>` keyword, :ref:`Color<class_Color>` color **)** |
  44. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`add_member_keyword_color<class_CodeHighlighter_method_add_member_keyword_color>` **(** :ref:`String<class_String>` member_keyword, :ref:`Color<class_Color>` 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>` **(** :ref:`String<class_String>` keyword **)** |const| |
  54. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Color<class_Color>` | :ref:`get_member_keyword_color<class_CodeHighlighter_method_get_member_keyword_color>` **(** :ref:`String<class_String>` member_keyword **)** |const| |
  56. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`bool<class_bool>` | :ref:`has_color_region<class_CodeHighlighter_method_has_color_region>` **(** :ref:`String<class_String>` start_key **)** |const| |
  58. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`bool<class_bool>` | :ref:`has_keyword_color<class_CodeHighlighter_method_has_keyword_color>` **(** :ref:`String<class_String>` keyword **)** |const| |
  60. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`bool<class_bool>` | :ref:`has_member_keyword_color<class_CodeHighlighter_method_has_member_keyword_color>` **(** :ref:`String<class_String>` member_keyword **)** |const| |
  62. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`remove_color_region<class_CodeHighlighter_method_remove_color_region>` **(** :ref:`String<class_String>` start_key **)** |
  64. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`remove_keyword_color<class_CodeHighlighter_method_remove_keyword_color>` **(** :ref:`String<class_String>` keyword **)** |
  66. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`remove_member_keyword_color<class_CodeHighlighter_method_remove_member_keyword_color>` **(** :ref:`String<class_String>` member_keyword **)** |
  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** = ``{}``
  77. .. rst-class:: classref-property-setget
  78. - void **set_color_regions** **(** :ref:`Dictionary<class_Dictionary>` value **)**
  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)``
  86. .. rst-class:: classref-property-setget
  87. - void **set_function_color** **(** :ref:`Color<class_Color>` value **)**
  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** = ``{}``
  95. .. rst-class:: classref-property-setget
  96. - void **set_keyword_colors** **(** :ref:`Dictionary<class_Dictionary>` value **)**
  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** = ``{}``
  104. .. rst-class:: classref-property-setget
  105. - void **set_member_keyword_colors** **(** :ref:`Dictionary<class_Dictionary>` value **)**
  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)``
  113. .. rst-class:: classref-property-setget
  114. - void **set_member_variable_color** **(** :ref:`Color<class_Color>` value **)**
  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)``
  122. .. rst-class:: classref-property-setget
  123. - void **set_number_color** **(** :ref:`Color<class_Color>` value **)**
  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)``
  131. .. rst-class:: classref-property-setget
  132. - void **set_symbol_color** **(** :ref:`Color<class_Color>` value **)**
  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** **(** :ref:`String<class_String>` start_key, :ref:`String<class_String>` end_key, :ref:`Color<class_Color>` color, :ref:`bool<class_bool>` line_only=false **)**
  143. Adds a color region such as comments or strings.
  144. Both the start and end keys must be symbols. Only the start key has to be unique.
  145. \ ``line_only`` denotes if the region should continue until the end of the line or carry over on to the next line. If the end key is blank this is automatically set to ``true``.
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_CodeHighlighter_method_add_keyword_color:
  149. .. rst-class:: classref-method
  150. void **add_keyword_color** **(** :ref:`String<class_String>` keyword, :ref:`Color<class_Color>` color **)**
  151. Sets the color for a keyword.
  152. The keyword cannot contain any symbols except '\_'.
  153. .. rst-class:: classref-item-separator
  154. ----
  155. .. _class_CodeHighlighter_method_add_member_keyword_color:
  156. .. rst-class:: classref-method
  157. void **add_member_keyword_color** **(** :ref:`String<class_String>` member_keyword, :ref:`Color<class_Color>` color **)**
  158. Sets the color for a member keyword.
  159. The member keyword cannot contain any symbols except '\_'.
  160. It will not be highlighted if preceded by a '.'.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _class_CodeHighlighter_method_clear_color_regions:
  164. .. rst-class:: classref-method
  165. void **clear_color_regions** **(** **)**
  166. Removes all color regions.
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_CodeHighlighter_method_clear_keyword_colors:
  170. .. rst-class:: classref-method
  171. void **clear_keyword_colors** **(** **)**
  172. Removes all keywords.
  173. .. rst-class:: classref-item-separator
  174. ----
  175. .. _class_CodeHighlighter_method_clear_member_keyword_colors:
  176. .. rst-class:: classref-method
  177. void **clear_member_keyword_colors** **(** **)**
  178. Removes all member keywords.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_CodeHighlighter_method_get_keyword_color:
  182. .. rst-class:: classref-method
  183. :ref:`Color<class_Color>` **get_keyword_color** **(** :ref:`String<class_String>` keyword **)** |const|
  184. Returns the color for a keyword.
  185. .. rst-class:: classref-item-separator
  186. ----
  187. .. _class_CodeHighlighter_method_get_member_keyword_color:
  188. .. rst-class:: classref-method
  189. :ref:`Color<class_Color>` **get_member_keyword_color** **(** :ref:`String<class_String>` member_keyword **)** |const|
  190. Returns the color for a member keyword.
  191. .. rst-class:: classref-item-separator
  192. ----
  193. .. _class_CodeHighlighter_method_has_color_region:
  194. .. rst-class:: classref-method
  195. :ref:`bool<class_bool>` **has_color_region** **(** :ref:`String<class_String>` start_key **)** |const|
  196. Returns ``true`` if the start key exists, else ``false``.
  197. .. rst-class:: classref-item-separator
  198. ----
  199. .. _class_CodeHighlighter_method_has_keyword_color:
  200. .. rst-class:: classref-method
  201. :ref:`bool<class_bool>` **has_keyword_color** **(** :ref:`String<class_String>` keyword **)** |const|
  202. Returns ``true`` if the keyword exists, else ``false``.
  203. .. rst-class:: classref-item-separator
  204. ----
  205. .. _class_CodeHighlighter_method_has_member_keyword_color:
  206. .. rst-class:: classref-method
  207. :ref:`bool<class_bool>` **has_member_keyword_color** **(** :ref:`String<class_String>` member_keyword **)** |const|
  208. Returns ``true`` if the member keyword exists, else ``false``.
  209. .. rst-class:: classref-item-separator
  210. ----
  211. .. _class_CodeHighlighter_method_remove_color_region:
  212. .. rst-class:: classref-method
  213. void **remove_color_region** **(** :ref:`String<class_String>` start_key **)**
  214. Removes the color region that uses that start key.
  215. .. rst-class:: classref-item-separator
  216. ----
  217. .. _class_CodeHighlighter_method_remove_keyword_color:
  218. .. rst-class:: classref-method
  219. void **remove_keyword_color** **(** :ref:`String<class_String>` keyword **)**
  220. Removes the keyword.
  221. .. rst-class:: classref-item-separator
  222. ----
  223. .. _class_CodeHighlighter_method_remove_member_keyword_color:
  224. .. rst-class:: classref-method
  225. void **remove_member_keyword_color** **(** :ref:`String<class_String>` member_keyword **)**
  226. Removes the member keyword.
  227. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  228. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  229. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  230. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  231. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  232. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  233. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`