Add shortcut for quick-toggling word wrap
This commit is contained in:
parent
27253f3eb2
commit
ff310f0969
6 changed files with 19 additions and 0 deletions
|
@ -1323,6 +1323,10 @@ void ScriptTextEditor::_edit_option(int p_op) {
|
||||||
}
|
}
|
||||||
tx->end_complex_operation();
|
tx->end_complex_operation();
|
||||||
} break;
|
} break;
|
||||||
|
case EDIT_TOGGLE_WORD_WRAP: {
|
||||||
|
TextEdit::LineWrappingMode wrap = code_editor->get_text_editor()->get_line_wrapping_mode();
|
||||||
|
code_editor->get_text_editor()->set_line_wrapping_mode(wrap == TextEdit::LINE_WRAPPING_BOUNDARY ? TextEdit::LINE_WRAPPING_NONE : TextEdit::LINE_WRAPPING_BOUNDARY);
|
||||||
|
} break;
|
||||||
case SEARCH_FIND: {
|
case SEARCH_FIND: {
|
||||||
code_editor->get_find_replace_bar()->popup_search();
|
code_editor->get_find_replace_bar()->popup_search();
|
||||||
} break;
|
} break;
|
||||||
|
@ -2064,6 +2068,7 @@ void ScriptTextEditor::_enable_code_editor() {
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_text_select_all"), EDIT_SELECT_ALL);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_text_select_all"), EDIT_SELECT_ALL);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_selection"), EDIT_DUPLICATE_SELECTION);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_selection"), EDIT_DUPLICATE_SELECTION);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/evaluate_selection"), EDIT_EVALUATE);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/evaluate_selection"), EDIT_EVALUATE);
|
||||||
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_word_wrap"), EDIT_TOGGLE_WORD_WRAP);
|
||||||
edit_menu->get_popup()->add_separator();
|
edit_menu->get_popup()->add_separator();
|
||||||
{
|
{
|
||||||
PopupMenu *sub_menu = memnew(PopupMenu);
|
PopupMenu *sub_menu = memnew(PopupMenu);
|
||||||
|
@ -2283,6 +2288,7 @@ void ScriptTextEditor::register_editor() {
|
||||||
ED_SHORTCUT("script_text_editor/duplicate_selection", TTR("Duplicate Selection"), KeyModifierMask::SHIFT | KeyModifierMask::CTRL | Key::D);
|
ED_SHORTCUT("script_text_editor/duplicate_selection", TTR("Duplicate Selection"), KeyModifierMask::SHIFT | KeyModifierMask::CTRL | Key::D);
|
||||||
ED_SHORTCUT_OVERRIDE("script_text_editor/duplicate_selection", "macos", KeyModifierMask::SHIFT | KeyModifierMask::META | Key::C);
|
ED_SHORTCUT_OVERRIDE("script_text_editor/duplicate_selection", "macos", KeyModifierMask::SHIFT | KeyModifierMask::META | Key::C);
|
||||||
ED_SHORTCUT("script_text_editor/evaluate_selection", TTR("Evaluate Selection"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::E);
|
ED_SHORTCUT("script_text_editor/evaluate_selection", TTR("Evaluate Selection"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::E);
|
||||||
|
ED_SHORTCUT("script_text_editor/toggle_word_wrap", TTR("Toggle Word Wrap"), KeyModifierMask::ALT | Key::Z);
|
||||||
ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT | Key::T);
|
ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT | Key::T);
|
||||||
ED_SHORTCUT("script_text_editor/convert_indent_to_spaces", TTR("Convert Indent to Spaces"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::Y);
|
ED_SHORTCUT("script_text_editor/convert_indent_to_spaces", TTR("Convert Indent to Spaces"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::Y);
|
||||||
ED_SHORTCUT("script_text_editor/convert_indent_to_tabs", TTR("Convert Indent to Tabs"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::I);
|
ED_SHORTCUT("script_text_editor/convert_indent_to_tabs", TTR("Convert Indent to Tabs"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::I);
|
||||||
|
|
|
@ -129,6 +129,7 @@ class ScriptTextEditor : public ScriptEditorBase {
|
||||||
EDIT_TO_LOWERCASE,
|
EDIT_TO_LOWERCASE,
|
||||||
EDIT_CAPITALIZE,
|
EDIT_CAPITALIZE,
|
||||||
EDIT_EVALUATE,
|
EDIT_EVALUATE,
|
||||||
|
EDIT_TOGGLE_WORD_WRAP,
|
||||||
EDIT_TOGGLE_FOLD_LINE,
|
EDIT_TOGGLE_FOLD_LINE,
|
||||||
EDIT_FOLD_ALL_LINES,
|
EDIT_FOLD_ALL_LINES,
|
||||||
EDIT_UNFOLD_ALL_LINES,
|
EDIT_UNFOLD_ALL_LINES,
|
||||||
|
|
|
@ -433,6 +433,10 @@ void TextEditor::_edit_option(int p_op) {
|
||||||
case EDIT_CAPITALIZE: {
|
case EDIT_CAPITALIZE: {
|
||||||
_convert_case(CodeTextEditor::CAPITALIZE);
|
_convert_case(CodeTextEditor::CAPITALIZE);
|
||||||
} break;
|
} break;
|
||||||
|
case EDIT_TOGGLE_WORD_WRAP: {
|
||||||
|
TextEdit::LineWrappingMode wrap = code_editor->get_text_editor()->get_line_wrapping_mode();
|
||||||
|
code_editor->get_text_editor()->set_line_wrapping_mode(wrap == TextEdit::LINE_WRAPPING_BOUNDARY ? TextEdit::LINE_WRAPPING_NONE : TextEdit::LINE_WRAPPING_BOUNDARY);
|
||||||
|
} break;
|
||||||
case SEARCH_FIND: {
|
case SEARCH_FIND: {
|
||||||
code_editor->get_find_replace_bar()->popup_search();
|
code_editor->get_find_replace_bar()->popup_search();
|
||||||
} break;
|
} break;
|
||||||
|
@ -649,6 +653,7 @@ TextEditor::TextEditor() {
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_all_lines"), EDIT_UNFOLD_ALL_LINES);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_all_lines"), EDIT_UNFOLD_ALL_LINES);
|
||||||
edit_menu->get_popup()->add_separator();
|
edit_menu->get_popup()->add_separator();
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_selection"), EDIT_DUPLICATE_SELECTION);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_selection"), EDIT_DUPLICATE_SELECTION);
|
||||||
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_word_wrap"), EDIT_TOGGLE_WORD_WRAP);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS);
|
||||||
|
|
|
@ -72,6 +72,7 @@ private:
|
||||||
EDIT_TO_UPPERCASE,
|
EDIT_TO_UPPERCASE,
|
||||||
EDIT_TO_LOWERCASE,
|
EDIT_TO_LOWERCASE,
|
||||||
EDIT_CAPITALIZE,
|
EDIT_CAPITALIZE,
|
||||||
|
EDIT_TOGGLE_WORD_WRAP,
|
||||||
EDIT_TOGGLE_FOLD_LINE,
|
EDIT_TOGGLE_FOLD_LINE,
|
||||||
EDIT_FOLD_ALL_LINES,
|
EDIT_FOLD_ALL_LINES,
|
||||||
EDIT_UNFOLD_ALL_LINES,
|
EDIT_UNFOLD_ALL_LINES,
|
||||||
|
|
|
@ -663,6 +663,10 @@ void TextShaderEditor::_menu_option(int p_option) {
|
||||||
case EDIT_DUPLICATE_SELECTION: {
|
case EDIT_DUPLICATE_SELECTION: {
|
||||||
shader_editor->duplicate_selection();
|
shader_editor->duplicate_selection();
|
||||||
} break;
|
} break;
|
||||||
|
case EDIT_TOGGLE_WORD_WRAP: {
|
||||||
|
TextEdit::LineWrappingMode wrap = shader_editor->get_text_editor()->get_line_wrapping_mode();
|
||||||
|
shader_editor->get_text_editor()->set_line_wrapping_mode(wrap == TextEdit::LINE_WRAPPING_BOUNDARY ? TextEdit::LINE_WRAPPING_NONE : TextEdit::LINE_WRAPPING_BOUNDARY);
|
||||||
|
} break;
|
||||||
case EDIT_TOGGLE_COMMENT: {
|
case EDIT_TOGGLE_COMMENT: {
|
||||||
if (shader.is_null()) {
|
if (shader.is_null()) {
|
||||||
return;
|
return;
|
||||||
|
@ -1117,6 +1121,7 @@ TextShaderEditor::TextShaderEditor() {
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/delete_line"), EDIT_DELETE_LINE);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/delete_line"), EDIT_DELETE_LINE);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_selection"), EDIT_DUPLICATE_SELECTION);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_selection"), EDIT_DUPLICATE_SELECTION);
|
||||||
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_word_wrap"), EDIT_TOGGLE_WORD_WRAP);
|
||||||
edit_menu->get_popup()->add_separator();
|
edit_menu->get_popup()->add_separator();
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_text_completion_query"), EDIT_COMPLETE);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_text_completion_query"), EDIT_COMPLETE);
|
||||||
edit_menu->get_popup()->connect("id_pressed", callable_mp(this, &TextShaderEditor::_menu_option));
|
edit_menu->get_popup()->connect("id_pressed", callable_mp(this, &TextShaderEditor::_menu_option));
|
||||||
|
|
|
@ -120,6 +120,7 @@ class TextShaderEditor : public MarginContainer {
|
||||||
EDIT_UNINDENT,
|
EDIT_UNINDENT,
|
||||||
EDIT_DELETE_LINE,
|
EDIT_DELETE_LINE,
|
||||||
EDIT_DUPLICATE_SELECTION,
|
EDIT_DUPLICATE_SELECTION,
|
||||||
|
EDIT_TOGGLE_WORD_WRAP,
|
||||||
EDIT_TOGGLE_COMMENT,
|
EDIT_TOGGLE_COMMENT,
|
||||||
EDIT_COMPLETE,
|
EDIT_COMPLETE,
|
||||||
SEARCH_FIND,
|
SEARCH_FIND,
|
||||||
|
|
Loading…
Reference in a new issue