Allow to split editors views by dragging tabs into the tab widget corners.

This commit is contained in:
Martín Lucas Golini
2024-12-29 23:50:24 -03:00
parent a447da4002
commit 793e87af5c
14 changed files with 252 additions and 51 deletions

View File

@@ -651,8 +651,7 @@ void AppConfig::loadDocuments( UICodeEditorSplitter* editorSplitter, json j,
}
} else if ( j["type"] == "splitter" ) {
UISplitter* splitter = editorSplitter->split(
j["orientation"] == "horizontal" ? UICodeEditorSplitter::SplitDirection::Right
: UICodeEditorSplitter::SplitDirection::Bottom,
j["orientation"] == "horizontal" ? SplitDirection::Right : SplitDirection::Bottom,
curTabWidget->getTabSelected()->getOwnedWidget()->asType<UICodeEditor>(), false );
if ( nullptr == splitter )

View File

@@ -201,26 +201,22 @@ class App : public UICodeEditorSplitter::Client {
[this] { mTerminalManager->createTerminalInSplitter(); } );
t.setCommand( "terminal-split-right", [this] {
auto cwd = getCurrentWorkingDir();
mSplitter->split( UICodeEditorSplitter::SplitDirection::Right,
mSplitter->getCurWidget(), false );
mSplitter->split( SplitDirection::Right, mSplitter->getCurWidget(), false );
mTerminalManager->createNewTerminal( "", nullptr, cwd );
} );
t.setCommand( "terminal-split-bottom", [this] {
auto cwd = getCurrentWorkingDir();
mSplitter->split( UICodeEditorSplitter::SplitDirection::Bottom,
mSplitter->getCurWidget(), false );
mSplitter->split( SplitDirection::Bottom, mSplitter->getCurWidget(), false );
mTerminalManager->createNewTerminal( "", nullptr, cwd );
} );
t.setCommand( "terminal-split-left", [this] {
auto cwd = getCurrentWorkingDir();
mSplitter->split( UICodeEditorSplitter::SplitDirection::Left, mSplitter->getCurWidget(),
false );
mSplitter->split( SplitDirection::Left, mSplitter->getCurWidget(), false );
mTerminalManager->createNewTerminal( "", nullptr, cwd );
} );
t.setCommand( "terminal-split-top", [this] {
auto cwd = getCurrentWorkingDir();
mSplitter->split( UICodeEditorSplitter::SplitDirection::Top, mSplitter->getCurWidget(),
false );
mSplitter->split( SplitDirection::Top, mSplitter->getCurWidget(), false );
mTerminalManager->createNewTerminal( "", nullptr, cwd );
} );
t.setCommand( "reopen-closed-tab", [this] { reopenClosedTab(); } );

View File

@@ -42,15 +42,13 @@ UITerminal* TerminalManager::createTerminalInSplitter( const std::string& workin
switch ( config.term.newTerminalOrientation ) {
case NewTerminalOrientation::Vertical: {
auto cwd = workingDir.empty() ? mApp->getCurrentWorkingDir() : workingDir;
splitter->split( UICodeEditorSplitter::SplitDirection::Right,
splitter->getCurWidget(), false );
splitter->split( SplitDirection::Right, splitter->getCurWidget(), false );
term = createNewTerminal( "", nullptr, cwd, "", {}, fallback );
break;
}
case NewTerminalOrientation::Horizontal: {
auto cwd = workingDir.empty() ? mApp->getCurrentWorkingDir() : workingDir;
splitter->split( UICodeEditorSplitter::SplitDirection::Bottom,
splitter->getCurWidget(), false );
splitter->split( SplitDirection::Bottom, splitter->getCurWidget(), false );
term = createNewTerminal( "", nullptr, cwd, "", {}, fallback );
break;
}