class_syntaxhighlighter.rst 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the SyntaxHighlighter.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_SyntaxHighlighter:
  6. SyntaxHighlighter
  7. =================
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`CodeHighlighter<class_CodeHighlighter>`, :ref:`EditorSyntaxHighlighter<class_EditorSyntaxHighlighter>`
  10. Base Syntax highlighter resource for :ref:`TextEdit<class_TextEdit>`.
  11. Description
  12. -----------
  13. Base syntax highlighter resource all syntax highlighters extend from, provides syntax highlighting data to :ref:`TextEdit<class_TextEdit>`.
  14. The associated :ref:`TextEdit<class_TextEdit>` node will call into the ``SyntaxHighlighter`` on a as needed basis.
  15. \ **Note:** Each Syntax highlighter instance should not be shared across multiple :ref:`TextEdit<class_TextEdit>` nodes.
  16. Methods
  17. -------
  18. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`_clear_highlighting_cache<class_SyntaxHighlighter_method__clear_highlighting_cache>` **(** **)** |virtual| |
  20. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Dictionary<class_Dictionary>` | :ref:`_get_line_syntax_highlighting<class_SyntaxHighlighter_method__get_line_syntax_highlighting>` **(** :ref:`int<class_int>` line **)** |virtual| |const| |
  22. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`_update_cache<class_SyntaxHighlighter_method__update_cache>` **(** **)** |virtual| |
  24. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`clear_highlighting_cache<class_SyntaxHighlighter_method_clear_highlighting_cache>` **(** **)** |
  26. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_line_syntax_highlighting<class_SyntaxHighlighter_method_get_line_syntax_highlighting>` **(** :ref:`int<class_int>` line **)** |
  28. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`TextEdit<class_TextEdit>` | :ref:`get_text_edit<class_SyntaxHighlighter_method_get_text_edit>` **(** **)** |
  30. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`update_cache<class_SyntaxHighlighter_method_update_cache>` **(** **)** |
  32. +-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. Method Descriptions
  34. -------------------
  35. .. _class_SyntaxHighlighter_method__clear_highlighting_cache:
  36. - void **_clear_highlighting_cache** **(** **)** |virtual|
  37. Virtual method which can be overridden to clear any local caches.
  38. ----
  39. .. _class_SyntaxHighlighter_method__get_line_syntax_highlighting:
  40. - :ref:`Dictionary<class_Dictionary>` **_get_line_syntax_highlighting** **(** :ref:`int<class_int>` line **)** |virtual| |const|
  41. Virtual method which can be overridden to return syntax highlighting data.
  42. See :ref:`get_line_syntax_highlighting<class_SyntaxHighlighter_method_get_line_syntax_highlighting>` for more details.
  43. ----
  44. .. _class_SyntaxHighlighter_method__update_cache:
  45. - void **_update_cache** **(** **)** |virtual|
  46. Virtual method which can be overridden to update any local caches.
  47. ----
  48. .. _class_SyntaxHighlighter_method_clear_highlighting_cache:
  49. - void **clear_highlighting_cache** **(** **)**
  50. Clears all cached syntax highlighting data.
  51. Then calls overridable method :ref:`_clear_highlighting_cache<class_SyntaxHighlighter_method__clear_highlighting_cache>`.
  52. ----
  53. .. _class_SyntaxHighlighter_method_get_line_syntax_highlighting:
  54. - :ref:`Dictionary<class_Dictionary>` **get_line_syntax_highlighting** **(** :ref:`int<class_int>` line **)**
  55. Returns syntax highlighting data for a single line. If the line is not cached, calls :ref:`_get_line_syntax_highlighting<class_SyntaxHighlighter_method__get_line_syntax_highlighting>` to calculate the data.
  56. The return :ref:`Dictionary<class_Dictionary>` is column number to :ref:`Dictionary<class_Dictionary>`. The column number notes the start of a region, the region will end if another region is found, or at the end of the line. The nested :ref:`Dictionary<class_Dictionary>` contains the data for that region, currently only the key "color" is supported.
  57. \ **Example return:**\
  58. ::
  59. var color_map = {
  60. 0: {
  61. "color": Color(1, 0, 0)
  62. },
  63. 5: {
  64. "color": Color(0, 1, 0)
  65. }
  66. }
  67. This will color columns 0-4 red, and columns 5-eol in green.
  68. ----
  69. .. _class_SyntaxHighlighter_method_get_text_edit:
  70. - :ref:`TextEdit<class_TextEdit>` **get_text_edit** **(** **)**
  71. Returns the associated :ref:`TextEdit<class_TextEdit>` node.
  72. ----
  73. .. _class_SyntaxHighlighter_method_update_cache:
  74. - void **update_cache** **(** **)**
  75. Clears then updates the ``SyntaxHighlighter`` caches. Override :ref:`_update_cache<class_SyntaxHighlighter_method__update_cache>` for a callback.
  76. \ **Note:** This is called automatically when the associated :ref:`TextEdit<class_TextEdit>` node, updates its own cache.
  77. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  78. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  79. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  80. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  81. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  82. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`