|
@@ -937,7 +937,7 @@ void TextEdit::_notification(int p_what) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- Map<int, HighlighterInfo> color_map;
|
|
|
+ Dictionary color_map;
|
|
|
if (syntax_coloring) {
|
|
|
color_map = _get_line_syntax_highlighting(minimap_line);
|
|
|
}
|
|
@@ -980,7 +980,7 @@ void TextEdit::_notification(int p_what) {
|
|
|
for (int j = 0; j < str.length(); j++) {
|
|
|
if (syntax_coloring) {
|
|
|
if (color_map.has(last_wrap_column + j)) {
|
|
|
- current_color = color_map[last_wrap_column + j].color;
|
|
|
+ current_color = color_map[last_wrap_column + j].get("color");
|
|
|
if (readonly) {
|
|
|
current_color.a = cache.font_color_readonly.a;
|
|
|
}
|
|
@@ -1060,7 +1060,7 @@ void TextEdit::_notification(int p_what) {
|
|
|
|
|
|
const String &fullstr = text[line];
|
|
|
|
|
|
- Map<int, HighlighterInfo> color_map;
|
|
|
+ Dictionary color_map;
|
|
|
if (syntax_coloring) {
|
|
|
color_map = _get_line_syntax_highlighting(line);
|
|
|
}
|
|
@@ -1255,7 +1255,7 @@ void TextEdit::_notification(int p_what) {
|
|
|
for (; j < str.length(); j++) {
|
|
|
if (syntax_coloring) {
|
|
|
if (color_map.has(last_wrap_column + j)) {
|
|
|
- current_color = color_map[last_wrap_column + j].color;
|
|
|
+ current_color = color_map[last_wrap_column + j].get("color");
|
|
|
if (readonly && current_color.a > cache.font_color_readonly.a) {
|
|
|
current_color.a = cache.font_color_readonly.a;
|
|
|
}
|
|
@@ -5017,20 +5017,20 @@ void TextEdit::_update_caches() {
|
|
|
cache.executing_icon = get_theme_icon("MainPlay", "EditorIcons");
|
|
|
text.set_font(cache.font);
|
|
|
|
|
|
- if (syntax_highlighter) {
|
|
|
- syntax_highlighter->_update_cache();
|
|
|
+ if (syntax_highlighter.is_valid()) {
|
|
|
+ syntax_highlighter->update_cache();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-SyntaxHighlighter *TextEdit::_get_syntax_highlighting() {
|
|
|
+Ref<SyntaxHighlighter> TextEdit::get_syntax_highlighting() {
|
|
|
return syntax_highlighter;
|
|
|
}
|
|
|
|
|
|
-void TextEdit::_set_syntax_highlighting(SyntaxHighlighter *p_syntax_highlighter) {
|
|
|
+void TextEdit::set_syntax_highlighting(Ref<SyntaxHighlighter> p_syntax_highlighter) {
|
|
|
syntax_highlighter = p_syntax_highlighter;
|
|
|
- if (syntax_highlighter) {
|
|
|
- syntax_highlighter->set_text_editor(this);
|
|
|
- syntax_highlighter->_update_cache();
|
|
|
+ if (syntax_highlighter.is_valid()) {
|
|
|
+ syntax_highlighter->set_text_edit(this);
|
|
|
+ syntax_highlighter->update_cache();
|
|
|
}
|
|
|
syntax_highlighting_cache.clear();
|
|
|
update();
|
|
@@ -7056,6 +7056,9 @@ void TextEdit::_bind_methods() {
|
|
|
ClassDB::bind_method(D_METHOD("set_syntax_coloring", "enable"), &TextEdit::set_syntax_coloring);
|
|
|
ClassDB::bind_method(D_METHOD("is_syntax_coloring_enabled"), &TextEdit::is_syntax_coloring_enabled);
|
|
|
|
|
|
+ ClassDB::bind_method(D_METHOD("set_syntax_highlighting", "syntax_highlighter"), &TextEdit::set_syntax_highlighting);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_syntax_highlighting"), &TextEdit::get_syntax_highlighting);
|
|
|
+
|
|
|
ClassDB::bind_method(D_METHOD("set_highlight_current_line", "enabled"), &TextEdit::set_highlight_current_line);
|
|
|
ClassDB::bind_method(D_METHOD("is_highlight_current_line_enabled"), &TextEdit::is_highlight_current_line_enabled);
|
|
|
|
|
@@ -7088,6 +7091,7 @@ void TextEdit::_bind_methods() {
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "readonly"), "set_readonly", "is_readonly");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_current_line"), "set_highlight_current_line", "is_highlight_current_line_enabled");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled");
|
|
|
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "syntax_highlighter", PROPERTY_HINT_RESOURCE_TYPE, "SyntaxHighlighter"), "set_syntax_highlighting", "get_syntax_highlighting");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_tabs"), "set_draw_tabs", "is_drawing_tabs");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_spaces"), "set_draw_spaces", "is_drawing_spaces");
|
|
@@ -7150,7 +7154,7 @@ TextEdit::TextEdit() {
|
|
|
wrap_at = 0;
|
|
|
wrap_right_offset = 10;
|
|
|
set_focus_mode(FOCUS_ALL);
|
|
|
- syntax_highlighter = nullptr;
|
|
|
+ syntax_highlighter = Ref<SyntaxHighlighter>(NULL);
|
|
|
_update_caches();
|
|
|
cache.row_height = 1;
|
|
|
cache.line_spacing = 1;
|
|
@@ -7281,18 +7285,18 @@ TextEdit::~TextEdit() {
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
-Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int p_line) {
|
|
|
+Dictionary TextEdit::_get_line_syntax_highlighting(int p_line) {
|
|
|
if (syntax_highlighting_cache.has(p_line)) {
|
|
|
return syntax_highlighting_cache[p_line];
|
|
|
}
|
|
|
|
|
|
- if (syntax_highlighter != nullptr) {
|
|
|
- Map<int, HighlighterInfo> color_map = syntax_highlighter->_get_line_syntax_highlighting(p_line);
|
|
|
+ if (syntax_highlighter.is_valid()) {
|
|
|
+ Dictionary color_map = syntax_highlighter->get_line_syntax_highlighting(p_line);
|
|
|
syntax_highlighting_cache[p_line] = color_map;
|
|
|
return color_map;
|
|
|
}
|
|
|
|
|
|
- Map<int, HighlighterInfo> color_map;
|
|
|
+ Dictionary color_map;
|
|
|
|
|
|
bool prev_is_char = false;
|
|
|
bool prev_is_number = false;
|
|
@@ -7311,7 +7315,7 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int
|
|
|
const String &str = text[p_line];
|
|
|
Color prev_color;
|
|
|
for (int j = 0; j < str.length(); j++) {
|
|
|
- HighlighterInfo highlighter_info;
|
|
|
+ Dictionary highlighter_info;
|
|
|
|
|
|
if (deregion > 0) {
|
|
|
deregion--;
|
|
@@ -7323,7 +7327,7 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int
|
|
|
if (deregion != 0) {
|
|
|
if (color != prev_color) {
|
|
|
prev_color = color;
|
|
|
- highlighter_info.color = color;
|
|
|
+ highlighter_info["color"] = color;
|
|
|
color_map[j] = highlighter_info;
|
|
|
}
|
|
|
continue;
|
|
@@ -7466,7 +7470,7 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int
|
|
|
|
|
|
if (color != prev_color) {
|
|
|
prev_color = color;
|
|
|
- highlighter_info.color = color;
|
|
|
+ highlighter_info["color"] = color;
|
|
|
color_map[j] = highlighter_info;
|
|
|
}
|
|
|
}
|
|
@@ -7474,11 +7478,3 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int
|
|
|
syntax_highlighting_cache[p_line] = color_map;
|
|
|
return color_map;
|
|
|
}
|
|
|
-
|
|
|
-void SyntaxHighlighter::set_text_editor(TextEdit *p_text_editor) {
|
|
|
- text_editor = p_text_editor;
|
|
|
-}
|
|
|
-
|
|
|
-TextEdit *SyntaxHighlighter::get_text_editor() {
|
|
|
- return text_editor;
|
|
|
-}
|