diff --git a/include/eepp/ui/uiproperty.hpp b/include/eepp/ui/uiproperty.hpp index 66b8352a9..60862635c 100644 --- a/include/eepp/ui/uiproperty.hpp +++ b/include/eepp/ui/uiproperty.hpp @@ -7,27 +7,31 @@ template class UIProperty { UIProperty() {} UIProperty( T defaultValue, UIWidget* widget, - const UIDataBind::Converter& converter = UIDataBind::converterDefault(), + const typename EE::UI::UIDataBind::Converter& converter = + EE::UI::UIDataBind::converterDefault(), const std::string& valueKey = "value", const Event::EventType& eventType = Event::OnValueChange ) : mValue( std::move( defaultValue ) ), mBindedData( &mValue, widget, converter, valueKey, eventType ) {} UIProperty( T defaultValue, const std::unordered_set& widgets = {}, - const UIDataBind::Converter& converter = UIDataBind::converterDefault(), + const typename EE::UI::UIDataBind::Converter& converter = + EE::UI::UIDataBind::converterDefault(), const std::string& valueKey = "value", const Event::EventType& eventType = Event::OnValueChange ) : mValue( std::move( defaultValue ) ), mBindedData( &mValue, widgets, converter, valueKey, eventType ) {} UIProperty( const std::unordered_set& widgets = {}, - const UIDataBind::Converter& converter = UIDataBind::converterDefault(), + const typename EE::UI::UIDataBind::Converter& converter = + EE::UI::UIDataBind::converterDefault(), const std::string& valueKey = "value", const Event::EventType& eventType = Event::OnValueChange ) : mBindedData( &mValue, widgets, converter, valueKey, eventType ) {} UIProperty( UIWidget* widget, - const UIDataBind::Converter& converter = UIDataBind::converterDefault(), + const typename EE::UI::UIDataBind::Converter& converter = + EE::UI::UIDataBind::converterDefault(), const std::string& valueKey = "value", const Event::EventType& eventType = Event::OnValueChange ) : mBindedData( &mValue, widget, converter, valueKey, eventType ) {} diff --git a/premake5.lua b/premake5.lua index 0f29f9f1e..5b1dd62c9 100644 --- a/premake5.lua +++ b/premake5.lua @@ -27,7 +27,7 @@ newoption { { "SDL2", "SDL2" }, } } -newoption { trigger = "arch", description = "Used exclusively to indicate premake the architecture of the dependencies that need to be downloaded" } +newoption { trigger = "deps-arch", description = "Used exclusively to indicate premake the architecture of the dependencies that need to be downloaded" } newoption { trigger = "with-static-cpp", description = "Builds statically libstdc++" } function get_dll_extension() @@ -194,7 +194,7 @@ function copy_sdl() if _OPTIONS["windows-vc-build"] then os.copyfile( _MAIN_SCRIPT_DIR .. "/src/thirdparty/" .. remote_sdl2_version .."/lib/x64/SDL2.dll", _MAIN_SCRIPT_DIR .. "/bin/SDL2.dll" ) os.copyfile( _MAIN_SCRIPT_DIR .. "/src/thirdparty/" .. remote_sdl2_version .."/lib/x64/SDL2.dll", _MAIN_SCRIPT_DIR .. "/bin/unit_tests/SDL2.dll" ) - elseif _OPTIONS["windows-mingw-build"] and _OPTIONS["arch"] ~= "arm64" then + elseif _OPTIONS["windows-mingw-build"] and _OPTIONS["deps-arch"] ~= "arm64" then os.copyfile( _MAIN_SCRIPT_DIR .. "/src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/bin/SDL2.dll", _MAIN_SCRIPT_DIR .. "/bin/SDL2.dll" ) os.copyfile( _MAIN_SCRIPT_DIR .. "/src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/bin/SDL2.dll", _MAIN_SCRIPT_DIR .. "/bin/unit_tests/SDL2.dll" ) end @@ -221,10 +221,10 @@ function download_and_extract_dependencies() if _OPTIONS["windows-vc-build"] then download_and_extract_sdl(remote_sdl2_devel_vc_url) copy_sdl() - elseif _OPTIONS["windows-mingw-build"] and _OPTIONS["arch"] ~= "arm64" then + elseif _OPTIONS["windows-mingw-build"] and _OPTIONS["deps-arch"] ~= "arm64" then download_and_extract_sdl(remote_sdl2_devel_mingw_url) copy_sdl() - elseif _OPTIONS["windows-mingw-build"] and _OPTIONS["arch"] == "arm64" then + elseif _OPTIONS["windows-mingw-build"] and _OPTIONS["deps-arch"] == "arm64" then download_and_extract_sdl(remote_sdl2_devel_src_url) elseif os.istarget("ios") then download_and_extract_sdl(remote_sdl2_devel_src_url) @@ -237,7 +237,7 @@ function build_arch_configuration() buildoptions { "-D__USE_MINGW_ANSI_STDIO=1 -B /usr/bin/i686-w64-mingw32-" } filter {"architecture:x86_64", "options:cc=mingw"} - if _OPTIONS["arch"] ~= "arm64" then + if _OPTIONS["deps-arch"] ~= "arm64" then buildoptions { "-D__USE_MINGW_ANSI_STDIO=1 -B /usr/bin/x86_64-w64-mingw32-" } end @@ -454,7 +454,7 @@ function build_link_configuration( package_name, use_ee_icon ) syslibdirs { "src/thirdparty/" .. remote_sdl2_version .."/i686-w64-mingw32/lib/", "/usr/i686-w64-mingw32/sys-root/mingw/lib/" } filter { "options:windows-mingw-build", "architecture:x86_64" } - if _OPTIONS["arch"] ~= "arm64" then + if _OPTIONS["deps-arch"] ~= "arm64" then syslibdirs { "src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/lib/", "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/" } end @@ -833,7 +833,7 @@ function build_eepp( build_name ) incdirs { "src/thirdparty/" .. remote_sdl2_version .."/i686-w64-mingw32/include/" } filter { "options:windows-mingw-build", "architecture:x86_64" } - if _OPTIONS["arch"] ~= "arm64" then + if _OPTIONS["deps-arch"] ~= "arm64" then incdirs { "src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/include/" } end @@ -1176,7 +1176,7 @@ workspace "eepp" filter { "options:windows-mingw-build", "architecture:x86" } incdirs { "src/thirdparty/" .. remote_sdl2_version .."/i686-w64-mingw32/include/" } filter { "options:windows-mingw-build", "architecture:x86_64" } - if _OPTIONS["arch"] ~= "arm64" then + if _OPTIONS["deps-arch"] ~= "arm64" then incdirs { "src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/include/" } end filter { "options:windows-mingw-build", "options:arch=arm64" } diff --git a/projects/mingw32/make.sh b/projects/mingw32/make.sh index 0b3f0acb7..8a4e88867 100755 --- a/projects/mingw32/make.sh +++ b/projects/mingw32/make.sh @@ -45,7 +45,7 @@ elif [[ "$CONFIG" == *"arm64"* && "$(uname -m)" == "x86_64" ]]; then export AR="aarch64-w64-mingw32-ar" echo "Added $BIN_PATH to PATH." - PREMAKE5_ARCH="--arch=arm64" + PREMAKE5_ARCH="--deps-arch=arm64" fi PREMAKE5_ARGS="--file=../../premake5.lua --os=windows --cc=mingw --windows-mingw-build --with-text-shaper $PREMAKE5_ARCH gmake" @@ -61,7 +61,7 @@ else fi if [[ "$CONFIG" == *"arm64"* ]]; then -bash ./build_sdl2.sh --arch=arm64 || exit 1 +bash ./build_sdl2.sh --deps-arch=arm64 || exit 1 else export CC=x86_64-w64-mingw32-gcc-posix export CXX=x86_64-w64-mingw32-g++-posix diff --git a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp index fc38a0f41..31871b853 100644 --- a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp +++ b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp @@ -1088,7 +1088,7 @@ void SyntaxDefinitionManager::loadFromFolder( const std::string& folderPath ) { std::vector SyntaxDefinitionManager::languagesThatSupportExtension( std::string extension ) const { - std::vector langs; + std::unordered_set langs; if ( extension.empty() ) return {}; @@ -1101,32 +1101,45 @@ SyntaxDefinitionManager::languagesThatSupportExtension( std::string extension ) String::endsWith( ext, "$" ) ) { LuaPattern words( ext ); int start, end; - if ( words.find( extension, start, end ) ) - langs.push_back( &definition ); + if ( words.find( extension, start, end ) ) { + langs.insert( &definition ); + break; + } } else if ( extension == ext ) { - langs.push_back( &definition ); + langs.insert( &definition ); + break; } } } for ( const auto& preDefinition : mPreDefinitions ) { for ( const auto& ext : preDefinition.getFiles() ) { + if ( std::find_if( langs.begin(), langs.end(), + [&preDefinition]( const SyntaxDefinition* sdf ) { + return preDefinition.getLanguageName() == sdf->getLanguageName(); + } ) != langs.end() ) + continue; + if ( String::startsWith( ext, "%." ) || String::startsWith( ext, "^" ) || String::endsWith( ext, "$" ) ) { LuaPattern words( ext ); int start, end; if ( words.find( extension, start, end ) ) { - langs.push_back( &preDefinition.load() ); + langs.insert( &preDefinition.load() ); break; } } else if ( extension == ext ) { - langs.push_back( &preDefinition.load() ); + langs.insert( &preDefinition.load() ); break; } } } - return langs; + std::vector vlangs; + vlangs.reserve( langs.size() ); + for ( const auto& l : langs ) + vlangs.push_back( l ); + return vlangs; } bool SyntaxDefinitionManager::extensionCanRepresentManyLanguages( std::string extension ) const { diff --git a/src/eepp/ui/doc/syntaxtokenizer.cpp b/src/eepp/ui/doc/syntaxtokenizer.cpp index c98c6bd8e..a8941c6fe 100644 --- a/src/eepp/ui/doc/syntaxtokenizer.cpp +++ b/src/eepp/ui/doc/syntaxtokenizer.cpp @@ -360,7 +360,7 @@ _tokenize( const SyntaxDefinition& syntax, const std::string& text, const Syntax if ( !words.isValid() ) // Skip invalid patterns return false; if ( words.matches( text, matches.data(), startIdx ) && - ( numMatches = words.getNumMatches() ) > 0 && matches[0].start != matches[0].end ) { + ( numMatches = words.getNumMatches() ) > 0 ) { if ( shouldCloseSubSyntax ) { if ( shouldCloseSubSyntax->range.second >= matches[0].end ) { if ( !skipSubSyntaxSeparator ) { diff --git a/src/examples/7guis/temperature_converter/temperature_converter.cpp b/src/examples/7guis/temperature_converter/temperature_converter.cpp index 2eea9eb17..a0cdee3e9 100644 --- a/src/examples/7guis/temperature_converter/temperature_converter.cpp +++ b/src/examples/7guis/temperature_converter/temperature_converter.cpp @@ -11,8 +11,8 @@ EE_MAIN_FUNC int main( int, char** ) { )xml" ); - UIProperty celsius( hbox->find( "celsius_input" )->setFocus()->asType() ); - UIProperty fahrenheit( hbox->find( "fahrenheit_input" ) ); + UIProperty celsius( 0, hbox->find( "celsius_input" )->setFocus()->asType() ); + UIProperty fahrenheit( 32, hbox->find( "fahrenheit_input" ) ); celsius.changed( [&fahrenheit]( auto c ) { fahrenheit = c * 9 / 5 + 32; } ); fahrenheit.changed( [&celsius]( auto f ) { celsius = ( f - 32 ) * 5 / 9; } ); return app.run(); diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/brainfuck.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/brainfuck.cpp index a5c979e1a..6507c13fb 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/brainfuck.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/brainfuck.cpp @@ -27,7 +27,7 @@ SyntaxDefinition& addBrainfuck() { "", {} - } ); + } ).setExtensionPriority( false ); } }}}} // namespace EE::UI::Doc::Language diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/groovy.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/groovy.cpp index b1f349219..5b71b7f7f 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/groovy.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/groovy.cpp @@ -8,7 +8,7 @@ SyntaxDefinition& addGroovy() { auto& sd = SyntaxDefinitionManager::instance()->add( { "Groovy", - { "%.groovy$" }, + { "%.groovy$", "^Jenkinsfile$" }, { { { "//.*" }, "comment" }, { { "/%*", "%*/" }, "comment" }, diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/shellscript.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/shellscript.cpp index c566a8e69..74a251e9f 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/shellscript.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/shellscript.cpp @@ -10,7 +10,7 @@ SyntaxDefinition& addShellScript() { { "Shell script", { "%.sh$", "%.bash$", "^%.bashrc$", "^%.bash_profile$", "^%.profile$", "%.zsh$", - "%.fish$", "^PKGBUILD$", "%.winlib$" }, + "%.fish$", "^PKGBUILD$", "%.winlib$", "^APKBUILD$" }, { { { "$[%a_@*#][%w_]*" }, "type" }, { { "#.*\n" }, "comment" }, @@ -52,9 +52,10 @@ SyntaxDefinition& addShellScript() { }, "#", - { "^#!.*[ /]bash", "^#!.*[ /]sh" }, + { "^#!.*[ /]bash", "^#!.*[ /]sh", "^#!.*[ /]zsh", "^#!.*[ /]fish" }, "shellscript" } ) .addAlternativeName( "bash" ) + .addAlternativeName( "fish" ) .addAlternativeName( "zsh" ) .addAlternativeName( "sh" ); } diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp index 346ac7d32..96df53b9f 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp @@ -337,7 +337,7 @@ void LanguagesSyntaxHighlighting::load() { sdm->addPreDefinition( { "Groovy", []() -> SyntaxDefinition& { return addGroovy(); }, - { "%.groovy$" }, + { "%.groovy$", "^Jenkinsfile$" }, } ); sdm->addPreDefinition( { @@ -572,10 +572,10 @@ void LanguagesSyntaxHighlighting::load() { sdm->addPreDefinition( { "Shell script", []() -> SyntaxDefinition& { return addShellScript(); }, { "%.sh$", "%.bash$", "^%.bashrc$", "^%.bash_profile$", "^%.profile$", - "%.zsh$", "%.fish$", "^PKGBUILD$", "%.winlib$" }, - { "^#!.*[ /]bash", "^#!.*[ /]sh" }, + "%.zsh$", "%.fish$", "^PKGBUILD$", "%.winlib$", "^APKBUILD$" }, + { "^#!.*[ /]bash", "^#!.*[ /]sh", "^#!.*[ /]zsh", "^#!.*[ /]fish" }, "shellscript", - { "bash", "zsh", "sh" } } ); + { "bash", "zsh", "sh", "fish" } } ); sdm->addPreDefinition( { "SmallBASIC", diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 4afff6135..6ef1968a6 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -2238,11 +2238,29 @@ void App::loadImageFromPath( const std::string& path ) { loadImageFromMedium( path, false ); } +static bool isVideoExtension( std::string_view ext ) { + static constexpr std::array videoExtensions = { + "mp4", "mov", "mkv", "avi", "wmv", "webm", "flv", "mpg", "mpeg", "m4v" }; + for ( const auto& videoExt : videoExtensions ) + if ( String::iequals( ext, videoExt ) ) + return true; + return false; +} + +static bool isDocumentExtension( std::string_view ext ) { + static constexpr std::array videoExtensions = { "doc", "docx", "pdf" }; + for ( const auto& videoExt : videoExtensions ) + if ( String::iequals( ext, videoExt ) ) + return true; + return false; +} + bool App::loadFileFromPath( std::string path, bool inNewTab, UICodeEditor* codeEditor, std::function onLoaded ) { + std::string ext = FileSystem::fileExtension( path ); - if ( FileSystem::fileExtension( path ) == "lnk" ) { + if ( ext == "lnk" ) { auto target = Sys::getShortcutTarget( path ); if ( !target.empty() ) { if ( FileSystem::fileExists( target ) ) @@ -2253,8 +2271,9 @@ bool App::loadFileFromPath( return false; } - if ( Image::isImageExtension( path ) && Image::isImage( path ) && - FileSystem::fileExtension( path ) != "svg" ) { + if ( isVideoExtension( ext ) || isDocumentExtension( ext ) ) { + Engine::instance()->openURI( path ); + } else if ( Image::isImageExtension( path ) && Image::isImage( path ) && ext != "svg" ) { loadImageFromPath( path ); } else { UITab* tab = mSplitter->isDocumentOpen( path );