diff --git a/bin/assets/plugins/linters.json b/bin/assets/plugins/linters.json index 7d58401b9..938fb96e1 100644 --- a/bin/assets/plugins/linters.json +++ b/bin/assets/plugins/linters.json @@ -11,7 +11,8 @@ "warning_pattern_order": { "line": 3, "col": 4, "message": 2, "type": 1 }, "command": "jq -e . $FILENAME", "expected_exitcodes": [1, 2, 3, 4], - "no_errors_exit_code": 0 + "no_errors_exit_code": 0, + "use_tmp_folder": true }, { "file_patterns": ["%.js$", "%.ts$"], diff --git a/include/eepp/core/string.hpp b/include/eepp/core/string.hpp index 81aee7d5e..082edeb20 100644 --- a/include/eepp/core/string.hpp +++ b/include/eepp/core/string.hpp @@ -121,7 +121,8 @@ class EE_API String { * splitting, detects functions, arrays, braces and quotes for the splitting. */ static std::vector split( const std::string& str, const std::string& delims, const std::string& delimsPreserve = "", - const std::string& quote = "\"" ); + const std::string& quote = "\"", + const bool& removeQuotes = false ); /** Joins a string vector into a single string */ static std::string join( const std::vector& strArray, const Int8& joinchar = ' ', diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 74f4e6ea5..8b8f857ca 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -1203,6 +1203,7 @@ ecode-debug ProjectExplorer.CustomExecutableRunConfiguration + /home/programming/lad/lad-api/ true false false diff --git a/src/eepp/core/string.cpp b/src/eepp/core/string.cpp index 792fe6aa2..36fc8a2f5 100644 --- a/src/eepp/core/string.cpp +++ b/src/eepp/core/string.cpp @@ -367,8 +367,8 @@ std::vector String::split( const StringBaseType& delim, const bool& push } std::vector String::split( const std::string& str, const std::string& delims, - const std::string& delimsPreserve, - const std::string& quote ) { + const std::string& delimsPreserve, const std::string& quote, + const bool& removeQuotes ) { std::vector tokens; if ( str.empty() || ( delims.empty() && delimsPreserve.empty() ) ) { return tokens; @@ -380,8 +380,8 @@ std::vector String::split( const std::string& str, const std::strin std::string::size_type tokenEnd = str.find_first_of( allDelims, tokenStart ); std::string::size_type tokenLen = 0; std::string token; - while ( true ) { + bool fromQuote = false; while ( tokenEnd != std::string::npos && quote.find_first_of( str[tokenEnd] ) != std::string::npos ) { if ( str[tokenEnd] == '(' ) { @@ -391,6 +391,7 @@ std::vector String::split( const std::string& str, const std::strin } else if ( str[tokenEnd] == '{' ) { tokenEnd = findCloseBracket( str, tokenEnd, '{', '}' ); } else { + fromQuote = true; tokenEnd = str.find_first_of( str[tokenEnd], tokenEnd + 1 ); } if ( tokenEnd != std::string::npos ) { @@ -406,6 +407,8 @@ std::vector String::split( const std::string& str, const std::strin token = str.substr( tokenStart, tokenLen ); if ( !token.empty() ) { + if ( fromQuote && removeQuotes && token.size() > 2 ) + token = token.substr( 1, token.size() - 2 ); tokens.push_back( token ); } if ( tokenEnd != std::string::npos && !delimsPreserve.empty() && diff --git a/src/modules/eterm/include/eterm/terminal/terminaldisplay.hpp b/src/modules/eterm/include/eterm/terminal/terminaldisplay.hpp index abefd49d5..51b9d124f 100644 --- a/src/modules/eterm/include/eterm/terminal/terminaldisplay.hpp +++ b/src/modules/eterm/include/eterm/terminal/terminaldisplay.hpp @@ -240,7 +240,8 @@ class TerminalDisplay : public ITerminalDisplay { std::vector mBuffer; std::vector> mColors; std::shared_ptr mTerminal; - mutable std::string mClipboard; + mutable String mClipboard; + mutable std::string mClipboardUtf8; Uint32 mNumCallBacks; std::map mCallbacks; diff --git a/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp b/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp index 82a38a380..165422db7 100644 --- a/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp +++ b/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp @@ -560,11 +560,9 @@ void TerminalDisplay::update() { void TerminalDisplay::action( TerminalShortcutAction action ) { switch ( action ) { case TerminalShortcutAction::PASTE: { - auto clipboard = getClipboard(); - auto clipboardLen = strlen( clipboard ); - if ( clipboardLen > 0 ) { - mTerminal->ttywrite( clipboard, clipboardLen, 1 ); - } + getClipboard(); + if ( !mClipboard.empty() ) + mTerminal->ttywrite( mClipboardUtf8.c_str(), mClipboardUtf8.size(), 1 ); break; } case TerminalShortcutAction::COPY: { @@ -632,6 +630,7 @@ void TerminalDisplay::setClipboard( const char* text ) { if ( text == nullptr ) return; mClipboard = text; + mClipboardUtf8 = mClipboard.toUtf8(); mWindow->getClipboard()->setText( mClipboard ); } @@ -645,7 +644,8 @@ const char* TerminalDisplay::getClipboard() const { return mClipboard.c_str(); } #endif - return mClipboard.c_str(); + mClipboardUtf8 = mClipboard.toUtf8(); + return mClipboardUtf8.c_str(); } bool TerminalDisplay::drawBegin( int columns, int rows ) { @@ -733,6 +733,12 @@ void TerminalDisplay::onMouseDown( const Vector2i& pos, const Uint32& flags ) { if ( !selection.empty() ) { for ( auto& chr : selection ) onTextInput( chr ); + } else { + getClipboard(); + if ( !mClipboard.empty() ) { + for ( auto& chr : mClipboard ) + onTextInput( chr ); + } } } } diff --git a/src/modules/eterm/src/eterm/ui/uiterminal.cpp b/src/modules/eterm/src/eterm/ui/uiterminal.cpp index 37d4c7fa1..da2574e5c 100644 --- a/src/modules/eterm/src/eterm/ui/uiterminal.cpp +++ b/src/modules/eterm/src/eterm/ui/uiterminal.cpp @@ -188,11 +188,17 @@ Uint32 UITerminal::onKeyUp( const KeyEvent& ) { } Uint32 UITerminal::onMouseMove( const Vector2i& position, const Uint32& flags ) { + if ( getUISceneNode()->getUIEventDispatcher()->isNodeDragging() ) + return 0; + mTerm->onMouseMove( position, flags ); return 1; } Uint32 UITerminal::onMouseDown( const Vector2i& position, const Uint32& flags ) { + if ( getUISceneNode()->getUIEventDispatcher()->isNodeDragging() ) + return 0; + if ( ( flags & EE_BUTTON_LMASK ) && mTerm->getTerminal()->getSelectionMode() == TerminalSelectionMode::SEL_IDLE ) { mDraggingSel = true; diff --git a/src/tools/ecode/appconfig.cpp b/src/tools/ecode/appconfig.cpp index 230fe838e..b7f09815b 100644 --- a/src/tools/ecode/appconfig.cpp +++ b/src/tools/ecode/appconfig.cpp @@ -322,7 +322,12 @@ static void loadDocuments( UICodeEditorSplitter* editorSplitter, std::shared_ptr }, curTabWidget ); } else if ( file["type"] == "terminal" ) { - app->createNewTerminal( file.contains( "title" ) ? file["title"] : "" ); + app->createNewTerminal( file.contains( "title" ) ? file["title"] : "", + curTabWidget ); + + if ( curTabWidget->getTabCount() == totalToLoad ) + curTabWidget->setTabSelected( + eeclamp( currentPage, 0, curTabWidget->getTabCount() - 1 ) ); } } } else if ( j["type"] == "splitter" ) { diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 0184e0582..cdcf6bd08 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -1994,11 +1994,18 @@ void App::fullscreenToggle() { ->setActive( !mWindow->isWindowed() ); } -void App::createNewTerminal( const std::string& title ) { - UIWidget* curWidget = mEditorSplitter->getCurWidget(); - if ( !curWidget ) - return; - UITabWidget* tabWidget = mEditorSplitter->tabWidgetFromWidget( curWidget ); +void App::createNewTerminal( const std::string& title, UITabWidget* inTabWidget ) { + UITabWidget* tabWidget = nullptr; + + if ( !inTabWidget ) { + UIWidget* curWidget = mEditorSplitter->getCurWidget(); + if ( !curWidget ) + return; + tabWidget = mEditorSplitter->tabWidgetFromWidget( curWidget ); + } else { + tabWidget = inTabWidget; + } + if ( !tabWidget ) { if ( !mEditorSplitter->getTabWidgets().empty() ) { tabWidget = mEditorSplitter->getTabWidgets()[0]; @@ -2009,8 +2016,10 @@ void App::createNewTerminal( const std::string& title ) { UITerminal* term = UITerminal::New( mFontMonoNerdFont ? mFontMonoNerdFont : mFontMono, PixelDensity::dpToPx( 11 ), Sizef( 16, 16 ), "", {}, !mCurrentProject.empty() ? mCurrentProject : "" ); - mEditorSplitter->createWidgetInTabWidget( tabWidget, term, title.empty() ? "Shell" : title, - true ); + auto ret = mEditorSplitter->createWidgetInTabWidget( tabWidget, term, + title.empty() ? "Shell" : title, true ); + mEditorSplitter->removeUnusedTab( tabWidget ); + ret.first->setIcon( findIcon( "filetype-bash" ) ); term->setTitle( title ); term->addEventListener( Event::OnTitleChange, [&]( const Event* event ) { if ( event->getNode() != mEditorSplitter->getCurWidget() ) diff --git a/src/tools/ecode/ecode.hpp b/src/tools/ecode/ecode.hpp index 5202b081b..fe5ac17f5 100644 --- a/src/tools/ecode/ecode.hpp +++ b/src/tools/ecode/ecode.hpp @@ -80,7 +80,7 @@ class App : public UICodeEditorSplitter::Client { NotificationCenter* getNotificationCenter() const; - void createNewTerminal( const std::string& title = "" ); + void createNewTerminal( const std::string& title = "", UITabWidget* inTabWidget = nullptr ); std::map getAppKeybindings(); diff --git a/src/tools/ecode/plugins/formatter/formatterplugin.cpp b/src/tools/ecode/plugins/formatter/formatterplugin.cpp index abab8d205..3fd4fa5a4 100644 --- a/src/tools/ecode/plugins/formatter/formatterplugin.cpp +++ b/src/tools/ecode/plugins/formatter/formatterplugin.cpp @@ -171,7 +171,7 @@ void FormatterPlugin::runFormatter( UICodeEditor* editor, const Formatter& forma std::string cmd( formatter.command ); String::replaceAll( cmd, "$FILENAME", "\"" + path + "\"" ); - std::vector cmdArr = String::split( cmd, " " ); + std::vector cmdArr = String::split( cmd, " ", "", "\"", true ); std::vector strings; for ( size_t i = 0; i < cmdArr.size(); ++i ) strings.push_back( cmdArr[i].c_str() ); @@ -194,7 +194,10 @@ void FormatterPlugin::runFormatter( UICodeEditor* editor, const Formatter& forma if ( subprocess_alive( &subprocess ) && !mShuttingDown ) subprocess_join( &subprocess, &returnCode ); + else + returnCode = subprocess.return_status; subprocess_destroy( &subprocess ); + // Log::info( "Formatter result:\n%s", data.c_str() ); if ( formatter.type == FormatterType::Output ) { diff --git a/src/tools/ecode/plugins/linter/linterplugin.cpp b/src/tools/ecode/plugins/linter/linterplugin.cpp index 40cc3e606..098708e19 100644 --- a/src/tools/ecode/plugins/linter/linterplugin.cpp +++ b/src/tools/ecode/plugins/linter/linterplugin.cpp @@ -250,7 +250,7 @@ void LinterPlugin::runLinter( std::shared_ptr doc, const Linter& l Clock clock; std::string cmd( linter.command ); String::replaceAll( cmd, "$FILENAME", "\"" + path + "\"" ); - std::vector cmdArr = String::split( cmd, " " ); + std::vector cmdArr = String::split( cmd, " ", "", "\"", true ); std::vector strings; for ( size_t i = 0; i < cmdArr.size(); ++i ) strings.push_back( cmdArr[i].c_str() ); @@ -273,6 +273,8 @@ void LinterPlugin::runLinter( std::shared_ptr doc, const Linter& l if ( subprocess_alive( &subprocess ) && !mShuttingDown ) subprocess_join( &subprocess, &returnCode ); + else + returnCode = subprocess.return_status; subprocess_destroy( &subprocess ); if ( linter.hasNoErrorsExitCode && linter.noErrorsExitCode == returnCode ) {