diff --git a/src/tools/ecode/appconfig.cpp b/src/tools/ecode/appconfig.cpp index a0a6f8cda..c1c649dd5 100644 --- a/src/tools/ecode/appconfig.cpp +++ b/src/tools/ecode/appconfig.cpp @@ -212,6 +212,8 @@ void AppConfig::load( const std::string& confPath, std::string& keybindingsPath, ini.getValueB( "global_search_bar", "buffer_only_mode", false ); term.shell = ini.getValue( "terminal", "shell" ); + term.shellArgs = ini.getValue( "terminal", "shell_args", + Sys::getPlatformType() == Sys::PlatformType::Haiku ? "-l" : "" ); term.fontSize = ini.getValue( "terminal", "font_size", "11dp" ); term.colorScheme = ini.getValue( "terminal", "colorscheme", "eterm" ); term.newTerminalOrientation = NewTerminalOrientation::fromString( @@ -367,6 +369,7 @@ void AppConfig::save( const std::vector& recentFiles, ini.setValueB( "global_search_bar", "buffer_only_mode", globalSearchBarConfig.bufferOnlyMode ); ini.setValue( "terminal", "shell", term.shell ); + ini.setValue( "terminal", "shell_args", term.shellArgs ); ini.setValue( "terminal", "font_size", term.fontSize.toString() ); ini.setValue( "terminal", "colorscheme", term.colorScheme ); ini.setValue( "terminal", "new_terminal_orientation", diff --git a/src/tools/ecode/appconfig.hpp b/src/tools/ecode/appconfig.hpp index a85100a07..e5117dcfa 100644 --- a/src/tools/ecode/appconfig.hpp +++ b/src/tools/ecode/appconfig.hpp @@ -168,6 +168,7 @@ class NewTerminalOrientation { struct TerminalConfig { std::string shell; + std::string shellArgs; std::string colorScheme{ "eterm" }; StyleSheetLength fontSize{ 11, StyleSheetLength::Dp }; NewTerminalOrientation::Orientation newTerminalOrientation{ diff --git a/src/tools/ecode/terminalmanager.cpp b/src/tools/ecode/terminalmanager.cpp index d49d4b5e6..434f5ce66 100644 --- a/src/tools/ecode/terminalmanager.cpp +++ b/src/tools/ecode/terminalmanager.cpp @@ -9,7 +9,7 @@ namespace ecode { TerminalManager::TerminalManager( App* app ) : mApp( app ) {} UITerminal* TerminalManager::createTerminalInSplitter( - const std::string& workingDir, std::string program, const std::vector& args, + const std::string& workingDir, std::string program, std::vector args, const std::unordered_map& env, bool fallback, bool keepAlive ) { #if EE_PLATFORM == EE_PLATFORM_WIN std::string os = Sys::getOSName( true ); @@ -158,18 +158,20 @@ void TerminalManager::configureTerminalShell() { - - + + + - - + + )xml" ); UIWindow* window = mApp->getUISceneNode()->loadLayoutFromString( layout )->asType(); UIComboBox* shellCombo = window->find( "shell_combo" ); + UITextInput* shellArgs = window->find( "shell_args" ); UIPushButton* ok = window->find( "ok" ); UIPushButton* cancel = window->find( "cancel" ); const std::vector list{ @@ -182,6 +184,7 @@ void TerminalManager::configureTerminalShell() { found.emplace_back( std::move( f ) ); } shellCombo->getListBox()->addListBoxItems( found ); + shellArgs->setText( mApp->termConfig().shellArgs ); const char* shellEnv = std::getenv( "SHELL" ); if ( !mApp->termConfig().shell.empty() ) { shellCombo->getListBox()->setSelected( mApp->termConfig().shell ); @@ -191,15 +194,17 @@ void TerminalManager::configureTerminalShell() { : Sys::which( shellEnv ) ); if ( !shellEnvStr.empty() ) shellCombo->getListBox()->setSelected( shellEnvStr ); - } else if ( Sys::getPlatform() == "Windows" ) { + } else if ( Sys::getPlatformType() == Sys::PlatformType::Windows ) { std::string shellEnvStr( Sys::which( "powershell" ) ); if ( !shellEnvStr.empty() ) shellCombo->getListBox()->setSelected( shellEnvStr ); } - const auto setShellFn = []( App* app, UIWindow* window, UIComboBox* shellCombo ) { + const auto setShellFn = []( App* app, UIWindow* window, UIComboBox* shellCombo, + UITextInput* shellArgs ) { std::string shell( shellCombo->getText().toUtf8() ); if ( !Sys::which( shell ).empty() || FileSystem::fileExists( shell ) ) { app->getConfig().term.shell = shell; + app->getConfig().term.shellArgs = shellArgs->getText().toUtf8(); window->closeWindow(); } else { app->errorMsgBox( app->i18n( @@ -212,8 +217,8 @@ void TerminalManager::configureTerminalShell() { shellCombo->getListBox()->getVerticalScrollBar()->setClickStep( shellCombo->getDropDownList()->getMaxNumVisibleItems() / (Float)found.size() ); ok->setFocus(); - ok->onClick( [this, setShellFn, window, - shellCombo]( const MouseEvent* ) { setShellFn( mApp, window, shellCombo ); }, + ok->onClick( [this, setShellFn, window, shellCombo, shellArgs]( + const MouseEvent* ) { setShellFn( mApp, window, shellCombo, shellArgs ); }, MouseButton::EE_BUTTON_LEFT ); cancel->onClick( [window]( const MouseEvent* ) { window->closeWindow(); }, EE_BUTTON_LEFT ); window->on( Event::KeyDown, [window]( const Event* event ) { @@ -451,7 +456,7 @@ void TerminalManager::displayError( const std::string& workingDir ) { UITerminal* TerminalManager::createNewTerminal( const std::string& title, UITabWidget* inTabWidget, const std::string& workingDir, - std::string program, const std::vector& args, + std::string program, std::vector args, const std::unordered_map& env, bool fallback, bool keepAlive ) { #if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN UIMessageBox* msgBox = UIMessageBox::New( @@ -494,6 +499,9 @@ UITerminal* TerminalManager::createNewTerminal( if ( program.empty() && !mApp->termConfig().shell.empty() ) program = mApp->termConfig().shell; + if ( args.empty() && !mApp->termConfig().shellArgs.empty() ) + args = Process::parseArgs( mApp->termConfig().shellArgs ); + UITerminal* term = UITerminal::New( mApp->getTerminalFont() ? mApp->getTerminalFont() : mApp->getFontMono(), mApp->termConfig().fontSize.asPixels( 0, Sizef(), mApp->getDisplayDPI() ), initialSize, diff --git a/src/tools/ecode/terminalmanager.hpp b/src/tools/ecode/terminalmanager.hpp index 269bf1cb6..537b51cfd 100644 --- a/src/tools/ecode/terminalmanager.hpp +++ b/src/tools/ecode/terminalmanager.hpp @@ -17,14 +17,14 @@ class TerminalManager { UITerminal* createTerminalInSplitter( const std::string& workingDir = "", std::string program = "", - const std::vector& args = {}, + std::vector args = {}, const std::unordered_map& env = {}, bool fallback = true, bool keepAlive = true ); UITerminal* createNewTerminal( const std::string& title = "", UITabWidget* inTabWidget = nullptr, const std::string& workingDir = "", std::string program = "", - const std::vector& args = {}, + std::vector args = {}, const std::unordered_map& env = {}, bool fallback = true, bool keepAlive = true );