class_textedit.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_TextEdit:
  4. TextEdit
  5. ========
  6. **Inherits:** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Multiline text editing control.
  11. Member Functions
  12. ----------------
  13. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`set_text<class_TextEdit_set_text>` **(** :ref:`String<class_string>` text **)** |
  15. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`insert_text_at_cursor<class_TextEdit_insert_text_at_cursor>` **(** :ref:`String<class_string>` text **)** |
  17. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`int<class_int>` | :ref:`get_line_count<class_TextEdit_get_line_count>` **(** **)** const |
  19. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`String<class_string>` | :ref:`get_text<class_TextEdit_get_text>` **(** **)** |
  21. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`String<class_string>` | :ref:`get_line<class_TextEdit_get_line>` **(** :ref:`int<class_int>` line **)** const |
  23. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`cursor_set_column<class_TextEdit_cursor_set_column>` **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` adjust_viewport=false **)** |
  25. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`cursor_set_line<class_TextEdit_cursor_set_line>` **(** :ref:`int<class_int>` line, :ref:`bool<class_bool>` adjust_viewport=false **)** |
  27. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`int<class_int>` | :ref:`cursor_get_column<class_TextEdit_cursor_get_column>` **(** **)** const |
  29. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`cursor_get_line<class_TextEdit_cursor_get_line>` **(** **)** const |
  31. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_readonly<class_TextEdit_set_readonly>` **(** :ref:`bool<class_bool>` enable **)** |
  33. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_wrap<class_TextEdit_set_wrap>` **(** :ref:`bool<class_bool>` enable **)** |
  35. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_max_chars<class_TextEdit_set_max_chars>` **(** :ref:`int<class_int>` amount **)** |
  37. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`cut<class_TextEdit_cut>` **(** **)** |
  39. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`copy<class_TextEdit_copy>` **(** **)** |
  41. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`paste<class_TextEdit_paste>` **(** **)** |
  43. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`select_all<class_TextEdit_select_all>` **(** **)** |
  45. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`select<class_TextEdit_select>` **(** :ref:`int<class_int>` from_line, :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_line, :ref:`int<class_int>` to_column **)** |
  47. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`is_selection_active<class_TextEdit_is_selection_active>` **(** **)** const |
  49. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`int<class_int>` | :ref:`get_selection_from_line<class_TextEdit_get_selection_from_line>` **(** **)** const |
  51. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`int<class_int>` | :ref:`get_selection_from_column<class_TextEdit_get_selection_from_column>` **(** **)** const |
  53. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`int<class_int>` | :ref:`get_selection_to_line<class_TextEdit_get_selection_to_line>` **(** **)** const |
  55. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`int<class_int>` | :ref:`get_selection_to_column<class_TextEdit_get_selection_to_column>` **(** **)** const |
  57. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`String<class_string>` | :ref:`get_selection_text<class_TextEdit_get_selection_text>` **(** **)** const |
  59. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`String<class_string>` | :ref:`get_word_under_cursor<class_TextEdit_get_word_under_cursor>` **(** **)** const |
  61. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`IntArray<class_intarray>` | :ref:`search<class_TextEdit_search>` **(** :ref:`String<class_string>` flags, :ref:`int<class_int>` from_line, :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_line **)** const |
  63. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`undo<class_TextEdit_undo>` **(** **)** |
  65. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`redo<class_TextEdit_redo>` **(** **)** |
  67. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`clear_undo_history<class_TextEdit_clear_undo_history>` **(** **)** |
  69. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`set_syntax_coloring<class_TextEdit_set_syntax_coloring>` **(** :ref:`bool<class_bool>` enable **)** |
  71. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`is_syntax_coloring_enabled<class_TextEdit_is_syntax_coloring_enabled>` **(** **)** const |
  73. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`add_keyword_color<class_TextEdit_add_keyword_color>` **(** :ref:`String<class_string>` keyword, :ref:`Color<class_color>` color **)** |
  75. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`add_color_region<class_TextEdit_add_color_region>` **(** :ref:`String<class_string>` begin_key, :ref:`String<class_string>` end_key, :ref:`Color<class_color>` color, :ref:`bool<class_bool>` line_only=false **)** |
  77. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`set_symbol_color<class_TextEdit_set_symbol_color>` **(** :ref:`Color<class_color>` color **)** |
  79. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`set_custom_bg_color<class_TextEdit_set_custom_bg_color>` **(** :ref:`Color<class_color>` color **)** |
  81. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | void | :ref:`clear_colors<class_TextEdit_clear_colors>` **(** **)** |
  83. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. Signals
  85. -------
  86. - **text_changed** **(** **)**
  87. - **cursor_changed** **(** **)**
  88. - **request_completion** **(** **)**
  89. Numeric Constants
  90. -----------------
  91. - **SEARCH_MATCH_CASE** = **1** --- Match case when searching.
  92. - **SEARCH_WHOLE_WORDS** = **2** --- Match whole words when searching.
  93. - **SEARCH_BACKWARDS** = **4** --- Search from end to beginning.
  94. Description
  95. -----------
  96. TextEdit is meant for editing large, multiline text. It also has facilities for editing code, such as syntax highlighting support and multiple levels of undo/redo.
  97. Member Function Description
  98. ---------------------------
  99. .. _class_TextEdit_set_text:
  100. - void **set_text** **(** :ref:`String<class_string>` text **)**
  101. Set the entire text.
  102. .. _class_TextEdit_insert_text_at_cursor:
  103. - void **insert_text_at_cursor** **(** :ref:`String<class_string>` text **)**
  104. Insert a given text at the cursor position.
  105. .. _class_TextEdit_get_line_count:
  106. - :ref:`int<class_int>` **get_line_count** **(** **)** const
  107. Return the amount of total lines in the text.
  108. .. _class_TextEdit_get_text:
  109. - :ref:`String<class_string>` **get_text** **(** **)**
  110. Return the whole text.
  111. .. _class_TextEdit_get_line:
  112. - :ref:`String<class_string>` **get_line** **(** :ref:`int<class_int>` line **)** const
  113. Return the text of a specific line.
  114. .. _class_TextEdit_cursor_set_column:
  115. - void **cursor_set_column** **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` adjust_viewport=false **)**
  116. .. _class_TextEdit_cursor_set_line:
  117. - void **cursor_set_line** **(** :ref:`int<class_int>` line, :ref:`bool<class_bool>` adjust_viewport=false **)**
  118. .. _class_TextEdit_cursor_get_column:
  119. - :ref:`int<class_int>` **cursor_get_column** **(** **)** const
  120. Return the column the editing cursor is at.
  121. .. _class_TextEdit_cursor_get_line:
  122. - :ref:`int<class_int>` **cursor_get_line** **(** **)** const
  123. Return the line the editing cursor is at.
  124. .. _class_TextEdit_set_readonly:
  125. - void **set_readonly** **(** :ref:`bool<class_bool>` enable **)**
  126. Set the text editor as read-only. Text can be displayed but not edited.
  127. .. _class_TextEdit_set_wrap:
  128. - void **set_wrap** **(** :ref:`bool<class_bool>` enable **)**
  129. Enable text wrapping when it goes beyond he edge of what is visible.
  130. .. _class_TextEdit_set_max_chars:
  131. - void **set_max_chars** **(** :ref:`int<class_int>` amount **)**
  132. Set the maximum amount of characters editable.
  133. .. _class_TextEdit_cut:
  134. - void **cut** **(** **)**
  135. Cut the current selection.
  136. .. _class_TextEdit_copy:
  137. - void **copy** **(** **)**
  138. Copy the current selection.
  139. .. _class_TextEdit_paste:
  140. - void **paste** **(** **)**
  141. Paste the current selection.
  142. .. _class_TextEdit_select_all:
  143. - void **select_all** **(** **)**
  144. Select all the text.
  145. .. _class_TextEdit_select:
  146. - void **select** **(** :ref:`int<class_int>` from_line, :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_line, :ref:`int<class_int>` to_column **)**
  147. Perform selection, from line/column to line/column.
  148. .. _class_TextEdit_is_selection_active:
  149. - :ref:`bool<class_bool>` **is_selection_active** **(** **)** const
  150. Return true if the selection is active.
  151. .. _class_TextEdit_get_selection_from_line:
  152. - :ref:`int<class_int>` **get_selection_from_line** **(** **)** const
  153. Return the selection begin line.
  154. .. _class_TextEdit_get_selection_from_column:
  155. - :ref:`int<class_int>` **get_selection_from_column** **(** **)** const
  156. Return the selection begin column.
  157. .. _class_TextEdit_get_selection_to_line:
  158. - :ref:`int<class_int>` **get_selection_to_line** **(** **)** const
  159. Return the selection end line.
  160. .. _class_TextEdit_get_selection_to_column:
  161. - :ref:`int<class_int>` **get_selection_to_column** **(** **)** const
  162. Return the selection end column.
  163. .. _class_TextEdit_get_selection_text:
  164. - :ref:`String<class_string>` **get_selection_text** **(** **)** const
  165. Return the text inside the selection.
  166. .. _class_TextEdit_get_word_under_cursor:
  167. - :ref:`String<class_string>` **get_word_under_cursor** **(** **)** const
  168. .. _class_TextEdit_search:
  169. - :ref:`IntArray<class_intarray>` **search** **(** :ref:`String<class_string>` flags, :ref:`int<class_int>` from_line, :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_line **)** const
  170. Perform a search inside the text. Search flags can be specified in the SEARCH\_\* enum.
  171. .. _class_TextEdit_undo:
  172. - void **undo** **(** **)**
  173. Perform undo operation.
  174. .. _class_TextEdit_redo:
  175. - void **redo** **(** **)**
  176. Perform redo operation.
  177. .. _class_TextEdit_clear_undo_history:
  178. - void **clear_undo_history** **(** **)**
  179. Clear the undo history.
  180. .. _class_TextEdit_set_syntax_coloring:
  181. - void **set_syntax_coloring** **(** :ref:`bool<class_bool>` enable **)**
  182. Set to enable the syntax coloring.
  183. .. _class_TextEdit_is_syntax_coloring_enabled:
  184. - :ref:`bool<class_bool>` **is_syntax_coloring_enabled** **(** **)** const
  185. Return true if the syntax coloring is enabled.
  186. .. _class_TextEdit_add_keyword_color:
  187. - void **add_keyword_color** **(** :ref:`String<class_string>` keyword, :ref:`Color<class_color>` color **)**
  188. Add a keyword and its color.
  189. .. _class_TextEdit_add_color_region:
  190. - void **add_color_region** **(** :ref:`String<class_string>` begin_key, :ref:`String<class_string>` end_key, :ref:`Color<class_color>` color, :ref:`bool<class_bool>` line_only=false **)**
  191. Add color region (given the delimiters) and its colors.
  192. .. _class_TextEdit_set_symbol_color:
  193. - void **set_symbol_color** **(** :ref:`Color<class_color>` color **)**
  194. Set the color for symbols.
  195. .. _class_TextEdit_set_custom_bg_color:
  196. - void **set_custom_bg_color** **(** :ref:`Color<class_color>` color **)**
  197. Set a custom background color. A background color with alpha==0 disables this.
  198. .. _class_TextEdit_clear_colors:
  199. - void **clear_colors** **(** **)**
  200. Clear all the syntax coloring information.