class_textedit.rst 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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:`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 **)** |
  15. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`add_keyword_color<class_TextEdit_add_keyword_color>` **(** :ref:`String<class_string>` keyword, :ref:`Color<class_color>` color **)** |
  17. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`clear_colors<class_TextEdit_clear_colors>` **(** **)** |
  19. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`clear_undo_history<class_TextEdit_clear_undo_history>` **(** **)** |
  21. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`copy<class_TextEdit_copy>` **(** **)** |
  23. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`cursor_get_blink_enabled<class_TextEdit_cursor_get_blink_enabled>` **(** **)** const |
  25. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`float<class_float>` | :ref:`cursor_get_blink_speed<class_TextEdit_cursor_get_blink_speed>` **(** **)** const |
  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. | :ref:`bool<class_bool>` | :ref:`cursor_is_block_mode<class_TextEdit_cursor_is_block_mode>` **(** **)** const |
  33. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`cursor_set_blink_enabled<class_TextEdit_cursor_set_blink_enabled>` **(** :ref:`bool<class_bool>` enable **)** |
  35. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`cursor_set_blink_speed<class_TextEdit_cursor_set_blink_speed>` **(** :ref:`float<class_float>` blink_speed **)** |
  37. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`cursor_set_block_mode<class_TextEdit_cursor_set_block_mode>` **(** :ref:`bool<class_bool>` enable **)** |
  39. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`cursor_set_column<class_TextEdit_cursor_set_column>` **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` adjust_viewport=false **)** |
  41. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`cursor_set_line<class_TextEdit_cursor_set_line>` **(** :ref:`int<class_int>` line, :ref:`bool<class_bool>` adjust_viewport=false **)** |
  43. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`cut<class_TextEdit_cut>` **(** **)** |
  45. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`String<class_string>` | :ref:`get_line<class_TextEdit_get_line>` **(** :ref:`int<class_int>` line **)** const |
  47. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`get_line_count<class_TextEdit_get_line_count>` **(** **)** const |
  49. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`PopupMenu<class_popupmenu>` | :ref:`get_menu<class_TextEdit_get_menu>` **(** **)** 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_from_line<class_TextEdit_get_selection_from_line>` **(** **)** const |
  55. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`String<class_string>` | :ref:`get_selection_text<class_TextEdit_get_selection_text>` **(** **)** const |
  57. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`int<class_int>` | :ref:`get_selection_to_column<class_TextEdit_get_selection_to_column>` **(** **)** const |
  59. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`int<class_int>` | :ref:`get_selection_to_line<class_TextEdit_get_selection_to_line>` **(** **)** const |
  61. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`String<class_string>` | :ref:`get_text<class_TextEdit_get_text>` **(** **)** |
  63. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`String<class_string>` | :ref:`get_word_under_cursor<class_TextEdit_get_word_under_cursor>` **(** **)** const |
  65. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`insert_text_at_cursor<class_TextEdit_insert_text_at_cursor>` **(** :ref:`String<class_string>` text **)** |
  67. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`bool<class_bool>` | :ref:`is_highlight_all_occurrences_enabled<class_TextEdit_is_highlight_all_occurrences_enabled>` **(** **)** const |
  69. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`bool<class_bool>` | :ref:`is_selection_active<class_TextEdit_is_selection_active>` **(** **)** const |
  71. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`is_show_line_numbers_enabled<class_TextEdit_is_show_line_numbers_enabled>` **(** **)** const |
  73. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`bool<class_bool>` | :ref:`is_syntax_coloring_enabled<class_TextEdit_is_syntax_coloring_enabled>` **(** **)** const |
  75. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`menu_option<class_TextEdit_menu_option>` **(** :ref:`int<class_int>` arg0 **)** |
  77. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`paste<class_TextEdit_paste>` **(** **)** |
  79. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`redo<class_TextEdit_redo>` **(** **)** |
  81. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :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 |
  83. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | 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 **)** |
  85. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | void | :ref:`select_all<class_TextEdit_select_all>` **(** **)** |
  87. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | void | :ref:`set_custom_bg_color<class_TextEdit_set_custom_bg_color>` **(** :ref:`Color<class_color>` color **)** |
  89. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`set_highlight_all_occurrences<class_TextEdit_set_highlight_all_occurrences>` **(** :ref:`bool<class_bool>` enable **)** |
  91. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`set_max_chars<class_TextEdit_set_max_chars>` **(** :ref:`int<class_int>` amount **)** |
  93. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | void | :ref:`set_readonly<class_TextEdit_set_readonly>` **(** :ref:`bool<class_bool>` enable **)** |
  95. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | void | :ref:`set_show_line_numbers<class_TextEdit_set_show_line_numbers>` **(** :ref:`bool<class_bool>` enable **)** |
  97. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | void | :ref:`set_symbol_color<class_TextEdit_set_symbol_color>` **(** :ref:`Color<class_color>` color **)** |
  99. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | void | :ref:`set_syntax_coloring<class_TextEdit_set_syntax_coloring>` **(** :ref:`bool<class_bool>` enable **)** |
  101. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | void | :ref:`set_text<class_TextEdit_set_text>` **(** :ref:`String<class_string>` text **)** |
  103. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | void | :ref:`set_wrap<class_TextEdit_set_wrap>` **(** :ref:`bool<class_bool>` enable **)** |
  105. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | void | :ref:`undo<class_TextEdit_undo>` **(** **)** |
  107. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. Signals
  109. -------
  110. - **breakpoint_toggled** **(** :ref:`int<class_int>` row **)**
  111. Emitted when a breakpoint is placed via the breakpoint gutter.
  112. - **cursor_changed** **(** **)**
  113. Emitted when the cursor changes.
  114. - **request_completion** **(** **)**
  115. - **text_changed** **(** **)**
  116. Emitted when the text changes.
  117. Numeric Constants
  118. -----------------
  119. - **SEARCH_MATCH_CASE** = **1** --- Match case when searching.
  120. - **SEARCH_WHOLE_WORDS** = **2** --- Match whole words when searching.
  121. - **SEARCH_BACKWARDS** = **4** --- Search from end to beginning.
  122. - **MENU_CUT** = **0**
  123. - **MENU_COPY** = **1**
  124. - **MENU_PASTE** = **2**
  125. - **MENU_CLEAR** = **3**
  126. - **MENU_SELECT_ALL** = **4**
  127. - **MENU_UNDO** = **5**
  128. - **MENU_MAX** = **6**
  129. Description
  130. -----------
  131. 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.
  132. Member Function Description
  133. ---------------------------
  134. .. _class_TextEdit_add_color_region:
  135. - 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 **)**
  136. Add color region (given the delimiters) and its colors.
  137. .. _class_TextEdit_add_keyword_color:
  138. - void **add_keyword_color** **(** :ref:`String<class_string>` keyword, :ref:`Color<class_color>` color **)**
  139. Add a keyword and its color.
  140. .. _class_TextEdit_clear_colors:
  141. - void **clear_colors** **(** **)**
  142. Clear all the syntax coloring information.
  143. .. _class_TextEdit_clear_undo_history:
  144. - void **clear_undo_history** **(** **)**
  145. Clear the undo history.
  146. .. _class_TextEdit_copy:
  147. - void **copy** **(** **)**
  148. Copy the current selection.
  149. .. _class_TextEdit_cursor_get_blink_enabled:
  150. - :ref:`bool<class_bool>` **cursor_get_blink_enabled** **(** **)** const
  151. Gets whether the text editor caret is blinking.
  152. .. _class_TextEdit_cursor_get_blink_speed:
  153. - :ref:`float<class_float>` **cursor_get_blink_speed** **(** **)** const
  154. Gets the text editor caret blink speed.
  155. .. _class_TextEdit_cursor_get_column:
  156. - :ref:`int<class_int>` **cursor_get_column** **(** **)** const
  157. Return the column the editing cursor is at.
  158. .. _class_TextEdit_cursor_get_line:
  159. - :ref:`int<class_int>` **cursor_get_line** **(** **)** const
  160. Return the line the editing cursor is at.
  161. .. _class_TextEdit_cursor_is_block_mode:
  162. - :ref:`bool<class_bool>` **cursor_is_block_mode** **(** **)** const
  163. Gets whether the text editor caret is in block mode.
  164. .. _class_TextEdit_cursor_set_blink_enabled:
  165. - void **cursor_set_blink_enabled** **(** :ref:`bool<class_bool>` enable **)**
  166. Set the text editor caret to blink.
  167. .. _class_TextEdit_cursor_set_blink_speed:
  168. - void **cursor_set_blink_speed** **(** :ref:`float<class_float>` blink_speed **)**
  169. Set the text editor caret blink speed. Cannot be less then or equal to 0.
  170. .. _class_TextEdit_cursor_set_block_mode:
  171. - void **cursor_set_block_mode** **(** :ref:`bool<class_bool>` enable **)**
  172. Set the text editor caret to block mode.
  173. .. _class_TextEdit_cursor_set_column:
  174. - void **cursor_set_column** **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` adjust_viewport=false **)**
  175. .. _class_TextEdit_cursor_set_line:
  176. - void **cursor_set_line** **(** :ref:`int<class_int>` line, :ref:`bool<class_bool>` adjust_viewport=false **)**
  177. .. _class_TextEdit_cut:
  178. - void **cut** **(** **)**
  179. Cut the current selection.
  180. .. _class_TextEdit_get_line:
  181. - :ref:`String<class_string>` **get_line** **(** :ref:`int<class_int>` line **)** const
  182. Return the text of a specific line.
  183. .. _class_TextEdit_get_line_count:
  184. - :ref:`int<class_int>` **get_line_count** **(** **)** const
  185. Return the amount of total lines in the text.
  186. .. _class_TextEdit_get_menu:
  187. - :ref:`PopupMenu<class_popupmenu>` **get_menu** **(** **)** const
  188. .. _class_TextEdit_get_selection_from_column:
  189. - :ref:`int<class_int>` **get_selection_from_column** **(** **)** const
  190. Return the selection begin column.
  191. .. _class_TextEdit_get_selection_from_line:
  192. - :ref:`int<class_int>` **get_selection_from_line** **(** **)** const
  193. Return the selection begin line.
  194. .. _class_TextEdit_get_selection_text:
  195. - :ref:`String<class_string>` **get_selection_text** **(** **)** const
  196. Return the text inside the selection.
  197. .. _class_TextEdit_get_selection_to_column:
  198. - :ref:`int<class_int>` **get_selection_to_column** **(** **)** const
  199. Return the selection end column.
  200. .. _class_TextEdit_get_selection_to_line:
  201. - :ref:`int<class_int>` **get_selection_to_line** **(** **)** const
  202. Return the selection end line.
  203. .. _class_TextEdit_get_text:
  204. - :ref:`String<class_string>` **get_text** **(** **)**
  205. Return the whole text.
  206. .. _class_TextEdit_get_word_under_cursor:
  207. - :ref:`String<class_string>` **get_word_under_cursor** **(** **)** const
  208. .. _class_TextEdit_insert_text_at_cursor:
  209. - void **insert_text_at_cursor** **(** :ref:`String<class_string>` text **)**
  210. Insert a given text at the cursor position.
  211. .. _class_TextEdit_is_highlight_all_occurrences_enabled:
  212. - :ref:`bool<class_bool>` **is_highlight_all_occurrences_enabled** **(** **)** const
  213. Returns true if highlight all occurrences is enabled.
  214. .. _class_TextEdit_is_selection_active:
  215. - :ref:`bool<class_bool>` **is_selection_active** **(** **)** const
  216. Return true if the selection is active.
  217. .. _class_TextEdit_is_show_line_numbers_enabled:
  218. - :ref:`bool<class_bool>` **is_show_line_numbers_enabled** **(** **)** const
  219. Returns true if line numbers are enabled.
  220. .. _class_TextEdit_is_syntax_coloring_enabled:
  221. - :ref:`bool<class_bool>` **is_syntax_coloring_enabled** **(** **)** const
  222. Return true if the syntax coloring is enabled.
  223. .. _class_TextEdit_menu_option:
  224. - void **menu_option** **(** :ref:`int<class_int>` arg0 **)**
  225. .. _class_TextEdit_paste:
  226. - void **paste** **(** **)**
  227. Paste the current selection.
  228. .. _class_TextEdit_redo:
  229. - void **redo** **(** **)**
  230. Perform redo operation.
  231. .. _class_TextEdit_search:
  232. - :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
  233. Perform a search inside the text. Search flags can be specified in the SEARCH\_\* enum.
  234. .. _class_TextEdit_select:
  235. - 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 **)**
  236. Perform selection, from line/column to line/column.
  237. .. _class_TextEdit_select_all:
  238. - void **select_all** **(** **)**
  239. Select all the text.
  240. .. _class_TextEdit_set_custom_bg_color:
  241. - void **set_custom_bg_color** **(** :ref:`Color<class_color>` color **)**
  242. Set a custom background color. A background color with alpha==0 disables this.
  243. .. _class_TextEdit_set_highlight_all_occurrences:
  244. - void **set_highlight_all_occurrences** **(** :ref:`bool<class_bool>` enable **)**
  245. Set to enable highlighting all occurrences of the current selection.
  246. .. _class_TextEdit_set_max_chars:
  247. - void **set_max_chars** **(** :ref:`int<class_int>` amount **)**
  248. Set the maximum amount of characters editable.
  249. .. _class_TextEdit_set_readonly:
  250. - void **set_readonly** **(** :ref:`bool<class_bool>` enable **)**
  251. Set the text editor as read-only. Text can be displayed but not edited.
  252. .. _class_TextEdit_set_show_line_numbers:
  253. - void **set_show_line_numbers** **(** :ref:`bool<class_bool>` enable **)**
  254. Set to enable showing line numbers.
  255. .. _class_TextEdit_set_symbol_color:
  256. - void **set_symbol_color** **(** :ref:`Color<class_color>` color **)**
  257. Set the color for symbols.
  258. .. _class_TextEdit_set_syntax_coloring:
  259. - void **set_syntax_coloring** **(** :ref:`bool<class_bool>` enable **)**
  260. Set to enable the syntax coloring.
  261. .. _class_TextEdit_set_text:
  262. - void **set_text** **(** :ref:`String<class_string>` text **)**
  263. Set the entire text.
  264. .. _class_TextEdit_set_wrap:
  265. - void **set_wrap** **(** :ref:`bool<class_bool>` enable **)**
  266. Enable text wrapping when it goes beyond he edge of what is visible.
  267. .. _class_TextEdit_undo:
  268. - void **undo** **(** **)**
  269. Perform undo operation.