summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_settings.cpp2
-rw-r--r--editor/plugins/line_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_text_editor.cpp65
-rw-r--r--editor/plugins/script_text_editor.h10
4 files changed, 77 insertions, 2 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 9beffa3c67..f1b7667a50 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -595,6 +595,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("editors/2d/keep_margins_when_changing_anchors", false);
set("editors/2d/warped_mouse_panning", true);
+ set("editors/poly_editor/point_grab_radius", 8);
+
set("run/window_placement/rect", 0);
hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Default,Centered,Custom Position,Force Maximized,Force Full Screen");
String screen_hints = TTR("Default (Same as Editor)");
diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp
index 69e329eb1a..4df0d2605a 100644
--- a/editor/plugins/line_2d_editor_plugin.cpp
+++ b/editor/plugins/line_2d_editor_plugin.cpp
@@ -62,7 +62,7 @@ Vector2 Line2DEditor::mouse_to_local_pos(Vector2 gpoint, bool alt) {
int Line2DEditor::get_point_index_at(Vector2 gpos) {
ERR_FAIL_COND_V(node == 0, -1);
- real_t grab_treshold = EDITOR_DEF("poly_editor/point_grab_radius", 8);
+ real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
for (int i = 0; i < node->get_point_count(); ++i) {
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index e942d6cebd..84aa4739ea 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -240,6 +240,48 @@ Variant ScriptTextEditor::get_edit_state() {
return state;
}
+void ScriptTextEditor::_convert_case(CaseStyle p_case) {
+ TextEdit *te = code_editor->get_text_edit();
+ Ref<Script> scr = get_edited_script();
+ if (scr.is_null()) {
+ return;
+ }
+
+ if (te->is_selection_active()) {
+ te->begin_complex_operation();
+
+ int begin = te->get_selection_from_line();
+ int end = te->get_selection_to_line();
+ int begin_col = te->get_selection_from_column();
+ int end_col = te->get_selection_to_column();
+
+ for (int i = begin; i <= end; i++) {
+ String new_line = te->get_line(i);
+
+ switch (p_case) {
+ case UPPER: {
+ new_line = new_line.to_upper();
+ } break;
+ case LOWER: {
+ new_line = new_line.to_lower();
+ } break;
+ case CAPITALIZE: {
+ new_line = new_line.capitalize();
+ } break;
+ }
+
+ if (i == begin) {
+ new_line = te->get_line(i).left(begin_col) + new_line.right(begin_col);
+ }
+ if (i == end) {
+ new_line = new_line.left(end_col) + te->get_line(i).right(end_col);
+ }
+ te->set_line(i, new_line);
+ }
+ te->end_complex_operation();
+ }
+}
+
void ScriptTextEditor::trim_trailing_whitespace() {
TextEdit *tx = code_editor->get_text_edit();
@@ -919,7 +961,15 @@ void ScriptTextEditor::_edit_option(int p_op) {
case EDIT_PICK_COLOR: {
color_panel->popup();
} break;
-
+ case EDIT_TO_UPPERCASE: {
+ _convert_case(UPPER);
+ } break;
+ case EDIT_TO_LOWERCASE: {
+ _convert_case(LOWER);
+ } break;
+ case EDIT_CAPITALIZE: {
+ _convert_case(CAPITALIZE);
+ } break;
case SEARCH_FIND: {
code_editor->get_find_replace_bar()->popup_search();
@@ -1335,6 +1385,15 @@ ScriptTextEditor::ScriptTextEditor() {
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_breakpoints"), DEBUG_REMOVE_ALL_BREAKPOINTS);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_breakpoint"), DEBUG_GOTO_NEXT_BREAKPOINT);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_breakpoint"), DEBUG_GOTO_PREV_BREAKPOINT);
+ edit_menu->get_popup()->add_separator();
+ PopupMenu *convert_case = memnew(PopupMenu);
+ convert_case->set_name("convert_case");
+ edit_menu->get_popup()->add_child(convert_case);
+ edit_menu->get_popup()->add_submenu_item(TTR("Convert Case"), "convert_case");
+ convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase")), EDIT_TO_UPPERCASE);
+ convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase")), EDIT_TO_LOWERCASE);
+ convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE);
+ convert_case->connect("id_pressed", this, "_edit_option");
search_menu = memnew(MenuButton);
edit_hb->add_child(search_menu);
@@ -1405,6 +1464,10 @@ void ScriptTextEditor::register_editor() {
ED_SHORTCUT("script_text_editor/goto_next_breakpoint", TTR("Goto Next Breakpoint"), KEY_MASK_CTRL | KEY_PERIOD);
ED_SHORTCUT("script_text_editor/goto_previous_breakpoint", TTR("Goto Previous Breakpoint"), KEY_MASK_CTRL | KEY_COMMA);
+ ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Convert To Uppercase"), KEY_MASK_SHIFT | KEY_F4);
+ ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Convert To Lowercase"), KEY_MASK_SHIFT | KEY_F3);
+ ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize"), KEY_MASK_SHIFT | KEY_F2);
+
ED_SHORTCUT("script_text_editor/find", TTR("Find.."), KEY_MASK_CMD | KEY_F);
ED_SHORTCUT("script_text_editor/find_next", TTR("Find Next"), KEY_F3);
ED_SHORTCUT("script_text_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3);
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 8e089e1ebf..77bce59f2e 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -76,6 +76,9 @@ class ScriptTextEditor : public ScriptEditorBase {
EDIT_INDENT_LEFT,
EDIT_CLONE_DOWN,
EDIT_PICK_COLOR,
+ EDIT_TO_UPPERCASE,
+ EDIT_TO_LOWERCASE,
+ EDIT_CAPITALIZE,
SEARCH_FIND,
SEARCH_FIND_NEXT,
SEARCH_FIND_PREV,
@@ -109,6 +112,13 @@ protected:
void _goto_line(int p_line) { goto_line(p_line); }
void _lookup_symbol(const String &p_symbol, int p_row, int p_column);
+ enum CaseStyle {
+ UPPER,
+ LOWER,
+ CAPITALIZE,
+ };
+ void _convert_case(CaseStyle p_case);
+
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);