diff --git a/bin/assets/plugins/formatters.json b/bin/assets/plugins/formatters.json index ecced69f4..98470ce85 100644 --- a/bin/assets/plugins/formatters.json +++ b/bin/assets/plugins/formatters.json @@ -2,9 +2,6 @@ "config": { "auto_format_on_save": false }, - "keybindings": { - "format-doc": "alt+f" - }, "formatters": [ { "language": ["javascript", "typescript", "jsx", "tsx", "html"], diff --git a/include/eepp/scene/keyevent.hpp b/include/eepp/scene/keyevent.hpp index bde81c471..cbdff3892 100644 --- a/include/eepp/scene/keyevent.hpp +++ b/include/eepp/scene/keyevent.hpp @@ -7,6 +7,10 @@ using namespace EE::Window; +namespace EE::Window { +class Input; +} + namespace EE { namespace Scene { class EE_API KeyEvent : public Event { @@ -38,6 +42,10 @@ class EE_API KeyEvent : public Event { class EE_API TextInputEvent : public Event { public: + /* This verification checks if the user is not pressing any key modifier that should invalidate + * the text input event. */ + static bool isValidTextInputEvent( Input* input, const TextInputEvent& event ); + TextInputEvent( Node* node, const Uint32& eventNum, const Uint32& chr, const Uint32& timestamp ); @@ -47,6 +55,9 @@ class EE_API TextInputEvent : public Event { String getText() const; + /* @see isValidTextInputEvent */ + bool isValid( Input* input ) const; + protected: String::StringBaseType mChar; Uint32 mTimestamp; diff --git a/include/eepp/ui/tools/uicodeeditorsplitter.hpp b/include/eepp/ui/tools/uicodeeditorsplitter.hpp index 0db1ef5ca..2ce6c9d83 100644 --- a/include/eepp/ui/tools/uicodeeditorsplitter.hpp +++ b/include/eepp/ui/tools/uicodeeditorsplitter.hpp @@ -20,6 +20,8 @@ class EE_API UICodeEditorSplitter { static const std::map getLocalDefaultKeybindings(); + static Uint32 getDefaultSwitchToTabModifier(); + class EE_API Client { public: virtual ~Client() {}; diff --git a/src/eepp/scene/keyevent.cpp b/src/eepp/scene/keyevent.cpp index 6647eb9f5..c7e2f43b3 100644 --- a/src/eepp/scene/keyevent.cpp +++ b/src/eepp/scene/keyevent.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace EE { namespace Scene { @@ -40,6 +41,32 @@ Uint32 KeyEvent::getSanitizedMod() const { return mMod & KEYMOD_CTRL_SHIFT_ALT_META; } +bool TextInputEvent::isValidTextInputEvent( Input* input, const TextInputEvent& event ) { + // Meta/Command key shortcuts do not generate text + if ( input->isMetaPressed() ) + return false; + + // Ctrl shortcuts (without Alt/AltGr) do not generate text + if ( input->isLeftControlPressed() && !input->isLeftAltPressed() && !input->isAltGrPressed() ) + return false; + + // Alt+Tab should not insert a tab character + if ( input->isLeftAltPressed() && !event.getText().empty() && event.getText()[0] == '\t' ) + return false; + +#if EE_PLATFORM != EE_PLATFORM_MACOS + // On non-macOS platforms, Alt key combinations (without Ctrl) do not generate text + if ( input->isLeftAltPressed() && !input->isLeftControlPressed() ) + return false; +#endif + + return true; +} + +bool TextInputEvent::isValid( Input* input ) const { + return isValidTextInputEvent( input, *this ); +} + TextInputEvent::TextInputEvent( Node* node, const Uint32& eventNum, const Uint32& chr, const Uint32& timestamp ) : Event( node, eventNum ), mChar( chr ), mTimestamp( timestamp ) {} diff --git a/src/eepp/ui/tools/uicodeeditorsplitter.cpp b/src/eepp/ui/tools/uicodeeditorsplitter.cpp index 9b6ad9280..fe4a46ddb 100644 --- a/src/eepp/ui/tools/uicodeeditorsplitter.cpp +++ b/src/eepp/ui/tools/uicodeeditorsplitter.cpp @@ -18,14 +18,24 @@ const std::map UICodeEditorSplitter::getDefa return localKeybindings; } +#if EE_PLATFORM == EE_PLATFORM_MACOS +static Uint32 DefaultSwitchToTabModifier = KEYMOD_CTRL; +#else +static Uint32 DefaultSwitchToTabModifier = KeyMod::getDefaultModifier(); +#endif + +Uint32 UICodeEditorSplitter::getDefaultSwitchToTabModifier() { + return DefaultSwitchToTabModifier; +} + const std::map UICodeEditorSplitter::getLocalDefaultKeybindings() { return { { { KEY_S, KeyMod::getDefaultModifier() }, "save-doc" }, { { KEY_T, KeyMod::getDefaultModifier() }, "create-new" }, { { KEY_W, KeyMod::getDefaultModifier() }, "close-tab" }, - { { KEY_TAB, KeyMod::getDefaultModifier() }, "next-tab" }, - { { KEY_TAB, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "previous-tab" }, + { { KEY_TAB, DefaultSwitchToTabModifier }, "next-tab" }, + { { KEY_TAB, DefaultSwitchToTabModifier | KEYMOD_SHIFT }, "previous-tab" }, { { KEY_J, KEYMOD_LALT | KEYMOD_SHIFT }, "split-left" }, { { KEY_L, KEYMOD_LALT | KEYMOD_SHIFT }, "split-right" }, { { KEY_I, KEYMOD_LALT | KEYMOD_SHIFT }, "split-top" }, @@ -35,16 +45,16 @@ UICodeEditorSplitter::getLocalDefaultKeybindings() { { { KEY_L, KeyMod::getDefaultModifier() | KEYMOD_LALT }, "switch-to-next-split" }, { { KEY_N, KeyMod::getDefaultModifier() | KEYMOD_LALT }, "switch-to-previous-colorscheme" }, { { KEY_M, KeyMod::getDefaultModifier() | KEYMOD_LALT }, "switch-to-next-colorscheme" }, - { { KEY_1, KeyMod::getDefaultModifier() }, "switch-to-tab-1" }, - { { KEY_2, KeyMod::getDefaultModifier() }, "switch-to-tab-2" }, - { { KEY_3, KeyMod::getDefaultModifier() }, "switch-to-tab-3" }, - { { KEY_4, KeyMod::getDefaultModifier() }, "switch-to-tab-4" }, - { { KEY_5, KeyMod::getDefaultModifier() }, "switch-to-tab-5" }, - { { KEY_6, KeyMod::getDefaultModifier() }, "switch-to-tab-6" }, - { { KEY_7, KeyMod::getDefaultModifier() }, "switch-to-tab-7" }, - { { KEY_8, KeyMod::getDefaultModifier() }, "switch-to-tab-8" }, - { { KEY_9, KeyMod::getDefaultModifier() }, "switch-to-tab-9" }, - { { KEY_0, KeyMod::getDefaultModifier() }, "switch-to-last-tab" }, + { { KEY_1, DefaultSwitchToTabModifier }, "switch-to-tab-1" }, + { { KEY_2, DefaultSwitchToTabModifier }, "switch-to-tab-2" }, + { { KEY_3, DefaultSwitchToTabModifier }, "switch-to-tab-3" }, + { { KEY_4, DefaultSwitchToTabModifier }, "switch-to-tab-4" }, + { { KEY_5, DefaultSwitchToTabModifier }, "switch-to-tab-5" }, + { { KEY_6, DefaultSwitchToTabModifier }, "switch-to-tab-6" }, + { { KEY_7, DefaultSwitchToTabModifier }, "switch-to-tab-7" }, + { { KEY_8, DefaultSwitchToTabModifier }, "switch-to-tab-8" }, + { { KEY_9, DefaultSwitchToTabModifier }, "switch-to-tab-9" }, + { { KEY_0, DefaultSwitchToTabModifier }, "switch-to-last-tab" }, { { KEY_LEFT, KEYMOD_LALT }, "editor-go-back" }, { { KEY_RIGHT, KEYMOD_LALT }, "editor-go-forward" }, }; diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 0c3b17734..ba7a4e6bc 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -1118,10 +1118,7 @@ Uint32 UICodeEditor::onTextInput( const TextInputEvent& event ) { return 0; Input* input = getInput(); - if ( ( input->isLeftAltPressed() && !event.getText().empty() && event.getText()[0] == '\t' ) || - ( input->isLeftControlPressed() && !input->isLeftAltPressed() && - !input->isAltGrPressed() ) || - input->isMetaPressed() || ( input->isLeftAltPressed() && !input->isLeftControlPressed() ) ) + if ( !event.isValid( input ) ) return 0; if ( mLastExecuteEventId == getInput()->getEventsSentId() && diff --git a/src/eepp/ui/uiconsole.cpp b/src/eepp/ui/uiconsole.cpp index 341e9cc2d..7a7cb91bb 100644 --- a/src/eepp/ui/uiconsole.cpp +++ b/src/eepp/ui/uiconsole.cpp @@ -950,10 +950,7 @@ Uint32 UIConsole::onKeyDown( const KeyEvent& event ) { Uint32 UIConsole::onTextInput( const TextInputEvent& event ) { Input* input = getInput(); - if ( ( input->isLeftAltPressed() && !event.getText().empty() && event.getText()[0] == '\t' ) || - ( input->isLeftControlPressed() && !input->isLeftAltPressed() && - !input->isAltGrPressed() ) || - input->isMetaPressed() || ( input->isLeftAltPressed() && !input->isLeftControlPressed() ) ) + if ( !event.isValid( input ) ) return 0; if ( mLastExecuteEventId == getInput()->getEventsSentId() && diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index 721ee42a1..bb44c2edd 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -898,10 +898,7 @@ Uint32 UITextInput::onTextInput( const TextInputEvent& event ) { return 0; Input* input = getInput(); - if ( ( input->isLeftAltPressed() && !event.getText().empty() && event.getText()[0] == '\t' ) || - ( input->isLeftControlPressed() && !input->isLeftAltPressed() && - !input->isAltGrPressed() ) || - input->isMetaPressed() || ( input->isLeftAltPressed() && !input->isLeftControlPressed() ) ) + if ( !event.isValid( input ) ) return 0; if ( mLastExecuteEventId == getInput()->getEventsSentId() && diff --git a/src/modules/eterm/src/eterm/ui/uiterminal.cpp b/src/modules/eterm/src/eterm/ui/uiterminal.cpp index afa39972c..b44cdbd30 100644 --- a/src/modules/eterm/src/eterm/ui/uiterminal.cpp +++ b/src/modules/eterm/src/eterm/ui/uiterminal.cpp @@ -435,10 +435,7 @@ bool UITerminal::isUsingCustomTitle() const { Uint32 UITerminal::onTextInput( const TextInputEvent& event ) { Input* input = getInput(); - if ( ( input->isLeftAltPressed() && !event.getText().empty() && event.getText()[0] == '\t' ) || - ( input->isLeftControlPressed() && !input->isLeftAltPressed() && - !input->isAltGrPressed() ) || - input->isMetaPressed() || ( input->isLeftAltPressed() && !input->isLeftControlPressed() ) ) + if ( !event.isValid( input ) ) return 0; mTerm->onTextInput( event.getChar() ); diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 78d9809cd..c9c2355ba 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -1993,16 +1993,6 @@ void App::setTheme( const std::string& path ) { } theme->getStyleSheet().addKeyframes( parser.getStyleSheet().getKeyframes() ); } - - /* auto inheritsEditorColors = style->getVariableByName( "--inherit-editor-colors" ); - if ( !inheritsEditorColors.isEmpty() ) { - const SyntaxColorScheme* colorScheme = getCurrentColorScheme(); - std::string themeString( - ColorSchemeTranslator::fromSyntaxColorScheme( *colorScheme ) ); - StyleSheetParser parser; - if ( parser.loadFromString( themeString ) ) - theme->getStyleSheet().combineStyleSheet( parser.getStyleSheet() ); - } */ } } @@ -2150,6 +2140,12 @@ std::map App::getDefaultKeybindings() { return local; } +#if EE_PLATFORM == EE_PLATFORM_MACOS +static Uint32 DefaultSwitchToStatusPanelModifier = KeyMod::getDefaultModifier(); +#else +static Uint32 DefaultSwitchToStatusPanelModifier = KEYMOD_LALT; +#endif + std::map App::getLocalKeybindings() { return { { { KEY_RETURN, KEYMOD_LALT | KEYMOD_LCTRL }, "fullscreen-toggle" }, @@ -2185,11 +2181,11 @@ std::map App::getLocalKeybindings() { "terminal-split-swap" }, { { KEY_T, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT }, "reopen-closed-tab" }, - { { KEY_1, KEYMOD_LALT }, "toggle-status-locate-bar" }, - { { KEY_2, KEYMOD_LALT }, "toggle-status-global-search-bar" }, - { { KEY_3, KEYMOD_LALT }, "toggle-status-terminal" }, - { { KEY_4, KEYMOD_LALT }, "toggle-status-build-output" }, - { { KEY_5, KEYMOD_LALT }, "toggle-status-app-output" }, + { { KEY_1, DefaultSwitchToStatusPanelModifier }, "toggle-status-locate-bar" }, + { { KEY_2, DefaultSwitchToStatusPanelModifier }, "toggle-status-global-search-bar" }, + { { KEY_3, DefaultSwitchToStatusPanelModifier }, "toggle-status-terminal" }, + { { KEY_4, DefaultSwitchToStatusPanelModifier }, "toggle-status-build-output" }, + { { KEY_5, DefaultSwitchToStatusPanelModifier }, "toggle-status-app-output" }, { { KEY_B, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "project-build-start-cancel" }, { { KEY_C, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "project-build-cancel" }, { { KEY_R, KeyMod::getDefaultModifier() }, "project-build-and-run" }, diff --git a/src/tools/ecode/plugins/debugger/debuggerplugin.cpp b/src/tools/ecode/plugins/debugger/debuggerplugin.cpp index 5949e73c1..81ec6b39a 100644 --- a/src/tools/ecode/plugins/debugger/debuggerplugin.cpp +++ b/src/tools/ecode/plugins/debugger/debuggerplugin.cpp @@ -574,7 +574,11 @@ void DebuggerPlugin::loadDAPConfig( const std::string& path, bool updateConfigFi mKeyBindings["debugger-step-over"] = "f10"; mKeyBindings["debugger-step-into"] = "f11"; mKeyBindings["debugger-step-out"] = "shift+f11"; + #if EE_PLATFORM == EE_PLATFORM_MACOS + mKeyBindings["toggle-status-app-debugger"] = "mod+6"; + #else mKeyBindings["toggle-status-app-debugger"] = "alt+6"; + #endif } if ( j.contains( "keybindings" ) ) { diff --git a/src/tools/ecode/plugins/debugger/statusdebuggercontroller.cpp b/src/tools/ecode/plugins/debugger/statusdebuggercontroller.cpp index d726c8d1d..b5bcc91a4 100644 --- a/src/tools/ecode/plugins/debugger/statusdebuggercontroller.cpp +++ b/src/tools/ecode/plugins/debugger/statusdebuggercontroller.cpp @@ -93,13 +93,14 @@ UIWidget* UIBreakpointsTableView::createCell( UIWidget* rowWidget, const ModelIn const std::map StatusDebuggerController::getLocalDefaultKeybindings() { return { - { { KEY_TAB, KeyMod::getDefaultModifier() }, "next-tab" }, - { { KEY_TAB, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "previous-tab" }, - { { KEY_1, KeyMod::getDefaultModifier() }, "switch-to-tab-1" }, - { { KEY_2, KeyMod::getDefaultModifier() }, "switch-to-tab-2" }, - { { KEY_3, KeyMod::getDefaultModifier() }, "switch-to-tab-3" }, - { { KEY_4, KeyMod::getDefaultModifier() }, "switch-to-tab-4" }, - { { KEY_5, KeyMod::getDefaultModifier() }, "switch-to-tab-5" }, + { { KEY_TAB, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, "next-tab" }, + { { KEY_TAB, UICodeEditorSplitter::getDefaultSwitchToTabModifier() | KEYMOD_SHIFT }, + "previous-tab" }, + { { KEY_1, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, "switch-to-tab-1" }, + { { KEY_2, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, "switch-to-tab-2" }, + { { KEY_3, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, "switch-to-tab-3" }, + { { KEY_4, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, "switch-to-tab-4" }, + { { KEY_5, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, "switch-to-tab-5" }, }; } diff --git a/src/tools/ecode/plugins/formatter/formatterplugin.cpp b/src/tools/ecode/plugins/formatter/formatterplugin.cpp index 20109d95d..144269521 100644 --- a/src/tools/ecode/plugins/formatter/formatterplugin.cpp +++ b/src/tools/ecode/plugins/formatter/formatterplugin.cpp @@ -206,8 +206,14 @@ void FormatterPlugin::loadFormatterConfig( const std::string& path, bool updateC config["auto_format_on_save"] = getAutoFormatOnSave(); } - if ( mKeyBindings.empty() ) + if ( mKeyBindings.empty() ) { +#if EE_PLATFORM == EE_PLATFORM_MACOS + mKeyBindings["format-doc"] = "mod+alt+f"; +#else mKeyBindings["format-doc"] = "alt+f"; +#endif + } + if ( j.contains( "keybindings" ) && j["keybindings"].contains( "format-doc" ) ) mKeyBindings["format-doc"] = j["keybindings"]["format-doc"]; else if ( updateConfigFile ) diff --git a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp index 8a5622cbd..94b2f87c6 100644 --- a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp @@ -1092,7 +1092,11 @@ void LSPClientPlugin::loadLSPConfig( std::vector& lsps, const std mKeyBindings["lsp-go-to-definition"] = "f2"; mKeyBindings["lsp-go-to-implementation"] = "shift+f2"; mKeyBindings["lsp-symbol-info"] = "f1"; + #if EE_PLATFORM == EE_PLATFORM_MACOS + mKeyBindings["lsp-symbol-code-action"] = "mod+return"; + #else mKeyBindings["lsp-symbol-code-action"] = "alt+return"; + #endif mKeyBindings["lsp-rename-symbol-under-cursor"] = "mod+shift+r"; mKeyBindings["lsp-symbol-references"] = "mod+shift+u"; mKeyBindings["lsp-format-range"] = "alt+shift+f"; diff --git a/src/tools/ecode/statusbuildoutputcontroller.cpp b/src/tools/ecode/statusbuildoutputcontroller.cpp index aa0eefb4c..c72345e50 100644 --- a/src/tools/ecode/statusbuildoutputcontroller.cpp +++ b/src/tools/ecode/statusbuildoutputcontroller.cpp @@ -591,19 +591,23 @@ void StatusBuildOutputController::createContainer() { mContainer->setCommand( "build-output-show-build-output", [this]() { showBuildOutput(); } ); mContainer->setCommand( "build-output-show-build-issues", [this]() { showIssues(); } ); - mContainer->getKeyBindings().addKeybind( { KEY_1, KeyMod::getDefaultModifier() }, - "build-output-show-build-output" ); - mContainer->getKeyBindings().addKeybind( { KEY_2, KeyMod::getDefaultModifier() }, - "build-output-show-build-issues" ); + mContainer->getKeyBindings().addKeybind( + { KEY_1, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, + "build-output-show-build-output" ); + mContainer->getKeyBindings().addKeybind( + { KEY_2, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, + "build-output-show-build-issues" ); mBuildOutput->getDocument().setCommand( "build-output-show-build-output", [this]() { showBuildOutput(); } ); mBuildOutput->getDocument().setCommand( "build-output-show-build-issues", [this]() { showIssues(); } ); - mBuildOutput->getKeyBindings().addKeybind( { KEY_1, KeyMod::getDefaultModifier() }, - "build-output-show-build-output" ); - mBuildOutput->getKeyBindings().addKeybind( { KEY_2, KeyMod::getDefaultModifier() }, - "build-output-show-build-issues" ); + mBuildOutput->getKeyBindings().addKeybind( + { KEY_1, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, + "build-output-show-build-output" ); + mBuildOutput->getKeyBindings().addKeybind( + { KEY_2, UICodeEditorSplitter::getDefaultSwitchToTabModifier() }, + "build-output-show-build-issues" ); mButOutput->onClick( [this]( auto ) { showBuildOutput(); } ); mButIssues->onClick( [this]( auto ) { showIssues(); } ); mButOutput->setTooltipText(