text_edit.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*************************************************************************/
  2. /* text_edit.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef TEXT_EDIT_H
  31. #define TEXT_EDIT_H
  32. #include "scene/gui/control.h"
  33. #include "scene/gui/popup_menu.h"
  34. #include "scene/gui/scroll_bar.h"
  35. #include "scene/main/timer.h"
  36. class SyntaxHighlighter;
  37. class TextEdit : public Control {
  38. GDCLASS(TextEdit, Control)
  39. public:
  40. struct HighlighterInfo {
  41. Color color;
  42. };
  43. struct ColorRegion {
  44. Color color;
  45. String begin_key;
  46. String end_key;
  47. bool line_only;
  48. bool eq;
  49. ColorRegion(const String &p_begin_key = "", const String &p_end_key = "", const Color &p_color = Color(), bool p_line_only = false) {
  50. begin_key = p_begin_key;
  51. end_key = p_end_key;
  52. color = p_color;
  53. line_only = p_line_only || p_end_key == "";
  54. eq = begin_key == end_key;
  55. }
  56. };
  57. class Text {
  58. public:
  59. struct ColorRegionInfo {
  60. int region;
  61. bool end;
  62. };
  63. struct Line {
  64. int width_cache : 24;
  65. bool marked : 1;
  66. bool breakpoint : 1;
  67. bool hidden : 1;
  68. bool safe : 1;
  69. int wrap_amount_cache : 24;
  70. Map<int, ColorRegionInfo> region_info;
  71. String data;
  72. };
  73. private:
  74. const Vector<ColorRegion> *color_regions;
  75. mutable Vector<Line> text;
  76. Ref<Font> font;
  77. int indent_size;
  78. void _update_line_cache(int p_line) const;
  79. public:
  80. void set_indent_size(int p_indent_size);
  81. void set_font(const Ref<Font> &p_font);
  82. void set_color_regions(const Vector<ColorRegion> *p_regions) { color_regions = p_regions; }
  83. int get_line_width(int p_line) const;
  84. int get_max_width(bool p_exclude_hidden = false) const;
  85. int get_char_width(CharType c, CharType next_c, int px) const;
  86. void set_line_wrap_amount(int p_line, int p_wrap_amount) const;
  87. int get_line_wrap_amount(int p_line) const;
  88. const Map<int, ColorRegionInfo> &get_color_region_info(int p_line) const;
  89. void set(int p_line, const String &p_text);
  90. void set_marked(int p_line, bool p_marked) { text.write[p_line].marked = p_marked; }
  91. bool is_marked(int p_line) const { return text[p_line].marked; }
  92. void set_breakpoint(int p_line, bool p_breakpoint) { text.write[p_line].breakpoint = p_breakpoint; }
  93. bool is_breakpoint(int p_line) const { return text[p_line].breakpoint; }
  94. void set_hidden(int p_line, bool p_hidden) { text.write[p_line].hidden = p_hidden; }
  95. bool is_hidden(int p_line) const { return text[p_line].hidden; }
  96. void set_safe(int p_line, bool p_safe) { text.write[p_line].safe = p_safe; }
  97. bool is_safe(int p_line) const { return text[p_line].safe; }
  98. void insert(int p_at, const String &p_text);
  99. void remove(int p_at);
  100. int size() const { return text.size(); }
  101. void clear();
  102. void clear_width_cache();
  103. void clear_wrap_cache();
  104. _FORCE_INLINE_ const String &operator[](int p_line) const { return text[p_line].data; }
  105. Text() { indent_size = 4; }
  106. };
  107. private:
  108. struct Cursor {
  109. int last_fit_x;
  110. int line, column; ///< cursor
  111. int x_ofs, line_ofs, wrap_ofs;
  112. } cursor;
  113. struct Selection {
  114. enum Mode {
  115. MODE_NONE,
  116. MODE_SHIFT,
  117. MODE_POINTER,
  118. MODE_WORD,
  119. MODE_LINE
  120. };
  121. Mode selecting_mode;
  122. int selecting_line, selecting_column;
  123. int selected_word_beg, selected_word_end, selected_word_origin;
  124. bool selecting_text;
  125. bool active;
  126. int from_line, from_column;
  127. int to_line, to_column;
  128. bool shiftclick_left;
  129. } selection;
  130. struct Cache {
  131. Ref<Texture> tab_icon;
  132. Ref<Texture> can_fold_icon;
  133. Ref<Texture> folded_icon;
  134. Ref<Texture> folded_eol_icon;
  135. Ref<StyleBox> style_normal;
  136. Ref<StyleBox> style_focus;
  137. Ref<StyleBox> style_readonly;
  138. Ref<Font> font;
  139. Color completion_background_color;
  140. Color completion_selected_color;
  141. Color completion_existing_color;
  142. Color completion_font_color;
  143. Color caret_color;
  144. Color caret_background_color;
  145. Color line_number_color;
  146. Color safe_line_number_color;
  147. Color font_color;
  148. Color font_selected_color;
  149. Color keyword_color;
  150. Color number_color;
  151. Color function_color;
  152. Color member_variable_color;
  153. Color selection_color;
  154. Color mark_color;
  155. Color breakpoint_color;
  156. Color code_folding_color;
  157. Color current_line_color;
  158. Color line_length_guideline_color;
  159. Color brace_mismatch_color;
  160. Color word_highlighted_color;
  161. Color search_result_color;
  162. Color search_result_border_color;
  163. Color symbol_color;
  164. Color background_color;
  165. int row_height;
  166. int line_spacing;
  167. int line_number_w;
  168. int breakpoint_gutter_width;
  169. int fold_gutter_width;
  170. } cache;
  171. Map<int, int> color_region_cache;
  172. struct TextOperation {
  173. enum Type {
  174. TYPE_NONE,
  175. TYPE_INSERT,
  176. TYPE_REMOVE
  177. };
  178. Type type;
  179. int from_line, from_column;
  180. int to_line, to_column;
  181. String text;
  182. uint32_t prev_version;
  183. uint32_t version;
  184. bool chain_forward;
  185. bool chain_backward;
  186. };
  187. String ime_text;
  188. Point2 ime_selection;
  189. TextOperation current_op;
  190. List<TextOperation> undo_stack;
  191. List<TextOperation>::Element *undo_stack_pos;
  192. void _clear_redo();
  193. void _do_text_op(const TextOperation &p_op, bool p_reverse);
  194. //syntax coloring
  195. SyntaxHighlighter *syntax_highlighter;
  196. HashMap<String, Color> keywords;
  197. HashMap<String, Color> member_keywords;
  198. Map<int, HighlighterInfo> _get_line_syntax_highlighting(int p_line);
  199. Vector<ColorRegion> color_regions;
  200. Set<String> completion_prefixes;
  201. bool completion_enabled;
  202. Vector<String> completion_strings;
  203. Vector<String> completion_options;
  204. bool completion_active;
  205. bool completion_forced;
  206. String completion_current;
  207. String completion_base;
  208. int completion_index;
  209. Rect2i completion_rect;
  210. int completion_line_ofs;
  211. String completion_hint;
  212. int completion_hint_offset;
  213. bool setting_text;
  214. // data
  215. Text text;
  216. uint32_t version;
  217. uint32_t saved_version;
  218. int max_chars;
  219. bool readonly;
  220. bool syntax_coloring;
  221. bool indent_using_spaces;
  222. int indent_size;
  223. String space_indent;
  224. Timer *caret_blink_timer;
  225. bool caret_blink_enabled;
  226. bool draw_caret;
  227. bool window_has_focus;
  228. bool block_caret;
  229. bool right_click_moves_caret;
  230. bool wrap_enabled;
  231. int wrap_at;
  232. int wrap_right_offset;
  233. bool setting_row;
  234. bool draw_tabs;
  235. bool override_selected_font_color;
  236. bool cursor_changed_dirty;
  237. bool text_changed_dirty;
  238. bool undo_enabled;
  239. bool line_numbers;
  240. bool line_numbers_zero_padded;
  241. bool line_length_guideline;
  242. int line_length_guideline_col;
  243. bool draw_breakpoint_gutter;
  244. int breakpoint_gutter_width;
  245. bool draw_fold_gutter;
  246. int fold_gutter_width;
  247. bool hiding_enabled;
  248. bool highlight_all_occurrences;
  249. bool scroll_past_end_of_file_enabled;
  250. bool auto_brace_completion_enabled;
  251. bool brace_matching_enabled;
  252. bool highlight_current_line;
  253. bool auto_indent;
  254. String cut_copy_line;
  255. bool insert_mode;
  256. bool select_identifiers_enabled;
  257. bool smooth_scroll_enabled;
  258. bool scrolling;
  259. float target_v_scroll;
  260. float v_scroll_speed;
  261. String highlighted_word;
  262. uint64_t last_dblclk;
  263. Timer *idle_detect;
  264. Timer *click_select_held;
  265. HScrollBar *h_scroll;
  266. VScrollBar *v_scroll;
  267. bool updating_scrolls;
  268. Object *tooltip_obj;
  269. StringName tooltip_func;
  270. Variant tooltip_ud;
  271. bool next_operation_is_complex;
  272. bool callhint_below;
  273. Vector2 callhint_offset;
  274. String search_text;
  275. uint32_t search_flags;
  276. int search_result_line;
  277. int search_result_col;
  278. bool context_menu_enabled;
  279. int get_visible_rows() const;
  280. int get_total_visible_rows() const;
  281. void update_cursor_wrap_offset();
  282. void update_wrap_at();
  283. bool line_wraps(int line) const;
  284. int times_line_wraps(int line) const;
  285. Vector<String> get_wrap_rows_text(int p_line) const;
  286. int get_cursor_wrap_index() const;
  287. int get_line_wrap_index_at_col(int p_line, int p_column) const;
  288. int get_char_count();
  289. double get_scroll_pos_for_line(int p_line, int p_wrap_index = 0) const;
  290. void set_line_as_first_visible(int p_line, int p_wrap_index = 0);
  291. void set_line_as_center_visible(int p_line, int p_wrap_index = 0);
  292. void set_line_as_last_visible(int p_line, int p_wrap_index = 0);
  293. int get_first_visible_line() const;
  294. int get_last_visible_line() const;
  295. int get_last_visible_line_wrap_index() const;
  296. double get_visible_rows_offset() const;
  297. double get_v_scroll_offset() const;
  298. int get_char_pos_for_line(int p_px, int p_line, int p_wrap_index = 0) const;
  299. int get_column_x_offset_for_line(int p_char, int p_line) const;
  300. int get_char_pos_for(int p_px, String p_str) const;
  301. int get_column_x_offset(int p_char, String p_str) const;
  302. void adjust_viewport_to_cursor();
  303. double get_scroll_line_diff() const;
  304. void _scroll_moved(double);
  305. void _update_scrollbars();
  306. void _v_scroll_input();
  307. void _click_selection_held();
  308. void _update_selection_mode_pointer();
  309. void _update_selection_mode_word();
  310. void _update_selection_mode_line();
  311. void _uncomment_line(int p_line);
  312. void _scroll_up(real_t p_delta);
  313. void _scroll_down(real_t p_delta);
  314. void _pre_shift_selection();
  315. void _post_shift_selection();
  316. void _scroll_lines_up();
  317. void _scroll_lines_down();
  318. //void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
  319. Size2 get_minimum_size() const;
  320. int get_row_height() const;
  321. void _reset_caret_blink_timer();
  322. void _toggle_draw_caret();
  323. void _update_caches();
  324. void _cursor_changed_emit();
  325. void _text_changed_emit();
  326. void _line_edited_from(int p_line);
  327. void _push_current_op();
  328. /* super internal api, undo/redo builds on it */
  329. void _base_insert_text(int p_line, int p_char, const String &p_text, int &r_end_line, int &r_end_column);
  330. String _base_get_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) const;
  331. void _base_remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
  332. int _get_column_pos_of_word(const String &p_key, const String &p_search, uint32_t p_search_flags, int p_from_column);
  333. PoolVector<int> _search_bind(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column) const;
  334. PopupMenu *menu;
  335. void _clear();
  336. void _cancel_completion();
  337. void _cancel_code_hint();
  338. void _confirm_completion();
  339. void _update_completion_candidates();
  340. protected:
  341. virtual String get_tooltip(const Point2 &p_pos) const;
  342. void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = NULL, int *r_end_char = NULL);
  343. void _remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
  344. void _insert_text_at_cursor(const String &p_text);
  345. void _gui_input(const Ref<InputEvent> &p_gui_input);
  346. void _notification(int p_what);
  347. void _consume_pair_symbol(CharType ch);
  348. void _consume_backspace_for_pair_symbol(int prev_line, int prev_column);
  349. static void _bind_methods();
  350. public:
  351. SyntaxHighlighter *_get_syntax_highlighting();
  352. void _set_syntax_highlighting(SyntaxHighlighter *p_syntax_highlighter);
  353. int _is_line_in_region(int p_line);
  354. ColorRegion _get_color_region(int p_region) const;
  355. Map<int, Text::ColorRegionInfo> _get_line_color_region_info(int p_line) const;
  356. enum MenuItems {
  357. MENU_CUT,
  358. MENU_COPY,
  359. MENU_PASTE,
  360. MENU_CLEAR,
  361. MENU_SELECT_ALL,
  362. MENU_UNDO,
  363. MENU_REDO,
  364. MENU_MAX
  365. };
  366. enum SearchFlags {
  367. SEARCH_MATCH_CASE = 1,
  368. SEARCH_WHOLE_WORDS = 2,
  369. SEARCH_BACKWARDS = 4
  370. };
  371. virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
  372. void _get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) const;
  373. //void delete_char();
  374. //void delete_line();
  375. void begin_complex_operation();
  376. void end_complex_operation();
  377. bool is_insert_text_operation();
  378. void set_text(String p_text);
  379. void insert_text_at_cursor(const String &p_text);
  380. void insert_at(const String &p_text, int at);
  381. int get_line_count() const;
  382. void set_line_as_marked(int p_line, bool p_marked);
  383. void set_line_as_breakpoint(int p_line, bool p_breakpoint);
  384. bool is_line_set_as_breakpoint(int p_line) const;
  385. void set_line_as_safe(int p_line, bool p_safe);
  386. bool is_line_set_as_safe(int p_line) const;
  387. void get_breakpoints(List<int> *p_breakpoints) const;
  388. Array get_breakpoints_array() const;
  389. void remove_breakpoints();
  390. void set_line_as_hidden(int p_line, bool p_hidden);
  391. bool is_line_hidden(int p_line) const;
  392. void fold_all_lines();
  393. void unhide_all_lines();
  394. int num_lines_from(int p_line_from, int visible_amount) const;
  395. int num_lines_from_rows(int p_line_from, int p_wrap_index_from, int visible_amount, int &wrap_index) const;
  396. int get_last_unhidden_line() const;
  397. bool can_fold(int p_line) const;
  398. bool is_folded(int p_line) const;
  399. void fold_line(int p_line);
  400. void unfold_line(int p_line);
  401. void toggle_fold_line(int p_line);
  402. String get_text();
  403. String get_line(int line) const;
  404. void set_line(int line, String new_text);
  405. void backspace_at_cursor();
  406. void indent_left();
  407. void indent_right();
  408. int get_indent_level(int p_line) const;
  409. bool is_line_comment(int p_line) const;
  410. inline void set_scroll_pass_end_of_file(bool p_enabled) {
  411. scroll_past_end_of_file_enabled = p_enabled;
  412. update();
  413. }
  414. inline void set_auto_brace_completion(bool p_enabled) {
  415. auto_brace_completion_enabled = p_enabled;
  416. }
  417. inline void set_brace_matching(bool p_enabled) {
  418. brace_matching_enabled = p_enabled;
  419. update();
  420. }
  421. inline void set_callhint_settings(bool below, Vector2 offset) {
  422. callhint_below = below;
  423. callhint_offset = offset;
  424. }
  425. void set_auto_indent(bool p_auto_indent);
  426. void center_viewport_to_cursor();
  427. void cursor_set_column(int p_col, bool p_adjust_viewport = true);
  428. void cursor_set_line(int p_row, bool p_adjust_viewport = true, bool p_can_be_hidden = true, int p_wrap_index = 0);
  429. int cursor_get_column() const;
  430. int cursor_get_line() const;
  431. bool cursor_get_blink_enabled() const;
  432. void cursor_set_blink_enabled(const bool p_enabled);
  433. float cursor_get_blink_speed() const;
  434. void cursor_set_blink_speed(const float p_speed);
  435. void cursor_set_block_mode(const bool p_enable);
  436. bool cursor_is_block_mode() const;
  437. void set_right_click_moves_caret(bool p_enable);
  438. bool is_right_click_moving_caret() const;
  439. void set_readonly(bool p_readonly);
  440. bool is_readonly() const;
  441. void set_max_chars(int p_max_chars);
  442. int get_max_chars() const;
  443. void set_wrap_enabled(bool p_wrap_enabled);
  444. bool is_wrap_enabled() const;
  445. void clear();
  446. void set_syntax_coloring(bool p_enabled);
  447. bool is_syntax_coloring_enabled() const;
  448. void cut();
  449. void copy();
  450. void paste();
  451. void select_all();
  452. void select(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
  453. void deselect();
  454. void swap_lines(int line1, int line2);
  455. void set_search_text(const String &p_search_text);
  456. void set_search_flags(uint32_t p_flags);
  457. void set_current_search_result(int line, int col);
  458. void set_highlight_all_occurrences(const bool p_enabled);
  459. bool is_highlight_all_occurrences_enabled() const;
  460. bool is_selection_active() const;
  461. int get_selection_from_line() const;
  462. int get_selection_from_column() const;
  463. int get_selection_to_line() const;
  464. int get_selection_to_column() const;
  465. String get_selection_text() const;
  466. String get_word_under_cursor() const;
  467. String get_word_at_pos(const Vector2 &p_pos) const;
  468. bool search(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column, int &r_line, int &r_column) const;
  469. void undo();
  470. void redo();
  471. void clear_undo_history();
  472. void set_indent_using_spaces(const bool p_use_spaces);
  473. bool is_indent_using_spaces() const;
  474. void set_indent_size(const int p_size);
  475. int get_indent_size();
  476. void set_draw_tabs(bool p_draw);
  477. bool is_drawing_tabs() const;
  478. void set_override_selected_font_color(bool p_override_selected_font_color);
  479. bool is_overriding_selected_font_color() const;
  480. void set_insert_mode(bool p_enabled);
  481. bool is_insert_mode() const;
  482. void add_keyword_color(const String &p_keyword, const Color &p_color);
  483. bool has_keyword_color(String p_keyword) const;
  484. Color get_keyword_color(String p_keyword) const;
  485. void add_color_region(const String &p_begin_key = String(), const String &p_end_key = String(), const Color &p_color = Color(), bool p_line_only = false);
  486. void clear_colors();
  487. void add_member_keyword(const String &p_keyword, const Color &p_color);
  488. bool has_member_color(String p_member) const;
  489. Color get_member_color(String p_member) const;
  490. void clear_member_keywords();
  491. double get_v_scroll() const;
  492. void set_v_scroll(double p_scroll);
  493. int get_h_scroll() const;
  494. void set_h_scroll(int p_scroll);
  495. void set_smooth_scroll_enabled(bool p_enable);
  496. bool is_smooth_scroll_enabled() const;
  497. void set_v_scroll_speed(float p_speed);
  498. float get_v_scroll_speed() const;
  499. uint32_t get_version() const;
  500. uint32_t get_saved_version() const;
  501. void tag_saved_version();
  502. void menu_option(int p_option);
  503. void set_show_line_numbers(bool p_show);
  504. bool is_show_line_numbers_enabled() const;
  505. void set_highlight_current_line(bool p_enabled);
  506. bool is_highlight_current_line_enabled() const;
  507. void set_line_numbers_zero_padded(bool p_zero_padded);
  508. void set_show_line_length_guideline(bool p_show);
  509. void set_line_length_guideline_column(int p_column);
  510. void set_breakpoint_gutter_enabled(bool p_draw);
  511. bool is_breakpoint_gutter_enabled() const;
  512. void set_breakpoint_gutter_width(int p_gutter_width);
  513. int get_breakpoint_gutter_width() const;
  514. void set_draw_fold_gutter(bool p_draw);
  515. bool is_drawing_fold_gutter() const;
  516. void set_fold_gutter_width(int p_gutter_width);
  517. int get_fold_gutter_width() const;
  518. void set_hiding_enabled(int p_enabled);
  519. int is_hiding_enabled() const;
  520. void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata);
  521. void set_completion(bool p_enabled, const Vector<String> &p_prefixes);
  522. void code_complete(const Vector<String> &p_strings, bool p_forced = false);
  523. void set_code_hint(const String &p_hint);
  524. void query_code_comple();
  525. void set_select_identifiers_on_hover(bool p_enable);
  526. bool is_selecting_identifiers_on_hover_enabled() const;
  527. void set_context_menu_enabled(bool p_enable);
  528. bool is_context_menu_enabled();
  529. PopupMenu *get_menu() const;
  530. String get_text_for_completion();
  531. String get_text_for_lookup_completion();
  532. virtual bool is_text_field() const;
  533. TextEdit();
  534. ~TextEdit();
  535. };
  536. VARIANT_ENUM_CAST(TextEdit::MenuItems);
  537. VARIANT_ENUM_CAST(TextEdit::SearchFlags);
  538. class SyntaxHighlighter {
  539. protected:
  540. TextEdit *text_editor;
  541. public:
  542. virtual void _update_cache() = 0;
  543. virtual Map<int, TextEdit::HighlighterInfo> _get_line_syntax_highlighting(int p_line) = 0;
  544. virtual String get_name() = 0;
  545. virtual List<String> get_supported_languages() = 0;
  546. void set_text_editor(TextEdit *p_text_editor);
  547. TextEdit *get_text_editor();
  548. };
  549. #endif // TEXT_EDIT_H