summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/gui/text_edit.cpp58
-rw-r--r--scene/gui/text_edit.h5
-rw-r--r--scene/gui/tree.cpp10
-rw-r--r--tools/editor/editor_settings.cpp2
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.cpp3
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp3
-rw-r--r--tools/editor/plugins/style_box_editor_plugin.cpp1
-rw-r--r--tools/editor/plugins/theme_editor_plugin.cpp6
8 files changed, 84 insertions, 4 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index b80597560d..0fc8e39fef 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -643,6 +643,9 @@ void TextEdit::_notification(int p_what) {
int deregion=0; //force it to clear inrgion
Point2 cursor_pos;
+ // get the highlighted words
+ String highlighted_text = get_selection_text();
+
for (int i=0;i<visible_rows;i++) {
int line=i+cursor.line_ofs;
@@ -659,6 +662,12 @@ void TextEdit::_notification(int p_what) {
bool in_keyword=false;
Color keyword_color;
+ // check if line contains highlighted word
+ int highlighted_text_col = -1;
+ if (highlighted_text.length() != 0) {
+ highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, 0);
+ }
+
if (cache.line_number_w) {
Color fcol = cache.font_color;
fcol.a*=0.4;
@@ -798,6 +807,20 @@ void TextEdit::_notification(int p_what) {
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin, ofs_y ), Size2i(char_w,get_row_height())),cache.selection_color);
}
+ if (highlight_all_occurrences) {
+ if (highlighted_text_col != -1) {
+
+ // if we are at the end check for new word on same line
+ if (j > highlighted_text_col+highlighted_text.length()) {
+ highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, j);
+ }
+
+ bool in_highlighted_word = (j >= highlighted_text_col && j < highlighted_text_col+highlighted_text.length());
+ if (in_highlighted_word) {
+ VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin, ofs_y ), Size2i(char_w, get_row_height())),cache.word_highlighted_color);
+ }
+ }
+ }
if (brace_matching_enabled) {
if ( (brace_open_match_line==line && brace_open_match_column==j) ||
@@ -2921,6 +2944,7 @@ void TextEdit::_update_caches() {
cache.current_line_color=get_color("current_line_color");
cache.breakpoint_color=get_color("breakpoint_color");
cache.brace_mismatch_color=get_color("brace_mismatch_color");
+ cache.word_highlighted_color=get_color("word_highlighted_color");
cache.line_spacing=get_constant("line_spacing");
cache.row_height = cache.font->get_height() + cache.line_spacing;
cache.tab_icon=get_icon("tab");
@@ -3182,6 +3206,40 @@ String TextEdit::get_word_under_cursor() const {
return text[cursor.line].substr(prev_cc, next_cc-prev_cc);
}
+void TextEdit::set_highlight_all_occurrences(const bool p_enabled) {
+ highlight_all_occurrences = p_enabled;
+ update();
+}
+
+int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_search, int p_from_column) {
+ int col = -1;
+
+ if (p_key.length() > 0 && p_search.length() > 0) {
+ if (p_from_column < 0 || p_from_column > p_search.length()) {
+ p_from_column = 0;
+ }
+
+ while (col == -1 && p_from_column <= p_search.length()) {
+ // match case
+ col = p_search.findn(p_key, p_from_column);
+
+ // whole words only
+ if (col != -1) {
+ p_from_column=col;
+
+ if (col > 0 && _is_text_char(p_search[col-1])) {
+ col = -1;
+ } else if (_is_text_char(p_search[col+p_key.length()])) {
+ col = -1;
+ }
+ }
+
+ p_from_column+=1;
+ }
+ }
+ return col;
+}
+
DVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const {
int col,line;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index d38c57804d..86696ca5a5 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -81,6 +81,7 @@ class TextEdit : public Control {
Color breakpoint_color;
Color current_line_color;
Color brace_mismatch_color;
+ Color word_highlighted_color;
int row_height;
int line_spacing;
@@ -212,6 +213,7 @@ class TextEdit : public Control {
bool undo_enabled;
bool line_numbers;
+ bool highlight_all_occurrences;
bool scroll_past_end_of_file_enabled;
bool auto_brace_completion_enabled;
bool brace_matching_enabled;
@@ -270,6 +272,8 @@ class TextEdit : public Control {
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);
+ int _get_column_pos_of_word(const String &p_key, const String &p_search, int p_from_column);
+
DVector<int> _search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const;
void _clear();
@@ -364,6 +368,7 @@ public:
void select(int p_from_line,int p_from_column,int p_to_line,int p_to_column);
void deselect();
+ void set_highlight_all_occurrences(const bool p_enabled);
bool is_selection_active() const;
int get_selection_from_line() const;
int get_selection_from_column() const;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 483aa47f35..718206dee1 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2750,6 +2750,15 @@ void Tree::clear() {
ERR_FAIL_COND(blocked>0);
}
+ if (pressing_for_editor) {
+ if (range_drag_enabled) {
+ range_drag_enabled = false;
+ Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+ warp_mouse(range_drag_capture_pos);
+ }
+ pressing_for_editor = false;
+ }
+
if (root) {
memdelete( root );
root = NULL;
@@ -2759,7 +2768,6 @@ void Tree::clear() {
edited_item=NULL;
popup_edited_item=NULL;
selected_item=NULL;
- pressing_for_editor=false;
update();
};
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 1133acb48c..6baa690644 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -403,7 +403,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/selection_color",Color::html("7b5dbe"));
set("text_editor/brace_mismatch_color",Color(1,0.2,0.2));
set("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15));
+ set("text_editor/word_highlighted_color",Color(0.8,0.9,0.9,0.15));
+ set("text_editor/highlight_all_occurrences", true);
set("text_editor/scroll_past_end_of_file", false);
set("text_editor/tab_size", 4);
diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp
index 0b06aab447..67f730f300 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_player_editor_plugin.cpp
@@ -1500,7 +1500,8 @@ bool AnimationPlayerEditorPlugin::handles(Object *p_object) const {
void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- anim_editor->show();
+
+ editor->make_bottom_panel_item_visible(anim_editor);
anim_editor->set_process(true);
anim_editor->ensure_visibility();
// editor->animation_panel_make_visible(true);
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 03db293959..b383c75253 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -292,6 +292,7 @@ void ScriptTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1)));
get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2)));
get_text_edit()->add_color_override("current_line_color",EDITOR_DEF("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15)));
+ get_text_edit()->add_color_override("word_highlighted_color",EDITOR_DEF("text_editor/word_highlighted_color",Color(0.8,0.9,0.9,0.15)));
Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2));
@@ -1931,6 +1932,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
ste->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
+ ste->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
ste->get_text_edit()->set_callhint_settings(
EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"),
EditorSettings::get_singleton()->get("text_editor/callhint_tooltip_offset"));
@@ -2069,6 +2071,7 @@ void ScriptEditor::_editor_settings_changed() {
ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
ste->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
+ ste->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
}
}
diff --git a/tools/editor/plugins/style_box_editor_plugin.cpp b/tools/editor/plugins/style_box_editor_plugin.cpp
index 3d7cf4135d..f08d2a7376 100644
--- a/tools/editor/plugins/style_box_editor_plugin.cpp
+++ b/tools/editor/plugins/style_box_editor_plugin.cpp
@@ -92,6 +92,7 @@ void StyleBoxEditorPlugin::make_visible(bool p_visible){
if (p_visible) {
button->show();
+ EditorNode::get_singleton()->make_bottom_panel_item_visible(stylebox_editor);
} else {
if (stylebox_editor->is_visible())
diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp
index ef7b3b17c3..938b8344ba 100644
--- a/tools/editor/plugins/theme_editor_plugin.cpp
+++ b/tools/editor/plugins/theme_editor_plugin.cpp
@@ -833,10 +833,12 @@ void ThemeEditorPlugin::make_visible(bool p_visible){
if (p_visible) {
theme_editor->set_process(true);
button->show();
+ editor->make_bottom_panel_item_visible(theme_editor);
+
} else {
theme_editor->set_process(false);
if (theme_editor->is_visible())
- EditorNode::get_singleton()->hide_bottom_panel();
+ editor->hide_bottom_panel();
button->hide();
}
}
@@ -848,7 +850,7 @@ ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) {
theme_editor->set_custom_minimum_size(Size2(0,500));
// p_node->get_viewport()->add_child(theme_editor);
- button=EditorNode::get_singleton()->add_bottom_panel_item("Theme",theme_editor);
+ button=editor->add_bottom_panel_item("Theme",theme_editor);
button->hide();