mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-07-20 17:52:50 +03:00
Use the new tab position setting for *all* new tabs (SpartanJ/ecode#904).
This commit is contained in:
@@ -447,6 +447,10 @@
|
||||
{
|
||||
"name": "minimax/minimax-m2.5:free",
|
||||
"display_name": "MiniMax: MiniMax M2.5 (free)"
|
||||
},
|
||||
{
|
||||
"name": "NVIDIA: Nemotron 3 Ultra (free)",
|
||||
"display_name": "nvidia/nemotron-3-ultra-550b-a55b:free"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1818,6 +1818,33 @@ void App::onTabCreated( UITab* tab, UIWidget* ) {
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
applyNewTabPosition( tab );
|
||||
}
|
||||
|
||||
void App::applyNewTabPosition( UITab* tab ) {
|
||||
UITabWidget* tabWidget = tab->getTabWidget();
|
||||
if ( !tabWidget )
|
||||
return;
|
||||
switch ( mConfig.editor.newTabPosition ) {
|
||||
case NewTabPosition::AfterActive: {
|
||||
Uint32 selectedIdx = tabWidget->getTabSelectedIndex();
|
||||
Uint32 newIdx = eemin<Uint32>( selectedIdx + 1, tabWidget->getTabCount() - 1 );
|
||||
tabWidget->moveTab( tab, newIdx );
|
||||
break;
|
||||
}
|
||||
case NewTabPosition::First:
|
||||
tabWidget->moveTab( tab, 0 );
|
||||
break;
|
||||
case NewTabPosition::LeftOfActive: {
|
||||
Uint32 selectedIdx = tabWidget->getTabSelectedIndex();
|
||||
tabWidget->moveTab( tab, eemin<Uint32>( selectedIdx, tabWidget->getTabCount() - 1 ) );
|
||||
break;
|
||||
}
|
||||
case NewTabPosition::Last:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void App::onColorSchemeChanged( const std::string& ) {
|
||||
|
||||
@@ -384,44 +384,7 @@ class App : public UICodeEditorSplitter::Client, public PluginContextProvider {
|
||||
mSplitter->registerSplitterCommands( t );
|
||||
|
||||
// Overwrite it
|
||||
t.setCommand( "create-new", [this] {
|
||||
UITabWidget* tabWidget = getSplitter()->getPreferredTabWidget();
|
||||
Uint32 selectedIdx =
|
||||
tabWidget && tabWidget->getTabCount() > 0 ? tabWidget->getTabSelectedIndex() : 0;
|
||||
auto d = getSplitter()->createCodeEditorInTabWidget( tabWidget );
|
||||
if ( d.first == nullptr || d.second == nullptr ) {
|
||||
if ( !getSplitter()->getTabWidgets().empty() ) {
|
||||
tabWidget = getSplitter()->getTabWidgets()[0];
|
||||
selectedIdx = tabWidget && tabWidget->getTabCount() > 0
|
||||
? tabWidget->getTabSelectedIndex()
|
||||
: 0;
|
||||
d = getSplitter()->createCodeEditorInTabWidget( tabWidget );
|
||||
}
|
||||
}
|
||||
if ( d.first == nullptr || d.second == nullptr ) {
|
||||
Log::error( "Couldn't createCodeEditorInTabWidget in create-new command" );
|
||||
return;
|
||||
}
|
||||
tabWidget = d.first->getTabWidget();
|
||||
switch ( mConfig.editor.newTabPosition ) {
|
||||
case NewTabPosition::AfterActive: {
|
||||
Uint32 newIdx = eemin<Uint32>( selectedIdx + 1, tabWidget->getTabCount() - 1 );
|
||||
tabWidget->moveTab( d.first, newIdx );
|
||||
break;
|
||||
}
|
||||
case NewTabPosition::First:
|
||||
tabWidget->moveTab( d.first, 0 );
|
||||
break;
|
||||
case NewTabPosition::LeftOfActive:
|
||||
tabWidget->moveTab(
|
||||
d.first, eemin<Uint32>( selectedIdx, tabWidget->getTabCount() - 1 ) );
|
||||
break;
|
||||
case NewTabPosition::Last:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
tabWidget->setTabSelected( d.first );
|
||||
} );
|
||||
t.setCommand( "create-new", [this] { getSplitter()->createEditorInNewTab(); } );
|
||||
|
||||
t.setCommand( "next-tab", [this] {
|
||||
UITabWidget* tabWidget =
|
||||
@@ -871,6 +834,8 @@ class App : public UICodeEditorSplitter::Client, public PluginContextProvider {
|
||||
|
||||
void onTabCreated( UITab* tab, UIWidget* widget );
|
||||
|
||||
void applyNewTabPosition( UITab* tab );
|
||||
|
||||
bool trySendUnlockedCmd( const KeyEvent& keyEvent );
|
||||
|
||||
FontTrueType* loadFont( const std::string& name, std::string fontPath,
|
||||
|
||||
Reference in New Issue
Block a user