From 67a86c3c055f5dadfbb6eac375ab42a3b20b1453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 31 Mar 2025 18:52:42 -0300 Subject: [PATCH] Process class fix a dead-lock. Compile with C++20 (compilation might fail on some systems, let's see the CI). Fixed V1 syntax highlighting. --- .github/workflows/ecode-nightly.yml | 6 +- include/eepp/core/string.hpp | 37 ++++-- include/eepp/graphics/font.hpp | 4 +- include/eepp/ui/uihelper.hpp | 16 +-- premake4.lua | 40 +++--- premake5.lua | 36 +++--- src/eepp/core/string.cpp | 13 ++ src/eepp/graphics/textureatlasloader.cpp | 8 +- src/eepp/system/process.cpp | 2 +- src/eepp/system/regex.cpp | 10 +- src/eepp/ui/doc/languages/cpp.cpp | 1 + src/eepp/ui/doc/textdocument.cpp | 5 +- src/eepp/ui/models/filesystemmodel.cpp | 4 +- src/eepp/ui/uitextview.cpp | 5 +- .../src/eepp/ui/doc/languages/v1.cpp | 122 +++++++----------- src/tests/test_all/test.cpp | 4 +- src/thirdparty/nanosvg/nanosvg.h | 2 +- src/tools/ecode/ecode.cpp | 2 +- .../ecode/plugins/debugger/debuggerplugin.cpp | 3 +- src/tools/ecode/settingsactions.cpp | 10 +- 20 files changed, 174 insertions(+), 156 deletions(-) diff --git a/.github/workflows/ecode-nightly.yml b/.github/workflows/ecode-nightly.yml index 04317e68b..6c908641c 100644 --- a/.github/workflows/ecode-nightly.yml +++ b/.github/workflows/ecode-nightly.yml @@ -74,9 +74,9 @@ jobs: sudo apt-get update - name: Install dependencies run: | - sudo apt-get install -y gcc-11 g++-11 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 10 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 10 + sudo apt-get install -y gcc-13 g++-13 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 10 sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 sudo update-alternatives --set cc /usr/bin/gcc sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 diff --git a/include/eepp/core/string.hpp b/include/eepp/core/string.hpp index a88cea5f3..2d14a3f29 100644 --- a/include/eepp/core/string.hpp +++ b/include/eepp/core/string.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include namespace EE { @@ -319,7 +320,7 @@ class EE_API String { static bool icontains( const String& haystack, const String& needle ); static int fuzzyMatchSimple( const std::string& pattern, const std::string& string, - bool allowUneven = false, bool permissive = false ); + bool allowUneven = false, bool permissive = false ); static int fuzzyMatch( const std::string& pattern, const std::string& string ); @@ -409,18 +410,33 @@ class EE_API String { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wformat-security" #elif defined( __GNUC__ ) +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-security" #endif - int size = + + int reqSize = std::snprintf( nullptr, 0, format.data(), - FormatArg>::get( std::forward( args ) )... ) + - 1; - std::string result( size, 0 ); - if ( size > 0 ) { - std::snprintf( &result[0], size, format.data(), FormatArg>::get( std::forward( args ) )... ); - result.resize( size - 1 ); + + if ( reqSize < 0 ) + return ""; + + std::size_t bufSize = static_cast( reqSize ) + 1; + std::string result( bufSize, '\0' ); + + int writtenChars = + std::snprintf( &result[0], bufSize, format.data(), + FormatArg>::get( std::forward( args ) )... ); + + if ( writtenChars < 0 ) + return ""; + + if ( static_cast( writtenChars ) < bufSize ) { + result.resize( static_cast( writtenChars ) ); + } else { + result.resize( bufSize - 1 ); } + #ifdef __clang__ #pragma clang diagnostic pop #elif defined( __GNUC__ ) @@ -510,6 +526,11 @@ class EE_API String { **/ String( const std::string& utf8String ); + /** @brief Construct from an UTF-8 string to UTF-32 according + ** @param utf8String UTF-8 string to convert + **/ + String( const std::basic_string& utf8String ); + /** @brief Construct from an UTF-8 string to UTF-32 according ** @param utf8String UTF-8 string to convert **/ diff --git a/include/eepp/graphics/font.hpp b/include/eepp/graphics/font.hpp index 7c3bfe42e..621254dc4 100644 --- a/include/eepp/graphics/font.hpp +++ b/include/eepp/graphics/font.hpp @@ -22,14 +22,14 @@ struct EE_API Glyph { enum class FontType { TTF, BMF, Sprite }; -enum FontHorizontalAlign { +enum FontHorizontalAlign : Uint32 { TEXT_ALIGN_LEFT = ( 0 << 0 ), TEXT_ALIGN_RIGHT = ( 1 << 0 ), TEXT_ALIGN_CENTER = ( 2 << 0 ), TEXT_HALIGN_MASK = ( 3 << 0 ) }; -enum FontVerticalAlign { +enum FontVerticalAlign : Uint32 { TEXT_ALIGN_TOP = ( 0 << 2 ), TEXT_ALIGN_BOTTOM = ( 1 << 2 ), TEXT_ALIGN_MIDDLE = ( 2 << 2 ), diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index 9521d02f8..a914ab071 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -8,12 +8,11 @@ using namespace EE::Graphics; namespace EE { namespace UI { -#define UI_HALIGN_LEFT TEXT_ALIGN_LEFT -#define UI_HALIGN_MASK TEXT_HALIGN_MASK -#define UI_VALIGN_TOP TEXT_ALIGN_TOP -#define UI_VALIGN_MASK TEXT_VALIGN_MASK - -enum UIFlag { +enum UIFlag : Uint32 { + UI_HALIGN_LEFT = TEXT_ALIGN_LEFT, + UI_VALIGN_TOP = TEXT_ALIGN_TOP, + UI_HALIGN_MASK = TEXT_HALIGN_MASK, + UI_VALIGN_MASK = TEXT_VALIGN_MASK, UI_HALIGN_RIGHT = TEXT_ALIGN_RIGHT, UI_HALIGN_CENTER = TEXT_ALIGN_CENTER, UI_VALIGN_BOTTOM = TEXT_ALIGN_BOTTOM, @@ -133,10 +132,7 @@ static const Uint32 UI_NODE_DEFAULT_FLAGS = static const Uint32 UI_NODE_DEFAULT_FLAGS_CENTERED = UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_HALIGN_CENTER | UI_VALIGN_CENTER; -enum class HintDisplay { - Always, - Focus -}; +enum class HintDisplay { Always, Focus }; }} // namespace EE::UI diff --git a/premake4.lua b/premake4.lua index 7ad2ab5f0..3a30bd555 100644 --- a/premake4.lua +++ b/premake4.lua @@ -406,9 +406,9 @@ function build_base_cpp_configuration( package_name ) end if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17", "/utf-8" } + buildoptions{ "/std:c++20", "/utf-8" } end set_ios_config() @@ -510,9 +510,9 @@ function build_link_configuration( package_name, use_ee_icon ) end if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17", "/utf-8", "/bigobj" } + buildoptions{ "/std:c++20", "/utf-8", "/bigobj" } end if package_name ~= "eepp" and package_name ~= "eepp-static" then @@ -976,9 +976,9 @@ function build_eepp( build_name ) end if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17", "/utf-8", "/bigobj" } + buildoptions{ "/std:c++20", "/utf-8", "/bigobj" } end if os.is_real("mingw32") or os.is_real("mingw64") or os.is_real("windows") then @@ -1235,9 +1235,9 @@ solution "eepp" set_targetdir("libs/" .. os.get_real() .. "/thirdparty/") includedirs { "src/thirdparty/efsw/include", "src/thirdparty/efsw/src" } if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17" } + buildoptions{ "/std:c++20" } end if os.is("windows") then @@ -1297,9 +1297,9 @@ solution "eepp" defines { "EE_STATIC" } end if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17" } + buildoptions{ "/std:c++20" } end build_base_cpp_configuration( "eepp-maps-static" ) @@ -1315,9 +1315,9 @@ solution "eepp" defines { "EE_STATIC" } end if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17" } + buildoptions{ "/std:c++20" } end build_base_cpp_configuration( "eepp-maps" ) postsymlinklib("../libs/" .. os.get_real() .. "/", "../../bin/", "eepp-maps" ) @@ -1330,9 +1330,9 @@ solution "eepp" files { "src/modules/physics/src/**.cpp", "src/eepp/physics/constraints/*.cpp" } defines { "EE_PHYSICS_STATIC" } if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17" } + buildoptions{ "/std:c++20" } end build_base_cpp_configuration( "eepp-physics-static" ) @@ -1345,9 +1345,9 @@ solution "eepp" links { "chipmunk-static", "eepp-shared" } defines { "EE_PHYSICS_EXPORTS" } if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17" } + buildoptions{ "/std:c++20" } end build_base_cpp_configuration( "eepp-physics" ) postsymlinklib("../libs/" .. os.get_real() .. "/", "../../bin/", "eepp-physics" ) @@ -1365,9 +1365,9 @@ solution "eepp" defines { "WINVER=0x0602" } end if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17" } + buildoptions{ "/std:c++20" } end build_base_cpp_configuration( "eterm" ) @@ -1381,9 +1381,9 @@ solution "eepp" defines { "EE_STATIC" } end if not is_vs() then - buildoptions{ "-std=c++17" } + buildoptions{ "-std=c++20" } else - buildoptions{ "/std:c++17" } + buildoptions{ "/std:c++20" } end build_base_cpp_configuration( "languages-syntax-highlighting" ) diff --git a/premake5.lua b/premake5.lua index d439f57d3..a5e85c799 100644 --- a/premake5.lua +++ b/premake5.lua @@ -144,7 +144,7 @@ function set_kind() else kind("WindowedApp") end - cppdialect "C++17" + cppdialect "C++20" end link_list = { } @@ -290,10 +290,10 @@ function build_base_cpp_configuration( package_name ) end filter "action:vs*" - buildoptions{ "/std:c++17", "/utf-8" } + buildoptions{ "/std:c++20", "/utf-8" } filter "action:not vs*" - cppdialect "C++17" + cppdialect "C++20" buildoptions { "-Wall" } filter "configurations:debug*" @@ -380,7 +380,7 @@ function build_link_configuration( package_name, use_ee_icon ) defines { "EE_TEXT_SHAPER_ENABLED" } end - cppdialect "C++17" + cppdialect "C++20" set_ios_config() set_apple_config() build_arch_configuration() @@ -412,7 +412,7 @@ function build_link_configuration( package_name, use_ee_icon ) end filter "action:vs*" - buildoptions{ "/std:c++17", "/utf-8", "/bigobj" } + buildoptions{ "/std:c++20", "/utf-8", "/bigobj" } filter "action:not vs*" buildoptions { "-Wall" } @@ -475,7 +475,7 @@ function build_link_configuration( package_name, use_ee_icon ) end filter { "action:export-compile-commands", "system:macosx" } - buildoptions { "-std=c++17" } + buildoptions { "-std=c++20" } filter {} end @@ -793,7 +793,7 @@ function build_eepp( build_name ) table.insert( link_list, get_backend_link_name( "freetype" ) ) end - cppdialect "C++17" + cppdialect "C++20" filter "options:use-frameworks" defines { "EE_USE_FRAMEWORKS" } @@ -833,10 +833,10 @@ function build_eepp( build_name ) filter "action:vs*" incdirs { "src/thirdparty/libzip/vs" } - buildoptions{ "/std:c++17", "/utf-8", "/bigobj" } + buildoptions{ "/std:c++20", "/utf-8", "/bigobj" } filter { "action:export-compile-commands", "system:macosx" } - buildoptions { "-std=c++17" } + buildoptions { "-std=c++20" } filter {} end @@ -1107,7 +1107,7 @@ workspace "eepp" project "efsw-static" kind "StaticLib" language "C++" - cppdialect "C++17" + cppdialect "C++20" incdirs { "src/thirdparty/efsw/include", "src/thirdparty/efsw/src" } files { "src/thirdparty/efsw/src/efsw/*.cpp" } build_base_cpp_configuration( "efsw" ) @@ -1153,7 +1153,7 @@ workspace "eepp" project "eepp-maps-static" kind "StaticLib" language "C++" - cppdialect "C++17" + cppdialect "C++20" incdirs { "include", "src/modules/maps/include/","src/modules/maps/src/" } files { "src/modules/maps/src/**.cpp" } defines { "EE_MAPS_STATIC" } @@ -1168,7 +1168,7 @@ workspace "eepp" project "eepp-maps" kind "SharedLib" language "C++" - cppdialect "C++17" + cppdialect "C++20" incdirs { "include", "src/modules/maps/include/","src/modules/maps/src/" } files { "src/modules/maps/src/**.cpp" } links { "eepp-shared" } @@ -1182,7 +1182,7 @@ workspace "eepp" project "eepp-physics-static" kind "StaticLib" language "C++" - cppdialect "C++17" + cppdialect "C++20" incdirs { "include", "src/modules/physics/include/","src/modules/physics/src/" } files { "src/modules/physics/src/**.cpp", "src/eepp/physics/constraints/*.cpp" } defines { "EE_PHYSICS_STATIC" } @@ -1197,7 +1197,7 @@ workspace "eepp" project "eepp-physics" kind "SharedLib" language "C++" - cppdialect "C++17" + cppdialect "C++20" incdirs { "include", "src/modules/physics/include/","src/modules/physics/src/" } files { "src/modules/physics/src/**.cpp", "src/eepp/physics/constraints/*.cpp" } links { "chipmunk-static", "eepp-shared" } @@ -1211,7 +1211,7 @@ workspace "eepp" project "eterm-static" kind "StaticLib" language "C++" - cppdialect "C++17" + cppdialect "C++20" incdirs { "include", "src/modules/eterm/include/","src/modules/eterm/src/" } files { "src/modules/eterm/src/**.cpp" } if _OPTIONS["with-static-eepp"] then @@ -1225,12 +1225,12 @@ workspace "eepp" filter "action:not vs*" buildoptions { "-Wall" } filter { "action:export-compile-commands", "system:macosx" } - buildoptions { "-std=c++17" } + buildoptions { "-std=c++20" } project "languages-syntax-highlighting-static" kind "StaticLib" language "C++" - cppdialect "C++17" + cppdialect "C++20" incdirs { "include", "src/modules/languages-syntax-highlighting/src" } files { "src/modules/languages-syntax-highlighting/src/**.cpp" } if _OPTIONS["with-static-eepp"] then @@ -1241,7 +1241,7 @@ workspace "eepp" filter "action:not vs*" buildoptions { "-Wall" } filter { "action:export-compile-commands", "system:macosx" } - buildoptions { "-std=c++17" } + buildoptions { "-std=c++20" } -- Library if not _OPTIONS["disable-static-build"] then diff --git a/src/eepp/core/string.cpp b/src/eepp/core/string.cpp index bea9c649f..8f110b9c1 100644 --- a/src/eepp/core/string.cpp +++ b/src/eepp/core/string.cpp @@ -1484,6 +1484,19 @@ String::String( const std::string& utf8String ) { Utf8::toUtf32( utf8String.begin() + skip, utf8String.end(), std::back_inserter( mString ) ); } +String::String( const std::basic_string& utf8String ) { + mString.reserve( utf8String.length() + 1 ); + + int skip = 0; + // Skip BOM + if ( utf8String.size() >= 3 && (char8_t)0xef == utf8String[0] && + (char8_t)0xbb == utf8String[1] && (char8_t)0xbf == utf8String[2] ) { + skip = 3; + } + + Utf8::toUtf32( utf8String.begin() + skip, utf8String.end(), std::back_inserter( mString ) ); +} + String::String( const std::string_view& utf8String ) { mString.reserve( utf8String.length() + 1 ); diff --git a/src/eepp/graphics/textureatlasloader.cpp b/src/eepp/graphics/textureatlasloader.cpp index 4db841552..9139a42e6 100644 --- a/src/eepp/graphics/textureatlasloader.cpp +++ b/src/eepp/graphics/textureatlasloader.cpp @@ -147,9 +147,13 @@ void TextureAtlasLoader::loadFromStream( IOStream& IOS ) { if ( !mSkipResourceLoad && NULL == tTex ) { if ( NULL != mPack ) { - mRL.add( [=] { TextureFactory::instance()->loadFromPack( mPack, path ); } ); + mRL.add( [this, path = std::move( path )] { + TextureFactory::instance()->loadFromPack( mPack, path ); + } ); } else { - mRL.add( [=] { TextureFactory::instance()->loadFromFile( path ); } ); + mRL.add( [path = std::move( path )] { + TextureFactory::instance()->loadFromFile( path ); + } ); } } diff --git a/src/eepp/system/process.cpp b/src/eepp/system/process.cpp index 4fd27afa3..9ddb942e3 100644 --- a/src/eepp/system/process.cpp +++ b/src/eepp/system/process.cpp @@ -329,7 +329,7 @@ size_t Process::readAll( std::string& buffer, bool readErr, Time timeout ) { int res = poll( &pollfd, static_cast( 1 ), 100 ); if ( res <= 0 ) { if ( ( timeout != Time::Zero && clock.getElapsedTime() >= timeout ) || - ( res < 0 && errno != EINTR ) ) + ( res < 0 && errno != EINTR ) || !isAlive() ) break; continue; } diff --git a/src/eepp/system/regex.cpp b/src/eepp/system/regex.cpp index 1b2182483..230e35082 100644 --- a/src/eepp/system/regex.cpp +++ b/src/eepp/system/regex.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -54,9 +55,9 @@ RegEx::RegEx( const std::string_view& pattern, Options options, bool useCache ) PCRE2_UCHAR buffer[256]; pcre2_get_error_message( errornumber, buffer, sizeof( buffer ) ); mValid = false; - // throw std::runtime_error( "PCRE2 compilation failed at offset " + - // std::to_string( erroroffset ) + ": " + - // reinterpret_cast( buffer ) ); + Log::debug( "PCRE2 compilation failed at offset " + std::to_string( erroroffset ) + ": " + + reinterpret_cast( buffer ) ); + return; } #if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN @@ -66,8 +67,7 @@ RegEx::RegEx( const std::string_view& pattern, Options options, bool useCache ) int rc = pcre2_pattern_info( reinterpret_cast( mCompiledPattern ), PCRE2_INFO_CAPTURECOUNT, &mCaptureCount ); if ( rc != 0 ) { - // throw std::runtime_error( "PCRE2 pattern info failed with error code " + - // std::to_string( rc ) ); + Log::debug( "PCRE2 pattern info failed with error code " + std::to_string( rc ) ); mValid = false; } else if ( useCache && RegExCache::instance()->isEnabled() ) { RegExCache::instance()->insert( pattern, options, mCompiledPattern ); diff --git a/src/eepp/ui/doc/languages/cpp.cpp b/src/eepp/ui/doc/languages/cpp.cpp index a2c06c53d..a52e01768 100644 --- a/src/eepp/ui/doc/languages/cpp.cpp +++ b/src/eepp/ui/doc/languages/cpp.cpp @@ -94,6 +94,7 @@ void addCPP() { { "bitor", "keyword" }, { "thread_local", "keyword" }, { "uint64_t", "keyword2" }, { "char32_t", "keyword2" }, { "alignas", "keyword" }, { "export", "keyword" }, + { "ssize_t", "keyword2" }, { "#if", "keyword" }, { "#ifdef", "keyword" }, { "#ifndef", "keyword" }, { "#else", "keyword" }, diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index 1c4cb0585..c8202f93f 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -626,7 +626,8 @@ bool TextDocument::loadAsyncFromURL( const std::string& url, mLoadingAsync = true; Http::getAsync( - [=]( const Http&, Http::Request&, Http::Response& response ) { + [this, onLoaded = std::move( onLoaded ), + uri = std::move( uri )]( const Http&, Http::Request&, Http::Response& response ) { if ( response.getStatus() <= Http::Response::Ok ) { std::string path( getTempPathFromURI( uri ) ); FileSystem::fileWrite( path, (const Uint8*)response.getBody().c_str(), @@ -2959,7 +2960,7 @@ TextDocument::SearchResults TextDocument::findAll( const String& text, bool case do { found = find( text, from, caseSensitive, wholeWord, type, restrictRange ); if ( found.isValid() ) { - if ( !all.empty() && all.back() == found ) + if ( !all.empty() && all.back().operator==(found) ) break; from = found.result.end(); all.push_back( found ); diff --git a/src/eepp/ui/models/filesystemmodel.cpp b/src/eepp/ui/models/filesystemmodel.cpp index 7b76db18a..ac0921e0b 100644 --- a/src/eepp/ui/models/filesystemmodel.cpp +++ b/src/eepp/ui/models/filesystemmodel.cpp @@ -202,7 +202,7 @@ bool FileSystemModel::Node::refresh( const FileSystemModel& model ) { auto files = FileSystem::filesInfoGetInPath( mInfo.getFilepath(), false, displayCfg.sortByName, displayCfg.foldersFirst, displayCfg.ignoreHidden, - [&model] { return model.mShutingDown.load( std::memory_order::memory_order_relaxed ); } ); + [&model] { return model.mShutingDown.load( std::memory_order_relaxed ); } ); std::vector newChildren; Node* node = nullptr; @@ -263,7 +263,7 @@ bool FileSystemModel::Node::traverseIfNeeded( const FileSystemModel& model ) { auto files = FileSystem::filesInfoGetInPath( mInfo.getFilepath(), false, displayCfg.sortByName, displayCfg.foldersFirst, displayCfg.ignoreHidden, - [&model] { return model.mShutingDown.load( std::memory_order::memory_order_relaxed ); } ); + [&model] { return model.mShutingDown.load( std::memory_order_relaxed ); } ); const auto& patterns = displayCfg.acceptedExtensions; bool accepted; diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp index 72c0f5341..96a404f24 100644 --- a/src/eepp/ui/uitextview.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -899,12 +899,13 @@ void UITextView::updateTextOverflow() { } UITextView* UITextView::setTextOverflow( const std::string_view& textOverflow ) { + static String EllipsisChar( u8"…"s ); // U+2026 if ( textOverflow == mTextOverflow || - ( mTextOverflow == u8"…" && textOverflow == "ellipsis"sv ) ) + ( mTextOverflow == EllipsisChar && textOverflow == "ellipsis"sv ) ) return this; if ( "ellipsis"sv == textOverflow ) { - mTextOverflow = u8"…"; // U+2026 + mTextOverflow = EllipsisChar; } else { mTextOverflow = textOverflow; } diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/v1.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/v1.cpp index d3feaf6c0..ed33ccf50 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/v1.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/v1.cpp @@ -5,39 +5,41 @@ namespace EE { namespace UI { namespace Doc { namespace Language { void addV1() { - auto& sd = SyntaxDefinitionManager::instance() - ->add( { "V1", - { "%.v1$" }, - { - { { "<%s*[sS][cC][rR][iI][pP][tT]%s+[tT][yY][pP][eE]%s*=%s*['\"]%a+/" - "[jJ][aA][vV][aA][sS][cC][rR][iI][pP][tT]['\"]%s*>", - "<%s*/[sS][cC][rR][iI][pP][tT]>" }, - "function", - "JavaScript" }, - { { "<%s*[sS][cC][rR][iI][pP][tT]%s*>", "<%s*/%s*[sS][cC][rR][iI][pP][tT]>" }, - "function", - "JavaScript" }, - { { "<%s*[sS][tT][yY][lL][eE][^>]*>", "<%s*/%s*[sS][tT][yY][lL][eE]%s*>" }, - "function", - "CSS" }, - { { "<%?v?1?", "%?>" }, "function", "V1Core" }, - { { "" }, "comment" }, - { { "%f[^>][^<]", "%f[<]" }, "normal" }, - { { "\"", "\"", "\\" }, "string" }, - { { "'", "'", "\\" }, "string" }, - { { "0x[%da-fA-F]+" }, "number" }, - { { "-?%d+[%d%.]*f?" }, "number" }, - { { "-?%.?%d+f?" }, "number" }, - { { "%f[^<]![%a_][%w%_%-]*" }, "keyword2" }, - { { "%f[^<][%a_][%w%_%-]*" }, "function" }, - { { "%f[^<]/[%a_][%w%_%-]*" }, "function" }, - { { "[%a_][%w_]*" }, "keyword" }, - { { "[/<>=]" }, "operator" }, - }, - {}, - "", - { "^#!.*[ /]v1" } } ) - .setAutoCloseXMLTags( true ); + auto& sd = + SyntaxDefinitionManager::instance() + ->add( + { "V1", + { "%.v1$" }, + { + { { "<%s*[sS][cC][rR][iI][pP][tT]%s+[tT][yY][pP][eE]%s*=%s*['\"]%a+/" + "[jJ][aA][vV][aA][sS][cC][rR][iI][pP][tT]['\"]%s*>", + "<%s*/[sS][cC][rR][iI][pP][tT]>" }, + "function", + "JavaScript" }, + { { "<%s*[sS][cC][rR][iI][pP][tT]%s*>", "<%s*/%s*[sS][cC][rR][iI][pP][tT]>" }, + "function", + "JavaScript" }, + { { "<%s*[sS][tT][yY][lL][eE][^>]*>", "<%s*/%s*[sS][tT][yY][lL][eE]%s*>" }, + "function", + "CSS" }, + { { "<%?v?1?", "%?>" }, "function", "V1Core" }, + { { "" }, "comment" }, + { { "%f[^>][^<]", "%f[<]" }, "normal" }, + { { "\"", "\"", "\\" }, "string" }, + { { "'", "'", "\\" }, "string" }, + { { "0x[%da-fA-F]+" }, "number" }, + { { "-?%d+[%d%.]*f?" }, "number" }, + { { "-?%.?%d+f?" }, "number" }, + { { "%f[^<]![%a_][%w%_%-]*" }, "keyword2" }, + { { "%f[^<][%a_][%w%_%-]*" }, "function" }, + { { "%f[^<]/[%a_][%w%_%-]*" }, "function" }, + { { "[%a_][%w_]*" }, "keyword" }, + { { "[/<>=]" }, "operator" }, + }, + {}, + "", + { "^#!.*[ /]v1" } } ) + .setAutoCloseXMLTags( true ); SyntaxDefinitionManager::instance() ->add( { "V1Core", @@ -54,50 +56,24 @@ void addV1() { { { "-?%d+[%d%.eE]*" }, "number" }, { { "-?%.?%d+" }, "number" }, { { "[%.%+%-=/%*%^%%<>!~|&]" }, "operator" }, - { { "[%a_][%w_]*%f[(]" }, "function" }, + { { "(if|for|while|foreach|switch)\\s*(?=\\()" }, + { "normal", "keyword", "keyword" }, + "", + SyntaxPatternMatchType::RegEx }, + { { "[%a_][%w_]*%s*%f[(]" }, "function" }, { { "[%a_][%w_]*" }, "symbol" }, }, - { { "return", "keyword" }, { "if", "keyword" }, - { "else", "keyword" }, { "elseif", "keyword" }, - { "endif", "keyword" }, { "declare", "keyword" }, - { "enddeclare", "keyword" }, { "switch", "keyword" }, - { "endswitch", "keyword" }, { "as", "keyword" }, - { "do", "keyword" }, { "for", "keyword" }, - { "endfor", "keyword" }, { "foreach", "keyword" }, - { "endforeach", "keyword" }, { "while", "keyword" }, - { "endwhile", "keyword" }, { "switch", "keyword" }, - { "case", "keyword" }, { "continue", "keyword" }, - { "default", "keyword" }, { "break", "keyword" }, - { "exit", "keyword" }, { "goto", "keyword" }, + { - { "catch", "keyword" }, { "throw", "keyword" }, - { "try", "keyword" }, { "finally", "keyword" }, + { "return", "keyword" }, { "if", "keyword" }, { "else", "keyword" }, + { "as", "keyword" }, { "do", "keyword" }, { "for", "keyword" }, + { "foreach", "keyword" }, { "while", "keyword" }, { "switch", "keyword" }, + { "case", "keyword" }, { "continue", "keyword" }, { "default", "keyword" }, + { "break", "keyword" }, { "exit", "keyword" }, { "function", "keyword" }, + { "global", "keyword" }, { "const", "keyword" }, { "true", "literal" }, + { "false", "literal" }, { "null", "literal" }, - { "class", "keyword" }, { "trait", "keyword" }, - { "interface", "keyword" }, { "public", "keyword" }, - { "static", "keyword" }, { "protected", "keyword" }, - { "private", "keyword" }, { "abstract", "keyword" }, - { "final", "keyword" }, - - { "function", "keyword2" }, { "global", "keyword2" }, - { "var", "keyword2" }, { "const", "keyword2" }, - { "bool", "keyword2" }, { "boolean", "keyword2" }, - { "int", "keyword2" }, { "integer", "keyword2" }, - { "real", "keyword2" }, { "double", "keyword2" }, - { "float", "keyword2" }, { "string", "keyword2" }, - { "array", "keyword2" }, { "object", "keyword2" }, - { "callable", "keyword2" }, { "iterable", "keyword2" }, - - { "namespace", "keyword2" }, { "extends", "keyword2" }, - { "implements", "keyword2" }, { "instanceof", "keyword2" }, - { "require", "keyword2" }, { "require_once", "keyword2" }, - { "include", "keyword2" }, { "include_once", "keyword2" }, - { "use", "keyword2" }, { "new", "keyword2" }, - { "clone", "keyword2" }, - - { "true", "literal" }, { "false", "literal" }, - { "NULL", "literal" }, { "parent", "literal" }, - { "self", "literal" }, { "echo", "function" } }, + }, "//", {}, "v1" } ) diff --git a/src/tests/test_all/test.cpp b/src/tests/test_all/test.cpp index 8f5729524..034df1be7 100644 --- a/src/tests/test_all/test.cpp +++ b/src/tests/test_all/test.cpp @@ -1375,7 +1375,9 @@ void EETest::loadTextures() { std::string name( files[i] ); if ( "jpg" == FileSystem::fileExtension( name ) ) { - mResLoad.add( [=] { TextureFactory::instance()->loadFromPack( PakTest, name ); } ); + mResLoad.add( [this, name = std::move( name )] { + TextureFactory::instance()->loadFromPack( PakTest, name ); + } ); } } #endif diff --git a/src/thirdparty/nanosvg/nanosvg.h b/src/thirdparty/nanosvg/nanosvg.h index b7d5f7a0d..e681444d5 100644 --- a/src/thirdparty/nanosvg/nanosvg.h +++ b/src/thirdparty/nanosvg/nanosvg.h @@ -1669,7 +1669,7 @@ static int nsvg__parseRotate(float* xform, const char* str) static void nsvg__parseTransform(float* xform, const char* str) { - float t[6]; + float t[6] = { 0, 0, 0, 0, 0, 0 }; int len; nsvg__xformIdentity(xform); while (*str) diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index af2c5be4a..073f5ad6d 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -3549,7 +3549,7 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe mThreadPool->run( [this] { // Load language definitions Clock defClock; - SyntaxDefinitionManager::createSingleton( 118 ); + SyntaxDefinitionManager::createSingleton( 119 ); Language::LanguagesSyntaxHighlighting::load(); SyntaxDefinitionManager::instance()->setLanguageExtensionsPriority( mConfig.languagesExtensions.priorities ); diff --git a/src/tools/ecode/plugins/debugger/debuggerplugin.cpp b/src/tools/ecode/plugins/debugger/debuggerplugin.cpp index e80354fce..c97dd9543 100644 --- a/src/tools/ecode/plugins/debugger/debuggerplugin.cpp +++ b/src/tools/ecode/plugins/debugger/debuggerplugin.cpp @@ -2090,7 +2090,8 @@ void DebuggerPlugin::run( const std::string& debugger, ProtocolSettings&& protoc std::function doneFn ) { if ( !FileSystem::fileExists( cmd ) ) cmd = FileSystem::fileNameFromPath( cmd ); - getUISceneNode()->runOnMainThread( [=] { + getUISceneNode()->runOnMainThread( [this, isIntegrated, cmd = std::move( cmd ), cwd, args, + doneFn = std::move( doneFn )] { if ( isIntegrated ) { UITerminal* term = getPluginContext()->getTerminalManager()->createTerminalInSplitter( diff --git a/src/tools/ecode/settingsactions.cpp b/src/tools/ecode/settingsactions.cpp index 7acf76a8d..d4c683eb4 100644 --- a/src/tools/ecode/settingsactions.cpp +++ b/src/tools/ecode/settingsactions.cpp @@ -2,6 +2,8 @@ #include "ecode.hpp" #include "version.hpp" +using namespace std::string_literals; + namespace ecode { void SettingsActions::checkForUpdatesResponse( Http::Response response, bool fromStartup ) { @@ -206,11 +208,11 @@ void SettingsActions::setIndentTabCharacter() { UIComboBox* comboBox = msgBox->getComboBox(); UIListBox* listBox = msgBox->getComboBox()->getDropDownList()->getListBox(); listBox->addClass( "indent_tab_listbox_item" ); - listBox->addListBoxItems( { u8"»", u8"→", u8"⇒", u8"↪", u8"⇢", u8"↣" } ); + listBox->addListBoxItems( { u8"»"s, u8"→"s, u8"⇒"s, u8"↪"s, u8"⇢"s, u8"↣"s } ); msgBox->getComboBox()->setText( - String::fromUtf8( mApp->getConfig().editor.tabIndentCharacter.empty() - ? u8"»" - : mApp->getConfig().editor.tabIndentCharacter ) ); + mApp->getConfig().editor.tabIndentCharacter.empty() + ? String( u8"»"s ) + : String::fromUtf8( mApp->getConfig().editor.tabIndentCharacter ) ); msgBox->showWhenReady(); comboBox->on( Event::OnValueChange, [this, comboBox]( const Event* ) { if ( comboBox->getText().size() != 1 )