mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Fixes in SyntaxDefinitionManager.
Make UIProperty C++17 friendly. Rename "arch" command line parameter for premake5 to "deps-arch" because it clashes with a new "arch" default parameter. Fix for empty matches in SyntaxTokenizer. Some very minor changes in language definitions.
This commit is contained in:
@@ -7,27 +7,31 @@ template <typename T> class UIProperty {
|
||||
UIProperty() {}
|
||||
|
||||
UIProperty( T defaultValue, UIWidget* widget,
|
||||
const UIDataBind<T>::Converter& converter = UIDataBind<T>::converterDefault(),
|
||||
const typename EE::UI::UIDataBind<T>::Converter& converter =
|
||||
EE::UI::UIDataBind<T>::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<UIWidget*>& widgets = {},
|
||||
const UIDataBind<T>::Converter& converter = UIDataBind<T>::converterDefault(),
|
||||
const typename EE::UI::UIDataBind<T>::Converter& converter =
|
||||
EE::UI::UIDataBind<T>::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<UIWidget*>& widgets = {},
|
||||
const UIDataBind<T>::Converter& converter = UIDataBind<T>::converterDefault(),
|
||||
const typename EE::UI::UIDataBind<T>::Converter& converter =
|
||||
EE::UI::UIDataBind<T>::converterDefault(),
|
||||
const std::string& valueKey = "value",
|
||||
const Event::EventType& eventType = Event::OnValueChange ) :
|
||||
mBindedData( &mValue, widgets, converter, valueKey, eventType ) {}
|
||||
|
||||
UIProperty( UIWidget* widget,
|
||||
const UIDataBind<T>::Converter& converter = UIDataBind<T>::converterDefault(),
|
||||
const typename EE::UI::UIDataBind<T>::Converter& converter =
|
||||
EE::UI::UIDataBind<T>::converterDefault(),
|
||||
const std::string& valueKey = "value",
|
||||
const Event::EventType& eventType = Event::OnValueChange ) :
|
||||
mBindedData( &mValue, widget, converter, valueKey, eventType ) {}
|
||||
|
||||
16
premake5.lua
16
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" }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1088,7 +1088,7 @@ void SyntaxDefinitionManager::loadFromFolder( const std::string& folderPath ) {
|
||||
|
||||
std::vector<const SyntaxDefinition*>
|
||||
SyntaxDefinitionManager::languagesThatSupportExtension( std::string extension ) const {
|
||||
std::vector<const SyntaxDefinition*> langs;
|
||||
std::unordered_set<const SyntaxDefinition*> 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<const SyntaxDefinition*> vlangs;
|
||||
vlangs.reserve( langs.size() );
|
||||
for ( const auto& l : langs )
|
||||
vlangs.push_back( l );
|
||||
return vlangs;
|
||||
}
|
||||
|
||||
bool SyntaxDefinitionManager::extensionCanRepresentManyLanguages( std::string extension ) const {
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -11,8 +11,8 @@ EE_MAIN_FUNC int main( int, char** ) {
|
||||
<TextView text="Fahrenheit" layout_height="match_parent" padding="0dp 4dp 0dp 4dp" enabled="false" />
|
||||
</hbox>
|
||||
)xml" );
|
||||
UIProperty<double> celsius( hbox->find( "celsius_input" )->setFocus()->asType<UIWidget>() );
|
||||
UIProperty<double> fahrenheit( hbox->find<UITextInput>( "fahrenheit_input" ) );
|
||||
UIProperty<double> celsius( 0, hbox->find( "celsius_input" )->setFocus()->asType<UIWidget>() );
|
||||
UIProperty<double> fahrenheit( 32, hbox->find<UITextInput>( "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();
|
||||
|
||||
@@ -27,7 +27,7 @@ SyntaxDefinition& addBrainfuck() {
|
||||
"",
|
||||
{}
|
||||
|
||||
} );
|
||||
} ).setExtensionPriority( false );
|
||||
}
|
||||
|
||||
}}}} // namespace EE::UI::Doc::Language
|
||||
|
||||
@@ -8,7 +8,7 @@ SyntaxDefinition& addGroovy() {
|
||||
auto& sd = SyntaxDefinitionManager::instance()->add(
|
||||
|
||||
{ "Groovy",
|
||||
{ "%.groovy$" },
|
||||
{ "%.groovy$", "^Jenkinsfile$" },
|
||||
{
|
||||
{ { "//.*" }, "comment" },
|
||||
{ { "/%*", "%*/" }, "comment" },
|
||||
|
||||
@@ -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" );
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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<std::string_view, 10> 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<std::string_view, 3> 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<void( UICodeEditor* codeEditor, const std::string& path )> 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 );
|
||||
|
||||
Reference in New Issue
Block a user