class_textedit.rst 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the TextEdit.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_TextEdit:
  5. TextEdit
  6. ========
  7. **Inherits:** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Multiline text editing control.
  12. Member Functions
  13. ----------------
  14. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | 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 **)** |
  16. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`add_keyword_color<class_TextEdit_add_keyword_color>` **(** :ref:`String<class_string>` keyword, :ref:`Color<class_color>` color **)** |
  18. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`can_fold<class_TextEdit_can_fold>` **(** :ref:`int<class_int>` line **)** const |
  20. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`clear_colors<class_TextEdit_clear_colors>` **(** **)** |
  22. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`clear_undo_history<class_TextEdit_clear_undo_history>` **(** **)** |
  24. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`copy<class_TextEdit_copy>` **(** **)** |
  26. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`cursor_get_column<class_TextEdit_cursor_get_column>` **(** **)** const |
  28. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`cursor_get_line<class_TextEdit_cursor_get_line>` **(** **)** const |
  30. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`cursor_set_column<class_TextEdit_cursor_set_column>` **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` adjust_viewport=true **)** |
  32. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`cursor_set_line<class_TextEdit_cursor_set_line>` **(** :ref:`int<class_int>` line, :ref:`bool<class_bool>` adjust_viewport=true, :ref:`bool<class_bool>` can_be_hidden=true **)** |
  34. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`cut<class_TextEdit_cut>` **(** **)** |
  36. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`deselect<class_TextEdit_deselect>` **(** **)** |
  38. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`fold_all_lines<class_TextEdit_fold_all_lines>` **(** **)** |
  40. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`fold_line<class_TextEdit_fold_line>` **(** :ref:`int<class_int>` line **)** |
  42. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`String<class_string>` | :ref:`get_line<class_TextEdit_get_line>` **(** :ref:`int<class_int>` line **)** const |
  44. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`int<class_int>` | :ref:`get_line_count<class_TextEdit_get_line_count>` **(** **)** const |
  46. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`PopupMenu<class_popupmenu>` | :ref:`get_menu<class_TextEdit_get_menu>` **(** **)** const |
  48. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`int<class_int>` | :ref:`get_selection_from_column<class_TextEdit_get_selection_from_column>` **(** **)** const |
  50. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`get_selection_from_line<class_TextEdit_get_selection_from_line>` **(** **)** const |
  52. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`String<class_string>` | :ref:`get_selection_text<class_TextEdit_get_selection_text>` **(** **)** const |
  54. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`get_selection_to_column<class_TextEdit_get_selection_to_column>` **(** **)** const |
  56. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`get_selection_to_line<class_TextEdit_get_selection_to_line>` **(** **)** const |
  58. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`String<class_string>` | :ref:`get_word_under_cursor<class_TextEdit_get_word_under_cursor>` **(** **)** const |
  60. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`insert_text_at_cursor<class_TextEdit_insert_text_at_cursor>` **(** :ref:`String<class_string>` text **)** |
  62. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`bool<class_bool>` | :ref:`is_folded<class_TextEdit_is_folded>` **(** :ref:`int<class_int>` line **)** const |
  64. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`bool<class_bool>` | :ref:`is_line_hidden<class_TextEdit_is_line_hidden>` **(** :ref:`int<class_int>` line **)** const |
  66. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`bool<class_bool>` | :ref:`is_selection_active<class_TextEdit_is_selection_active>` **(** **)** const |
  68. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`menu_option<class_TextEdit_menu_option>` **(** :ref:`int<class_int>` option **)** |
  70. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`paste<class_TextEdit_paste>` **(** **)** |
  72. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`redo<class_TextEdit_redo>` **(** **)** |
  74. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`PoolIntArray<class_poolintarray>` | :ref:`search<class_TextEdit_search>` **(** :ref:`String<class_string>` key, :ref:`int<class_int>` flags, :ref:`int<class_int>` from_line, :ref:`int<class_int>` from_column **)** const |
  76. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | 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 **)** |
  78. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`select_all<class_TextEdit_select_all>` **(** **)** |
  80. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`set_line_as_hidden<class_TextEdit_set_line_as_hidden>` **(** :ref:`int<class_int>` line, :ref:`bool<class_bool>` enable **)** |
  82. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`toggle_fold_line<class_TextEdit_toggle_fold_line>` **(** :ref:`int<class_int>` line **)** |
  84. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`undo<class_TextEdit_undo>` **(** **)** |
  86. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`unfold_line<class_TextEdit_unfold_line>` **(** :ref:`int<class_int>` line **)** |
  88. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`unhide_all_lines<class_TextEdit_unhide_all_lines>` **(** **)** |
  90. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. Signals
  92. -------
  93. .. _class_TextEdit_breakpoint_toggled:
  94. - **breakpoint_toggled** **(** :ref:`int<class_int>` row **)**
  95. Emitted when a breakpoint is placed via the breakpoint gutter.
  96. .. _class_TextEdit_cursor_changed:
  97. - **cursor_changed** **(** **)**
  98. Emitted when the cursor changes.
  99. .. _class_TextEdit_request_completion:
  100. - **request_completion** **(** **)**
  101. .. _class_TextEdit_symbol_lookup:
  102. - **symbol_lookup** **(** :ref:`String<class_string>` symbol, :ref:`int<class_int>` row, :ref:`int<class_int>` column **)**
  103. .. _class_TextEdit_text_changed:
  104. - **text_changed** **(** **)**
  105. Emitted when the text changes.
  106. Member Variables
  107. ----------------
  108. .. _class_TextEdit_caret_blink:
  109. - :ref:`bool<class_bool>` **caret_blink** - If ``true`` the caret (visual cursor) blinks.
  110. .. _class_TextEdit_caret_blink_speed:
  111. - :ref:`float<class_float>` **caret_blink_speed** - Duration (in seconds) of a caret's blinking cycle.
  112. .. _class_TextEdit_caret_block_mode:
  113. - :ref:`bool<class_bool>` **caret_block_mode** - If ``true`` the caret displays as a rectangle.
  114. If ``false`` the caret displays as a bar.
  115. .. _class_TextEdit_caret_moving_by_right_click:
  116. - :ref:`bool<class_bool>` **caret_moving_by_right_click** - If ``true`` a right click moves the cursor at the mouse position before displaying the context menu.
  117. If ``false`` the context menu disregards mouse location.
  118. .. _class_TextEdit_context_menu_enabled:
  119. - :ref:`bool<class_bool>` **context_menu_enabled** - If ``true`` a right click displays the context menu.
  120. .. _class_TextEdit_hiding_enabled:
  121. - :ref:`int<class_int>` **hiding_enabled**
  122. .. _class_TextEdit_highlight_all_occurrences:
  123. - :ref:`bool<class_bool>` **highlight_all_occurrences**
  124. .. _class_TextEdit_highlight_current_line:
  125. - :ref:`bool<class_bool>` **highlight_current_line** - If ``true`` the line containing the cursor is highlighted.
  126. .. _class_TextEdit_override_selected_font_color:
  127. - :ref:`bool<class_bool>` **override_selected_font_color**
  128. .. _class_TextEdit_readonly:
  129. - :ref:`bool<class_bool>` **readonly** - If ``true`` read-only mode is enabled. Existing text cannot be modified and new text cannot be added.
  130. .. _class_TextEdit_show_line_numbers:
  131. - :ref:`bool<class_bool>` **show_line_numbers** - If ``true`` line numbers are displayed to the left of the text.
  132. .. _class_TextEdit_smooth_scrolling:
  133. - :ref:`bool<class_bool>` **smooth_scrolling**
  134. .. _class_TextEdit_syntax_highlighting:
  135. - :ref:`bool<class_bool>` **syntax_highlighting**
  136. .. _class_TextEdit_text:
  137. - :ref:`String<class_string>` **text** - String value of the :ref:`TextEdit<class_textedit>`.
  138. .. _class_TextEdit_v_scroll_speed:
  139. - :ref:`float<class_float>` **v_scroll_speed** - If ``true``, enables text wrapping when it goes beyond he edge of what is visible.
  140. .. _class_TextEdit_wrap_lines:
  141. - :ref:`bool<class_bool>` **wrap_lines**
  142. Enums
  143. -----
  144. .. _enum_TextEdit_MenuItems:
  145. enum **MenuItems**
  146. - **MENU_CUT** = **0** --- Cuts (Copies and clears) the selected text.
  147. - **MENU_COPY** = **1** --- Copies the selected text.
  148. - **MENU_PASTE** = **2** --- Pastes the clipboard text over the selected text (or at the cursor's position).
  149. - **MENU_CLEAR** = **3** --- Erases the whole :ref:`TextEdit<class_textedit>` text.
  150. - **MENU_SELECT_ALL** = **4** --- Selects the whole :ref:`TextEdit<class_textedit>` text.
  151. - **MENU_UNDO** = **5** --- Undoes the previous action.
  152. - **MENU_MAX** = **6**
  153. .. _enum_TextEdit_SearchFlags:
  154. enum **SearchFlags**
  155. - **SEARCH_MATCH_CASE** = **1** --- Match case when searching.
  156. - **SEARCH_WHOLE_WORDS** = **2** --- Match whole words when searching.
  157. - **SEARCH_BACKWARDS** = **4** --- Search from end to beginning.
  158. Description
  159. -----------
  160. 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.
  161. Member Function Description
  162. ---------------------------
  163. .. _class_TextEdit_add_color_region:
  164. - 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 **)**
  165. Add color region (given the delimiters) and its colors.
  166. .. _class_TextEdit_add_keyword_color:
  167. - void **add_keyword_color** **(** :ref:`String<class_string>` keyword, :ref:`Color<class_color>` color **)**
  168. Add a keyword and its color.
  169. .. _class_TextEdit_can_fold:
  170. - :ref:`bool<class_bool>` **can_fold** **(** :ref:`int<class_int>` line **)** const
  171. .. _class_TextEdit_clear_colors:
  172. - void **clear_colors** **(** **)**
  173. Clear all the syntax coloring information.
  174. .. _class_TextEdit_clear_undo_history:
  175. - void **clear_undo_history** **(** **)**
  176. Clear the undo history.
  177. .. _class_TextEdit_copy:
  178. - void **copy** **(** **)**
  179. Copy the current selection.
  180. .. _class_TextEdit_cursor_get_column:
  181. - :ref:`int<class_int>` **cursor_get_column** **(** **)** const
  182. Return the column the editing cursor is at.
  183. .. _class_TextEdit_cursor_get_line:
  184. - :ref:`int<class_int>` **cursor_get_line** **(** **)** const
  185. Return the line the editing cursor is at.
  186. .. _class_TextEdit_cursor_set_column:
  187. - void **cursor_set_column** **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` adjust_viewport=true **)**
  188. .. _class_TextEdit_cursor_set_line:
  189. - void **cursor_set_line** **(** :ref:`int<class_int>` line, :ref:`bool<class_bool>` adjust_viewport=true, :ref:`bool<class_bool>` can_be_hidden=true **)**
  190. .. _class_TextEdit_cut:
  191. - void **cut** **(** **)**
  192. Cut the current selection.
  193. .. _class_TextEdit_deselect:
  194. - void **deselect** **(** **)**
  195. Clears the current selection.
  196. .. _class_TextEdit_fold_all_lines:
  197. - void **fold_all_lines** **(** **)**
  198. .. _class_TextEdit_fold_line:
  199. - void **fold_line** **(** :ref:`int<class_int>` line **)**
  200. .. _class_TextEdit_get_line:
  201. - :ref:`String<class_string>` **get_line** **(** :ref:`int<class_int>` line **)** const
  202. Return the text of a specific line.
  203. .. _class_TextEdit_get_line_count:
  204. - :ref:`int<class_int>` **get_line_count** **(** **)** const
  205. Return the amount of total lines in the text.
  206. .. _class_TextEdit_get_menu:
  207. - :ref:`PopupMenu<class_popupmenu>` **get_menu** **(** **)** const
  208. .. _class_TextEdit_get_selection_from_column:
  209. - :ref:`int<class_int>` **get_selection_from_column** **(** **)** const
  210. Return the selection begin column.
  211. .. _class_TextEdit_get_selection_from_line:
  212. - :ref:`int<class_int>` **get_selection_from_line** **(** **)** const
  213. Return the selection begin line.
  214. .. _class_TextEdit_get_selection_text:
  215. - :ref:`String<class_string>` **get_selection_text** **(** **)** const
  216. Return the text inside the selection.
  217. .. _class_TextEdit_get_selection_to_column:
  218. - :ref:`int<class_int>` **get_selection_to_column** **(** **)** const
  219. Return the selection end column.
  220. .. _class_TextEdit_get_selection_to_line:
  221. - :ref:`int<class_int>` **get_selection_to_line** **(** **)** const
  222. Return the selection end line.
  223. .. _class_TextEdit_get_word_under_cursor:
  224. - :ref:`String<class_string>` **get_word_under_cursor** **(** **)** const
  225. .. _class_TextEdit_insert_text_at_cursor:
  226. - void **insert_text_at_cursor** **(** :ref:`String<class_string>` text **)**
  227. Insert a given text at the cursor position.
  228. .. _class_TextEdit_is_folded:
  229. - :ref:`bool<class_bool>` **is_folded** **(** :ref:`int<class_int>` line **)** const
  230. .. _class_TextEdit_is_line_hidden:
  231. - :ref:`bool<class_bool>` **is_line_hidden** **(** :ref:`int<class_int>` line **)** const
  232. .. _class_TextEdit_is_selection_active:
  233. - :ref:`bool<class_bool>` **is_selection_active** **(** **)** const
  234. Return true if the selection is active.
  235. .. _class_TextEdit_menu_option:
  236. - void **menu_option** **(** :ref:`int<class_int>` option **)**
  237. .. _class_TextEdit_paste:
  238. - void **paste** **(** **)**
  239. Paste the current selection.
  240. .. _class_TextEdit_redo:
  241. - void **redo** **(** **)**
  242. Perform redo operation.
  243. .. _class_TextEdit_search:
  244. - :ref:`PoolIntArray<class_poolintarray>` **search** **(** :ref:`String<class_string>` key, :ref:`int<class_int>` flags, :ref:`int<class_int>` from_line, :ref:`int<class_int>` from_column **)** const
  245. Perform a search inside the text. Search flags can be specified in the SEARCH\_\* enum.
  246. .. _class_TextEdit_select:
  247. - 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 **)**
  248. Perform selection, from line/column to line/column.
  249. .. _class_TextEdit_select_all:
  250. - void **select_all** **(** **)**
  251. Select all the text.
  252. .. _class_TextEdit_set_line_as_hidden:
  253. - void **set_line_as_hidden** **(** :ref:`int<class_int>` line, :ref:`bool<class_bool>` enable **)**
  254. .. _class_TextEdit_toggle_fold_line:
  255. - void **toggle_fold_line** **(** :ref:`int<class_int>` line **)**
  256. Toggle the folding of the code block at the given line.
  257. .. _class_TextEdit_undo:
  258. - void **undo** **(** **)**
  259. Perform undo operation.
  260. .. _class_TextEdit_unfold_line:
  261. - void **unfold_line** **(** :ref:`int<class_int>` line **)**
  262. .. _class_TextEdit_unhide_all_lines:
  263. - void **unhide_all_lines** **(** **)**