2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* text_edit.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2017-01-01 21:01:57 +00:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-07 22:11:42 +00:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#ifndef TEXT_EDIT_H
|
|
|
|
#define TEXT_EDIT_H
|
|
|
|
|
|
|
|
#include "scene/gui/control.h"
|
2016-05-16 23:25:17 +00:00
|
|
|
#include "scene/gui/popup_menu.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/gui/scroll_bar.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "scene/main/timer.h"
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
class TextEdit : public Control {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(TextEdit, Control);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
struct Cursor {
|
|
|
|
int last_fit_x;
|
2017-03-05 15:44:50 +00:00
|
|
|
int line, column; ///< cursor
|
|
|
|
int x_ofs, line_ofs;
|
2014-02-10 01:10:30 +00:00
|
|
|
} cursor;
|
|
|
|
|
|
|
|
struct Selection {
|
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
|
|
|
|
MODE_NONE,
|
|
|
|
MODE_SHIFT,
|
2017-11-05 15:54:00 +00:00
|
|
|
MODE_POINTER,
|
|
|
|
MODE_WORD,
|
|
|
|
MODE_LINE
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Mode selecting_mode;
|
2017-03-05 15:44:50 +00:00
|
|
|
int selecting_line, selecting_column;
|
2017-11-05 15:54:00 +00:00
|
|
|
int selected_word_beg, selected_word_end, selected_word_origin;
|
2015-08-12 22:34:07 +00:00
|
|
|
bool selecting_text;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
bool active;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
int from_line, from_column;
|
|
|
|
int to_line, to_column;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-01-02 18:08:40 +00:00
|
|
|
bool shiftclick_left;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
} selection;
|
|
|
|
|
|
|
|
struct Cache {
|
|
|
|
|
|
|
|
Ref<Texture> tab_icon;
|
|
|
|
Ref<StyleBox> style_normal;
|
|
|
|
Ref<StyleBox> style_focus;
|
|
|
|
Ref<Font> font;
|
2016-06-21 15:50:31 +00:00
|
|
|
Color completion_background_color;
|
2016-06-21 16:21:55 +00:00
|
|
|
Color completion_selected_color;
|
2016-06-21 16:34:38 +00:00
|
|
|
Color completion_existing_color;
|
2016-07-11 13:25:56 +00:00
|
|
|
Color completion_font_color;
|
2016-04-05 16:06:56 +00:00
|
|
|
Color caret_color;
|
2016-07-12 15:07:17 +00:00
|
|
|
Color caret_background_color;
|
2016-04-08 19:05:50 +00:00
|
|
|
Color line_number_color;
|
2014-02-10 01:10:30 +00:00
|
|
|
Color font_color;
|
|
|
|
Color font_selected_color;
|
|
|
|
Color keyword_color;
|
2016-03-21 15:45:38 +00:00
|
|
|
Color number_color;
|
2016-04-02 19:46:42 +00:00
|
|
|
Color function_color;
|
2016-04-05 14:50:54 +00:00
|
|
|
Color member_variable_color;
|
2014-02-10 01:10:30 +00:00
|
|
|
Color selection_color;
|
|
|
|
Color mark_color;
|
|
|
|
Color breakpoint_color;
|
|
|
|
Color current_line_color;
|
2017-01-28 14:36:57 +00:00
|
|
|
Color line_length_guideline_color;
|
2014-12-17 04:53:34 +00:00
|
|
|
Color brace_mismatch_color;
|
2016-03-16 21:20:42 +00:00
|
|
|
Color word_highlighted_color;
|
2016-05-28 16:25:45 +00:00
|
|
|
Color search_result_color;
|
|
|
|
Color search_result_border_color;
|
2016-11-06 13:50:23 +00:00
|
|
|
Color symbol_color;
|
|
|
|
Color background_color;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
int row_height;
|
|
|
|
int line_spacing;
|
|
|
|
int line_number_w;
|
2016-05-26 13:17:14 +00:00
|
|
|
int breakpoint_gutter_width;
|
2014-02-10 01:10:30 +00:00
|
|
|
Size2 size;
|
|
|
|
} cache;
|
|
|
|
|
|
|
|
struct ColorRegion {
|
|
|
|
|
|
|
|
Color color;
|
|
|
|
String begin_key;
|
|
|
|
String end_key;
|
|
|
|
bool line_only;
|
|
|
|
bool eq;
|
2017-03-05 15:44:50 +00:00
|
|
|
ColorRegion(const String &p_begin_key = "", const String &p_end_key = "", const Color &p_color = Color(), bool p_line_only = false) {
|
|
|
|
begin_key = p_begin_key;
|
|
|
|
end_key = p_end_key;
|
|
|
|
color = p_color;
|
|
|
|
line_only = p_line_only || p_end_key == "";
|
|
|
|
eq = begin_key == end_key;
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Text {
|
|
|
|
public:
|
|
|
|
struct ColorRegionInfo {
|
|
|
|
|
|
|
|
int region;
|
|
|
|
bool end;
|
|
|
|
};
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
struct Line {
|
|
|
|
int width_cache : 24;
|
|
|
|
bool marked : 1;
|
|
|
|
bool breakpoint : 1;
|
|
|
|
Map<int, ColorRegionInfo> region_info;
|
|
|
|
String data;
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
private:
|
2017-03-05 15:44:50 +00:00
|
|
|
const Vector<ColorRegion> *color_regions;
|
|
|
|
mutable Vector<Line> text;
|
|
|
|
Ref<Font> font;
|
2017-04-17 13:24:30 +00:00
|
|
|
int indent_size;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void _update_line_cache(int p_line) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
public:
|
2017-04-17 13:24:30 +00:00
|
|
|
void set_indent_size(int p_indent_size);
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_font(const Ref<Font> &p_font);
|
|
|
|
void set_color_regions(const Vector<ColorRegion> *p_regions) { color_regions = p_regions; }
|
2014-02-10 01:10:30 +00:00
|
|
|
int get_line_width(int p_line) const;
|
2016-03-08 23:00:52 +00:00
|
|
|
int get_max_width() const;
|
2017-03-05 15:44:50 +00:00
|
|
|
const Map<int, ColorRegionInfo> &get_color_region_info(int p_line);
|
2017-08-11 19:10:05 +00:00
|
|
|
void set(int p_line, const String &p_text);
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_marked(int p_line, bool p_marked) { text[p_line].marked = p_marked; }
|
2014-02-10 01:10:30 +00:00
|
|
|
bool is_marked(int p_line) const { return text[p_line].marked; }
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_breakpoint(int p_line, bool p_breakpoint) { text[p_line].breakpoint = p_breakpoint; }
|
2014-02-10 01:10:30 +00:00
|
|
|
bool is_breakpoint(int p_line) const { return text[p_line].breakpoint; }
|
2017-03-05 15:44:50 +00:00
|
|
|
void insert(int p_at, const String &p_text);
|
2014-02-10 01:10:30 +00:00
|
|
|
void remove(int p_at);
|
|
|
|
int size() const { return text.size(); }
|
|
|
|
void clear();
|
|
|
|
void clear_caches();
|
2017-03-05 15:44:50 +00:00
|
|
|
_FORCE_INLINE_ const String &operator[](int p_line) const { return text[p_line].data; }
|
2017-04-17 13:24:30 +00:00
|
|
|
Text() { indent_size = 4; }
|
2017-03-05 15:44:50 +00:00
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
struct TextOperation {
|
|
|
|
|
|
|
|
enum Type {
|
|
|
|
TYPE_NONE,
|
|
|
|
TYPE_INSERT,
|
|
|
|
TYPE_REMOVE
|
|
|
|
};
|
|
|
|
|
|
|
|
Type type;
|
2017-03-05 15:44:50 +00:00
|
|
|
int from_line, from_column;
|
2014-02-10 01:10:30 +00:00
|
|
|
int to_line, to_column;
|
|
|
|
String text;
|
2016-03-13 20:08:12 +00:00
|
|
|
uint32_t prev_version;
|
2014-02-10 01:10:30 +00:00
|
|
|
uint32_t version;
|
|
|
|
bool chain_forward;
|
|
|
|
bool chain_backward;
|
|
|
|
};
|
|
|
|
|
2017-08-07 11:09:56 +00:00
|
|
|
String ime_text;
|
|
|
|
Point2 ime_selection;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
TextOperation current_op;
|
|
|
|
|
|
|
|
List<TextOperation> undo_stack;
|
2017-03-05 15:44:50 +00:00
|
|
|
List<TextOperation>::Element *undo_stack_pos;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void _clear_redo();
|
2017-03-05 15:44:50 +00:00
|
|
|
void _do_text_op(const TextOperation &p_op, bool p_reverse);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//syntax coloring
|
2017-03-05 15:44:50 +00:00
|
|
|
HashMap<String, Color> keywords;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Vector<ColorRegion> color_regions;
|
|
|
|
|
|
|
|
Set<String> completion_prefixes;
|
|
|
|
bool completion_enabled;
|
|
|
|
Vector<String> completion_strings;
|
|
|
|
Vector<String> completion_options;
|
|
|
|
bool completion_active;
|
2017-08-24 03:06:56 +00:00
|
|
|
bool completion_forced;
|
2014-02-10 01:10:30 +00:00
|
|
|
String completion_current;
|
|
|
|
String completion_base;
|
|
|
|
int completion_index;
|
|
|
|
Rect2i completion_rect;
|
|
|
|
int completion_line_ofs;
|
2014-12-17 01:31:57 +00:00
|
|
|
String completion_hint;
|
|
|
|
int completion_hint_offset;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
bool setting_text;
|
|
|
|
|
|
|
|
// data
|
|
|
|
Text text;
|
|
|
|
|
|
|
|
uint32_t version;
|
|
|
|
uint32_t saved_version;
|
|
|
|
|
|
|
|
int max_chars;
|
|
|
|
bool readonly;
|
|
|
|
bool syntax_coloring;
|
2017-04-17 13:24:30 +00:00
|
|
|
bool indent_using_spaces;
|
|
|
|
int indent_size;
|
|
|
|
String space_indent;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-09 18:21:55 +00:00
|
|
|
Timer *caret_blink_timer;
|
|
|
|
bool caret_blink_enabled;
|
|
|
|
bool draw_caret;
|
2016-06-19 15:11:16 +00:00
|
|
|
bool window_has_focus;
|
2016-07-12 15:07:17 +00:00
|
|
|
bool block_caret;
|
2016-05-09 18:21:55 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
bool setting_row;
|
|
|
|
bool wrap;
|
|
|
|
bool draw_tabs;
|
2017-09-27 17:24:05 +00:00
|
|
|
bool override_selected_font_color;
|
2014-02-10 01:10:30 +00:00
|
|
|
bool cursor_changed_dirty;
|
|
|
|
bool text_changed_dirty;
|
|
|
|
bool undo_enabled;
|
|
|
|
bool line_numbers;
|
2016-10-10 11:43:09 +00:00
|
|
|
bool line_numbers_zero_padded;
|
2016-10-10 08:34:51 +00:00
|
|
|
bool line_length_guideline;
|
|
|
|
int line_length_guideline_col;
|
2016-05-26 13:17:14 +00:00
|
|
|
bool draw_breakpoint_gutter;
|
|
|
|
int breakpoint_gutter_width;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2016-03-16 21:20:42 +00:00
|
|
|
bool highlight_all_occurrences;
|
2016-03-07 02:32:51 +00:00
|
|
|
bool scroll_past_end_of_file_enabled;
|
2014-04-30 16:21:58 +00:00
|
|
|
bool auto_brace_completion_enabled;
|
2014-12-17 04:53:34 +00:00
|
|
|
bool brace_matching_enabled;
|
2017-10-22 12:38:00 +00:00
|
|
|
bool highlight_current_line;
|
2015-11-29 16:02:35 +00:00
|
|
|
bool auto_indent;
|
2014-08-02 01:10:38 +00:00
|
|
|
bool cut_copy_line;
|
2016-03-31 19:49:30 +00:00
|
|
|
bool insert_mode;
|
2016-09-12 13:52:29 +00:00
|
|
|
bool select_identifiers_enabled;
|
|
|
|
|
2017-08-19 14:23:45 +00:00
|
|
|
bool smooth_scroll_enabled;
|
|
|
|
bool scrolling;
|
|
|
|
float target_v_scroll;
|
2017-08-21 18:13:24 +00:00
|
|
|
float v_scroll_speed;
|
2017-08-19 14:23:45 +00:00
|
|
|
|
2016-10-10 11:21:37 +00:00
|
|
|
bool raised_from_completion;
|
|
|
|
|
2017-04-06 15:35:08 +00:00
|
|
|
String highlighted_word;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
uint64_t last_dblclk;
|
|
|
|
|
|
|
|
Timer *idle_detect;
|
2015-12-09 18:56:41 +00:00
|
|
|
Timer *click_select_held;
|
2014-02-10 01:10:30 +00:00
|
|
|
HScrollBar *h_scroll;
|
|
|
|
VScrollBar *v_scroll;
|
|
|
|
bool updating_scrolls;
|
|
|
|
|
|
|
|
Object *tooltip_obj;
|
|
|
|
StringName tooltip_func;
|
|
|
|
Variant tooltip_ud;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-04-26 12:42:19 +00:00
|
|
|
bool next_operation_is_complex;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-03-04 10:05:42 +00:00
|
|
|
bool callhint_below;
|
|
|
|
Vector2 callhint_offset;
|
|
|
|
|
2016-05-28 16:25:45 +00:00
|
|
|
String search_text;
|
|
|
|
uint32_t search_flags;
|
|
|
|
int search_result_line;
|
|
|
|
int search_result_col;
|
|
|
|
|
2016-09-29 07:12:45 +00:00
|
|
|
bool context_menu_enabled;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
int get_visible_rows() const;
|
|
|
|
|
|
|
|
int get_char_count();
|
|
|
|
|
2017-08-11 19:10:05 +00:00
|
|
|
int get_char_pos_for(int p_px, String p_str) const;
|
|
|
|
int get_column_x_offset(int p_char, String p_str);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void adjust_viewport_to_cursor();
|
|
|
|
void _scroll_moved(double);
|
|
|
|
void _update_scrollbars();
|
2017-08-22 19:02:08 +00:00
|
|
|
void _v_scroll_input();
|
2015-12-09 18:56:41 +00:00
|
|
|
void _click_selection_held();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-11-05 15:54:00 +00:00
|
|
|
void _update_selection_mode_pointer();
|
|
|
|
void _update_selection_mode_word();
|
|
|
|
void _update_selection_mode_line();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _pre_shift_selection();
|
|
|
|
void _post_shift_selection();
|
|
|
|
|
2016-04-27 17:32:14 +00:00
|
|
|
void _scroll_lines_up();
|
|
|
|
void _scroll_lines_down();
|
|
|
|
|
2017-08-07 11:09:56 +00:00
|
|
|
static void _ime_text_callback(void *p_self, String p_text, Point2 p_selection);
|
|
|
|
|
2017-01-14 11:26:56 +00:00
|
|
|
//void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
|
2016-06-12 16:31:22 +00:00
|
|
|
Size2 get_minimum_size() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
int get_row_height() const;
|
|
|
|
|
2016-05-09 18:21:55 +00:00
|
|
|
void _reset_caret_blink_timer();
|
|
|
|
void _toggle_draw_caret();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _update_caches();
|
|
|
|
void _cursor_changed_emit();
|
|
|
|
void _text_changed_emit();
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _push_current_op();
|
|
|
|
|
|
|
|
/* super internal api, undo/redo builds on it */
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2017-08-11 19:10:05 +00:00
|
|
|
void _base_insert_text(int p_line, int p_char, const String &p_text, int &r_end_line, int &r_end_column);
|
2017-03-05 15:44:50 +00:00
|
|
|
String _base_get_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) const;
|
|
|
|
void _base_remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-28 16:25:45 +00:00
|
|
|
int _get_column_pos_of_word(const String &p_key, const String &p_search, uint32_t p_search_flags, int p_from_column);
|
2016-03-16 21:20:42 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
PoolVector<int> _search_bind(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-16 23:25:17 +00:00
|
|
|
PopupMenu *menu;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _clear();
|
|
|
|
void _cancel_completion();
|
2014-12-17 01:31:57 +00:00
|
|
|
void _cancel_code_hint();
|
2014-02-10 01:10:30 +00:00
|
|
|
void _confirm_completion();
|
|
|
|
void _update_completion_candidates();
|
|
|
|
|
|
|
|
protected:
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual String get_tooltip(const Point2 &p_pos) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-08-11 19:10:05 +00:00
|
|
|
void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = NULL, int *r_end_char = NULL);
|
2017-03-05 15:44:50 +00:00
|
|
|
void _remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
|
|
|
|
void _insert_text_at_cursor(const String &p_text);
|
2017-08-11 19:10:05 +00:00
|
|
|
void _gui_input(const Ref<InputEvent> &p_gui_input);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _notification(int p_what);
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-04-27 10:34:37 +00:00
|
|
|
void _consume_pair_symbol(CharType ch);
|
|
|
|
void _consume_backspace_for_pair_symbol(int prev_line, int prev_column);
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2016-05-16 23:25:17 +00:00
|
|
|
enum MenuItems {
|
|
|
|
MENU_CUT,
|
|
|
|
MENU_COPY,
|
|
|
|
MENU_PASTE,
|
|
|
|
MENU_CLEAR,
|
|
|
|
MENU_SELECT_ALL,
|
|
|
|
MENU_UNDO,
|
|
|
|
MENU_MAX
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
enum SearchFlags {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
SEARCH_MATCH_CASE = 1,
|
|
|
|
SEARCH_WHOLE_WORDS = 2,
|
|
|
|
SEARCH_BACKWARDS = 4
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void _get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) const;
|
2016-09-29 07:12:45 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
//void delete_char();
|
|
|
|
//void delete_line();
|
|
|
|
|
2016-04-06 06:36:29 +00:00
|
|
|
void begin_complex_operation();
|
|
|
|
void end_complex_operation();
|
|
|
|
|
2017-09-06 01:02:51 +00:00
|
|
|
bool is_insert_text_operation();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_text(String p_text);
|
2017-03-05 15:44:50 +00:00
|
|
|
void insert_text_at_cursor(const String &p_text);
|
|
|
|
void insert_at(const String &p_text, int at);
|
2014-02-10 01:10:30 +00:00
|
|
|
int get_line_count() const;
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_line_as_marked(int p_line, bool p_marked);
|
|
|
|
void set_line_as_breakpoint(int p_line, bool p_breakpoint);
|
2014-02-10 01:10:30 +00:00
|
|
|
bool is_line_set_as_breakpoint(int p_line) const;
|
|
|
|
void get_breakpoints(List<int> *p_breakpoints) const;
|
|
|
|
String get_text();
|
|
|
|
String get_line(int line) const;
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_line(int line, String new_text);
|
2014-02-10 01:10:30 +00:00
|
|
|
void backspace_at_cursor();
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2016-04-06 15:37:03 +00:00
|
|
|
void indent_selection_left();
|
|
|
|
void indent_selection_right();
|
|
|
|
|
2016-03-07 02:32:51 +00:00
|
|
|
inline void set_scroll_pass_end_of_file(bool p_enabled) {
|
|
|
|
scroll_past_end_of_file_enabled = p_enabled;
|
|
|
|
update();
|
|
|
|
}
|
2014-04-30 16:21:58 +00:00
|
|
|
inline void set_auto_brace_completion(bool p_enabled) {
|
|
|
|
auto_brace_completion_enabled = p_enabled;
|
|
|
|
}
|
2014-12-17 04:53:34 +00:00
|
|
|
inline void set_brace_matching(bool p_enabled) {
|
2017-03-05 15:44:50 +00:00
|
|
|
brace_matching_enabled = p_enabled;
|
2014-12-17 04:53:34 +00:00
|
|
|
update();
|
|
|
|
}
|
2016-03-04 10:05:42 +00:00
|
|
|
inline void set_callhint_settings(bool below, Vector2 offset) {
|
|
|
|
callhint_below = below;
|
|
|
|
callhint_offset = offset;
|
|
|
|
}
|
2015-11-29 16:02:35 +00:00
|
|
|
void set_auto_indent(bool p_auto_indent);
|
2014-12-17 04:53:34 +00:00
|
|
|
|
2016-07-21 01:40:08 +00:00
|
|
|
void center_viewport_to_cursor();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void cursor_set_column(int p_col, bool p_adjust_viewport = true);
|
|
|
|
void cursor_set_line(int p_row, bool p_adjust_viewport = true);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
int cursor_get_column() const;
|
|
|
|
int cursor_get_line() const;
|
|
|
|
|
2016-05-09 18:21:55 +00:00
|
|
|
bool cursor_get_blink_enabled() const;
|
|
|
|
void cursor_set_blink_enabled(const bool p_enabled);
|
|
|
|
|
|
|
|
float cursor_get_blink_speed() const;
|
|
|
|
void cursor_set_blink_speed(const float p_speed);
|
|
|
|
|
2016-07-12 15:07:17 +00:00
|
|
|
void cursor_set_block_mode(const bool p_enable);
|
|
|
|
bool cursor_is_block_mode() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_readonly(bool p_readonly);
|
|
|
|
|
|
|
|
void set_max_chars(int p_max_chars);
|
|
|
|
void set_wrap(bool p_wrap);
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
void set_syntax_coloring(bool p_enabled);
|
|
|
|
bool is_syntax_coloring_enabled() const;
|
|
|
|
|
|
|
|
void cut();
|
|
|
|
void copy();
|
|
|
|
void paste();
|
|
|
|
void select_all();
|
2017-03-05 15:44:50 +00:00
|
|
|
void select(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
|
2014-02-10 01:10:30 +00:00
|
|
|
void deselect();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_search_text(const String &p_search_text);
|
2016-05-28 16:25:45 +00:00
|
|
|
void set_search_flags(uint32_t p_flags);
|
|
|
|
void set_current_search_result(int line, int col);
|
|
|
|
|
2016-03-16 21:20:42 +00:00
|
|
|
void set_highlight_all_occurrences(const bool p_enabled);
|
2016-07-11 14:20:01 +00:00
|
|
|
bool is_highlight_all_occurrences_enabled() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
bool is_selection_active() const;
|
|
|
|
int get_selection_from_line() const;
|
2016-08-06 22:00:54 +00:00
|
|
|
int get_selection_from_column() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
int get_selection_to_line() const;
|
|
|
|
int get_selection_to_column() const;
|
|
|
|
String get_selection_text() const;
|
|
|
|
|
2014-05-06 09:36:39 +00:00
|
|
|
String get_word_under_cursor() const;
|
2017-03-05 15:44:50 +00:00
|
|
|
String get_word_at_pos(const Vector2 &p_pos) const;
|
2014-05-06 09:36:39 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
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;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void undo();
|
|
|
|
void redo();
|
2014-12-17 01:31:57 +00:00
|
|
|
void clear_undo_history();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-04-17 13:24:30 +00:00
|
|
|
void set_indent_using_spaces(const bool p_use_spaces);
|
|
|
|
bool is_indent_using_spaces() const;
|
|
|
|
void set_indent_size(const int p_size);
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_draw_tabs(bool p_draw);
|
|
|
|
bool is_drawing_tabs() const;
|
2017-09-27 17:24:05 +00:00
|
|
|
void set_override_selected_font_color(bool p_override_selected_font_color);
|
|
|
|
bool is_overriding_selected_font_color() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-03-31 19:49:30 +00:00
|
|
|
void set_insert_mode(bool p_enabled);
|
|
|
|
bool is_insert_mode() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void add_keyword_color(const String &p_keyword, const Color &p_color);
|
|
|
|
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);
|
2014-02-10 01:10:30 +00:00
|
|
|
void clear_colors();
|
|
|
|
|
|
|
|
int get_v_scroll() const;
|
|
|
|
void set_v_scroll(int p_scroll);
|
|
|
|
|
|
|
|
int get_h_scroll() const;
|
|
|
|
void set_h_scroll(int p_scroll);
|
|
|
|
|
2017-08-19 14:23:45 +00:00
|
|
|
void set_smooth_scroll_enabled(bool p_enable);
|
|
|
|
bool is_smooth_scroll_enabled() const;
|
|
|
|
|
2017-08-21 18:13:24 +00:00
|
|
|
void set_v_scroll_speed(float p_speed);
|
|
|
|
float get_v_scroll_speed() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
uint32_t get_version() const;
|
|
|
|
uint32_t get_saved_version() const;
|
|
|
|
void tag_saved_version();
|
|
|
|
|
2016-05-16 23:25:17 +00:00
|
|
|
void menu_option(int p_option);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_show_line_numbers(bool p_show);
|
2016-07-11 14:11:35 +00:00
|
|
|
bool is_show_line_numbers_enabled() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-10-22 12:38:00 +00:00
|
|
|
void set_highlight_current_line(bool p_enabled);
|
|
|
|
bool is_highlight_current_line_enabled() const;
|
|
|
|
|
2016-10-10 11:43:09 +00:00
|
|
|
void set_line_numbers_zero_padded(bool p_zero_padded);
|
|
|
|
|
2016-10-10 08:34:51 +00:00
|
|
|
void set_show_line_length_guideline(bool p_show);
|
|
|
|
void set_line_length_guideline_column(int p_column);
|
|
|
|
|
2016-05-26 13:17:14 +00:00
|
|
|
void set_draw_breakpoint_gutter(bool p_draw);
|
|
|
|
bool is_drawing_breakpoint_gutter() const;
|
|
|
|
|
|
|
|
void set_breakpoint_gutter_width(int p_gutter_width);
|
|
|
|
int get_breakpoint_gutter_width() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_completion(bool p_enabled, const Vector<String> &p_prefixes);
|
2017-08-24 03:06:56 +00:00
|
|
|
void code_complete(const Vector<String> &p_strings, bool p_forced = false);
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_code_hint(const String &p_hint);
|
2014-02-10 01:10:30 +00:00
|
|
|
void query_code_comple();
|
|
|
|
|
2016-09-12 13:52:29 +00:00
|
|
|
void set_select_identifiers_on_hover(bool p_enable);
|
|
|
|
bool is_selecting_identifiers_on_hover_enabled() const;
|
|
|
|
|
2016-09-29 07:12:45 +00:00
|
|
|
void set_context_menu_enabled(bool p_enable);
|
2016-05-16 23:25:17 +00:00
|
|
|
PopupMenu *get_menu() const;
|
|
|
|
|
2014-12-17 01:31:57 +00:00
|
|
|
String get_text_for_completion();
|
2016-09-12 13:52:29 +00:00
|
|
|
String get_text_for_lookup_completion();
|
2014-12-17 01:31:57 +00:00
|
|
|
|
2016-08-06 22:00:54 +00:00
|
|
|
virtual bool is_text_field() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
TextEdit();
|
|
|
|
~TextEdit();
|
|
|
|
};
|
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
VARIANT_ENUM_CAST(TextEdit::MenuItems);
|
|
|
|
VARIANT_ENUM_CAST(TextEdit::SearchFlags);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#endif // TEXT_EDIT_H
|