mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Add 'uppercase' and 'lowercase' to script editor
This commit is contained in:
parent
1cf15bb847
commit
bcfe3dcd35
4 changed files with 52 additions and 3 deletions
|
|
@ -3370,6 +3370,21 @@ void TextEdit::cut() {
|
|||
}
|
||||
}
|
||||
|
||||
void TextEdit::convert_case(int p_case) {
|
||||
if (selection.active) {
|
||||
String text = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
|
||||
selection.active = false;
|
||||
_remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
|
||||
cursor_set_line(selection.from_line);
|
||||
cursor_set_column(selection.from_column);
|
||||
if (p_case == UPPERCASE) {
|
||||
_insert_text_at_cursor(text.to_upper());
|
||||
} else if (p_case == LOWERCASE) {
|
||||
_insert_text_at_cursor(text.to_lower());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextEdit::copy() {
|
||||
|
||||
if (!selection.active) {
|
||||
|
|
@ -4312,6 +4327,16 @@ void TextEdit::menu_option(int p_option) {
|
|||
clear();
|
||||
}
|
||||
} break;
|
||||
case MENU_UPPERCASE: {
|
||||
if (!readonly) {
|
||||
convert_case(UPPERCASE);
|
||||
}
|
||||
} break;
|
||||
case MENU_LOWERCASE: {
|
||||
if (!readonly) {
|
||||
convert_case(LOWERCASE);
|
||||
}
|
||||
} break;
|
||||
case MENU_SELECT_ALL: {
|
||||
select_all();
|
||||
} break;
|
||||
|
|
@ -4372,6 +4397,7 @@ void TextEdit::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("paste"), &TextEdit::paste);
|
||||
ObjectTypeDB::bind_method(_MD("select_all"), &TextEdit::select_all);
|
||||
ObjectTypeDB::bind_method(_MD("select", "from_line", "from_column", "to_line", "to_column"), &TextEdit::select);
|
||||
ObjectTypeDB::bind_method(_MD("convert_case", "case"), &TextEdit::convert_case);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("is_selection_active"), &TextEdit::is_selection_active);
|
||||
ObjectTypeDB::bind_method(_MD("get_selection_from_line"), &TextEdit::get_selection_from_line);
|
||||
|
|
@ -4548,6 +4574,9 @@ TextEdit::TextEdit() {
|
|||
menu->add_item(TTR("Select All"), MENU_SELECT_ALL, KEY_MASK_CMD | KEY_A);
|
||||
menu->add_item(TTR("Clear"), MENU_CLEAR);
|
||||
menu->add_separator();
|
||||
menu->add_item(TTR("UpperCase"), MENU_UPPERCASE);
|
||||
menu->add_item(TTR("LowerCase"), MENU_LOWERCASE);
|
||||
menu->add_separator();
|
||||
menu->add_item(TTR("Undo"), MENU_UNDO, KEY_MASK_CMD | KEY_Z);
|
||||
menu->connect("item_pressed", this, "menu_option");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -346,12 +346,16 @@ public:
|
|||
MENU_COPY,
|
||||
MENU_PASTE,
|
||||
MENU_CLEAR,
|
||||
MENU_UPPERCASE,
|
||||
MENU_LOWERCASE,
|
||||
MENU_SELECT_ALL,
|
||||
MENU_UNDO,
|
||||
MENU_MAX
|
||||
|
||||
};
|
||||
|
||||
enum Case {
|
||||
UPPERCASE,
|
||||
LOWERCASE
|
||||
};
|
||||
enum SearchFlags {
|
||||
|
||||
SEARCH_MATCH_CASE = 1,
|
||||
|
|
@ -428,6 +432,7 @@ public:
|
|||
bool is_syntax_coloring_enabled() const;
|
||||
|
||||
void cut();
|
||||
void convert_case(int p_case);
|
||||
void copy();
|
||||
void paste();
|
||||
void select_all();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue