Added custom mouse gesture bindings (SpartanJ/ecode#602).

This commit is contained in:
Martín Lucas Golini
2025-08-27 23:48:11 -03:00
parent 3e298e4252
commit 39d4c30953
6 changed files with 121 additions and 1 deletions

View File

@@ -1302,6 +1302,11 @@ void App::loadKeybindings() {
DocSearchController::getDefaultKeybindings(), forceRebind,
getMigrateKeybindings(), mConfig.iniState );
KeybindingsHelper::updateKeybindings( ini, "editor_mouse_bindings", mWindow->getInput(),
mMousebindings, mMousebindingsInvert,
UICodeEditor::getDefaultMousebindings(), forceRebind,
getMigrateKeybindings(), mConfig.iniState );
auto localKeybindings = getLocalKeybindings();
for ( const auto& kb : localKeybindings ) {
auto found = mKeybindingsInvert.find( kb.second );
@@ -1340,10 +1345,15 @@ void App::reloadKeybindings() {
mRealSplitterKeybindings.clear();
mRealTerminalKeybindings.clear();
mRealDefaultKeybindings.clear();
mMousebindings.clear();
mMousebindingsInvert.clear();
loadKeybindings();
mSplitter->forEachEditor( [this]( UICodeEditor* ed ) {
ed->getKeyBindings().reset();
ed->getKeyBindings().addKeybindsStringUnordered( mKeybindings );
ed->getMouseBindings().reset();
ed->getMouseBindings().addMousebindsString( mMousebindings );
} );
mSplitter->forEachWidgetType( UI_TYPE_TERMINAL, [this]( UIWidget* widget ) {
mTerminalManager->setKeybindings( widget->asType<UITerminal>() );
@@ -2547,6 +2557,11 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) {
editor->getKeyBindings().addKeybindsStringUnordered( mKeybindings );
}
if ( !mMousebindings.empty() ) {
editor->getMouseBindings().reset();
editor->getMouseBindings().addMousebindsString( mMousebindings );
}
editor->on( Event::OnClose, [this, editor]( auto ) {
if ( SceneManager::existsSingleton() && !SceneManager::instance()->isShuttingDown() &&
editor->hasClass( NOT_UNIQUE_FILENAME ) )