Skip to content

Commit

Permalink
[submodules] Updated scintilla
Browse files Browse the repository at this point in the history
- Added lexilla as a separate submodule.
- Replaced scintilla mirror.
- Fixed scintilla editor.
  • Loading branch information
TheQwertiest committed May 10, 2023
1 parent d93eaa6 commit c9d8d83
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 138 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Expand Up @@ -12,7 +12,7 @@
url = https://github.com/TheQwertiest/smp_2003.git
[submodule "submodules/scintilla"]
path = submodules/scintilla
url = https://github.com/theqwertiest/scintilla.git
url = https://github.com/theqwertiest/scintilla_hg.git
[submodule "submodules/pfc"]
path = submodules/pfc
url = https://github.com/TheQwertiest/pfc.git
Expand All @@ -39,3 +39,6 @@
[submodule "submodules/fb2k_utils"]
path = submodules/fb2k_utils
url = https://github.com/TheQwertiest/fb2k_utils.git
[submodule "submodules/lexilla"]
path = submodules/lexilla
url = https://github.com/ScintillaOrg/lexilla.git
13 changes: 7 additions & 6 deletions foo_spider_monkey_panel/foo_spider_monkey_panel.vcxproj
Expand Up @@ -37,7 +37,7 @@
<ImportGroup Label="Shared">
<Import Project="$(SolutionDir)\..\submodules\wtl\wtl.vcxitems" Label="Shared" />
<Import Project="$(SolutionDir)\..\mozjs\Debug\mozjs_debug.vcxitems" Condition="'$(Configuration)'=='Debug'" Label="Shared" />
<Import Project="$(SolutionDir)\..\mozjs\Debug\mozjs_release.vcxitems" Condition="'$(Configuration)'=='Release'" Label="Shared" />
<Import Project="$(SolutionDir)\..\mozjs\Release\mozjs_release.vcxitems" Condition="'$(Configuration)'=='Release'" Label="Shared" />
<Import Project="$(SolutionDir)\..\PropertyList\property_list.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
Expand All @@ -50,8 +50,9 @@
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\fmt.props" />
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\foobar2000_sdk.props" />
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\json.props" />
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\range.props" />
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\lexilla.props" />
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\pfc.props" />
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\range.props" />
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\scintilla.props" />
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\timsort.props" />
<Import Project="$(QwrFb2kUtilsPropsDir)submodules\wtl.props" />
Expand Down Expand Up @@ -134,13 +135,13 @@
<ProjectReference Include="..\submodules\foobar2000\SDK\foobar2000_SDK.vcxproj">
<Project>{e8091321-d79d-4575-86ef-064ea1a4a20d}</Project>
</ProjectReference>
<ProjectReference Include="..\submodules\lexilla\src\Lexilla.vcxproj">
<Project>{7ca4bbc9-83ca-42be-84bb-8a98368fabab}</Project>
</ProjectReference>
<ProjectReference Include="..\submodules\pfc\pfc.vcxproj">
<Project>{ebfffb4e-261d-44d3-b89c-957b31a0bf9c}</Project>
</ProjectReference>
<ProjectReference Include="..\submodules\scintilla\lexilla\src\lexilla.vcxproj">
<Project>{7ca4bbc9-83ca-42be-84bb-8a98368fabab}</Project>
</ProjectReference>
<ProjectReference Include="..\submodules\scintilla\win32\scintilla.vcxproj">
<ProjectReference Include="..\submodules\scintilla\win32\Scintilla.vcxproj">
<Project>{10b2a7ef-9089-4352-ba26-7e9aef50987d}</Project>
</ProjectReference>
</ItemGroup>
Expand Down
48 changes: 26 additions & 22 deletions foo_spider_monkey_panel/ui/scintilla/ui_sci_editor.cpp
Expand Up @@ -9,6 +9,7 @@
#include <utils/logging.h>
#include <utils/resource_helpers.h>

#include <qwr/algorithm.h>
#include <qwr/fb2k_paths.h>
#include <qwr/file_helpers.h>
#include <qwr/string_helpers.h>
Expand Down Expand Up @@ -217,8 +218,8 @@ ScintillaStyle ParseStyle( qwr::u8string_view p_definition )

template <typename T>

requires qwr::is_any_same_v<typename T::value_type, qwr::u8string, qwr::u8string_view, const char*>
qwr::u8string JoinWithSpace( const T& cont )
requires qwr::is_any_same_v<typename T::value_type, qwr::u8string, qwr::u8string_view, const char*>
qwr::u8string JoinWithSpace( const T& cont )
{
qwr::u8string words_str;
words_str.reserve( cont.size() * 6 );
Expand Down Expand Up @@ -577,9 +578,15 @@ void CScriptEditorCtrl::SetJScript()

void CScriptEditorCtrl::ReloadScintillaSettings()
{
for ( const auto& prop: config::sci::props.val() )
{
SetProperty( prop.key.c_str(), prop.val.c_str() );
// save all properties
const auto& cfgProps = config::sci::props.val();
nameToPropValue_ = cfgProps | ranges::views::transform( []( const auto& elem ) {
return std::make_pair( elem.key, elem.val );
} )
| ranges::to<decltype( nameToPropValue_ )>();
for ( const auto& [key, value]: nameToPropValue_ )
{ // processes only built-in properties
SetProperty( key.c_str(), value.c_str() );
}

auto getIntFromProp = [&]( const std::string& propName ) -> std::optional<int> {
Expand Down Expand Up @@ -1241,11 +1248,6 @@ void CScriptEditorCtrl::Init()
// Auto complete
AutoCSetIgnoreCase( true );

// Set embedded properties
SetProperty( "dir.base", ( qwr::path::Foobar2000() / "" ).u8string().c_str() );
SetProperty( "dir.component", ( qwr::path::Component() / "" ).u8string().c_str() );
SetProperty( "dir.profile", ( qwr::path::Profile() / "" ).u8string().c_str() );

// Load properties
ReloadScintillaSettings();
}
Expand Down Expand Up @@ -1448,20 +1450,22 @@ void CScriptEditorCtrl::SetIndentation( int line, int indent )
SetSel( crange.cpMin, crange.cpMax );
}

std::optional<qwr::u8string> CScriptEditorCtrl::GetPropertyExpanded_Opt( const char* key )
std::optional<qwr::u8string> CScriptEditorCtrl::GetPropertyExpanded_Opt( std::string_view key )
{
int len = GetPropertyExpanded( key, nullptr );
if ( !len )
{
return std::nullopt;
}
if ( int len = GetPropertyExpanded( key.data(), nullptr ) )
{ // search built-in properties first
qwr::u8string propval;
propval.resize( len + 1 );
GetPropertyExpanded( key.data(), propval.data() );
propval.resize( strlen( propval.c_str() ) );

qwr::u8string propval;
propval.resize( len + 1 );
GetPropertyExpanded( key, propval.data() );
propval.resize( strlen( propval.c_str() ) );

return propval;
return propval;
}
else
{ // and custom afterwards
const auto propvalOpt = qwr::FindAsOptional( nameToPropValue_, key );
return ( propvalOpt && !propvalOpt->empty() ? propvalOpt : std::nullopt );
}
}

} // namespace smp::ui::sci
11 changes: 5 additions & 6 deletions foo_spider_monkey_panel/ui/scintilla/ui_sci_editor.h
Expand Up @@ -8,15 +8,12 @@
#include <ui/scintilla/ui_sci_goto.h>
#include <ui/scintilla/wtlscintilla.h>

#include <qwr/unordered_map.h>

#include <optional>
#include <set>
#include <span>

namespace smp::config::sci
{
struct ScintillaProp;
}

namespace smp::ui::sci
{

Expand Down Expand Up @@ -80,6 +77,7 @@ class CScriptEditorCtrl
, style( style )
{
}

qwr::u8string value;
int style;
};
Expand Down Expand Up @@ -108,7 +106,7 @@ class CScriptEditorCtrl
std::optional<std::vector<qwr::u8string_view>> GetNearestWords( qwr::u8string_view wordPart, std::optional<char> separator = std::nullopt );
std::optional<qwr::u8string_view> GetFullDefinitionForWord( qwr::u8string_view word );
void SetIndentation( int line, int indent );
std::optional<qwr::u8string> GetPropertyExpanded_Opt( const char* key );
std::optional<qwr::u8string> GetPropertyExpanded_Opt( std::string_view key );

private:
int m_nBraceCount = 0;
Expand All @@ -121,6 +119,7 @@ class CScriptEditorCtrl
qwr::u8string m_szFunctionDefinition;

std::set<qwr::u8string, KeyWordComparator> m_apis;
qwr::UnorderedStrMap<qwr::u8string, qwr::u8string> nameToPropValue_;
};

} // namespace smp::ui::sci
6 changes: 0 additions & 6 deletions foo_spider_monkey_panel/ui/scintilla/wtlscintilla.h
Expand Up @@ -1823,12 +1823,6 @@ class CScintillaImpl : public CWindowImpl<T, TBase, TWinTraits>
return ::SendMessage( this->m_hWnd, SCI_GETLEXER, 0, 0L );
}

void SetLexer( int nLexer )
{
ATLASSERT( ::IsWindow( this->m_hWnd ) );
::SendMessage( this->m_hWnd, SCI_SETLEXER, nLexer, 0L );
}

void SetILexer( Scintilla::ILexer5* pLexer )
{
ATLASSERT( ::IsWindow( this->m_hWnd ) );
Expand Down
27 changes: 14 additions & 13 deletions scripts/additional_files/lexilla.vcxproj
Expand Up @@ -33,33 +33,34 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Label="UserMacros">
<QwrTempDir>$(SolutionDir)..\_result\$(Platform)_$(Configuration)\temp\$(Configuration)\$(ProjectName)\</QwrTempDir>
<QwrLibDir>$(SolutionDir)..\_result\$(Platform)_$(Configuration)\lib\</QwrLibDir>
<QwrDebugMacro Condition="'$(Configuration)'=='Debug'">DEBUG=1</QwrDebugMacro >
<QwrDebugMacro Condition="'$(Configuration)'=='Release'"></QwrDebugMacro>
</PropertyGroup>
<PropertyGroup>
<OutDir>$(ProjectDir)..\..\bin\</OutDir>
<NMakeOutput>$(ProjectDir)..\..\bin\liblexilla.lib</NMakeOutput>
<OutDir>$(QwrTempDir)</OutDir>
<NMakeOutput>$(QwrLibDir)liblexilla.lib</NMakeOutput>
<NMakeBuildCommandLine>nmake $(QwrDebugMacro) QWR_TEMPDIR=$(QwrTempDir) QWR_BINDIR=$(QwrLibDir) -f lexilla.mak</NMakeBuildCommandLine>
<NMakeCleanCommandLine>$(NMakeBuildCommandLine) clean</NMakeCleanCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeBuildCommandLine>nmake DEBUG=1 -f lexilla.mak</NMakeBuildCommandLine>
<NMakeCleanCommandLine>$(NMakeBuildCommandLine) clean</NMakeCleanCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeBuildCommandLine>nmake -f lexilla.mak</NMakeBuildCommandLine>
<NMakeCleanCommandLine>$(NMakeBuildCommandLine) clean</NMakeCleanCommandLine>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\lexers\*.cxx" />
<ClCompile Include="..\..\lexlib\*.cxx" />
<ClCompile Include="..\..\src\*.cxx" />
<ClCompile Include="..\lexers\*.cxx" />
<ClCompile Include="..\lexlib\*.cxx" />
<ClCompile Include="*.cxx" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\*.h" />
<ClInclude Include="..\..\src\*.h" />
<ClInclude Include="..\..\lexlib\*.h" />
<ClInclude Include="..\include\*.h" />
<ClInclude Include="..\lexlib\*.h" />
<ClInclude Include="*.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
17 changes: 10 additions & 7 deletions scripts/additional_files/scintilla.vcxproj
Expand Up @@ -33,20 +33,23 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Label="UserMacros">
<QwrTempDir>$(SolutionDir)..\_result\$(Platform)_$(Configuration)\temp\$(Configuration)\$(ProjectName)\</QwrTempDir>
<QwrLibDir>$(SolutionDir)..\_result\$(Platform)_$(Configuration)\lib\</QwrLibDir>
<QwrDebugMacro Condition="'$(Configuration)'=='Debug'">DEBUG=1</QwrDebugMacro >
<QwrDebugMacro Condition="'$(Configuration)'=='Release'"></QwrDebugMacro>
</PropertyGroup>
<PropertyGroup>
<OutDir>$(ProjectDir)..\bin\</OutDir>
<NMakeOutput>$(ProjectDir)..\bin\libscintilla.lib</NMakeOutput>
<OutDir>$(QwrTempDir)</OutDir>
<NMakeOutput>$(QwrLibDir)libscintilla.lib</NMakeOutput>
<NMakeBuildCommandLine>nmake $(QwrDebugMacro) QWR_TEMPDIR=$(QwrTempDir) QWR_BINDIR=$(QwrLibDir) -f scintilla.mak</NMakeBuildCommandLine>
<NMakeCleanCommandLine>$(NMakeBuildCommandLine) clean</NMakeCleanCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeBuildCommandLine>nmake DEBUG=1 -f scintilla.mak</NMakeBuildCommandLine>
<NMakeCleanCommandLine>$(NMakeBuildCommandLine) clean</NMakeCleanCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeBuildCommandLine>nmake -f scintilla.mak</NMakeBuildCommandLine>
<NMakeCleanCommandLine>$(NMakeBuildCommandLine) clean</NMakeCleanCommandLine>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
Expand Down
26 changes: 26 additions & 0 deletions scripts/configure_lexilla.py
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

import subprocess
from pathlib import Path

import call_wrapper

def configure():
cur_dir = Path(__file__).parent.absolute()
root_dir = cur_dir.parent
lexilla_dir = root_dir/"submodules"/"lexilla"
assert(lexilla_dir.exists() and lexilla_dir.is_dir())
lexers_dir = lexilla_dir/"lexers"

for lexer in lexers_dir.glob("*"):
if (lexer.name != "LexCPP.cxx" ):
lexer.unlink()

subprocess.check_call("py LexillaGen.py", cwd=lexilla_dir/"scripts", shell=True)

if __name__ == '__main__':
call_wrapper.final_call_decorator(
"Configuring Lexilla",
"Configuring Lexilla: success",
"Configuring Lexilla: failure!"
)(configure)()
6 changes: 0 additions & 6 deletions scripts/configure_scintilla.py
Expand Up @@ -10,14 +10,8 @@ def configure():
root_dir = cur_dir.parent
scintilla_dir = root_dir/"submodules"/"scintilla"
assert(scintilla_dir.exists() and scintilla_dir.is_dir())
lexers_dir = scintilla_dir/"lexers"

for lexer in lexers_dir.glob("*"):
if (lexer.name != "LexCPP.cxx" ):
lexer.unlink()

subprocess.check_call("py LexGen.py", cwd=scintilla_dir/"scripts", shell=True)
subprocess.check_call("py LexillaGen.py", cwd=scintilla_dir/"lexilla"/"scripts", shell=True)

if __name__ == '__main__':
call_wrapper.final_call_decorator(
Expand Down
72 changes: 72 additions & 0 deletions scripts/patches/lexilla.patch
@@ -0,0 +1,72 @@
diff --git a/submodules/lexilla/src/lexilla.mak b/submodules/lexilla/src/lexilla.mak
index b04551a0..8109b685 100644
--- a/submodules/lexilla/src/lexilla.mak
+++ b/submodules/lexilla/src/lexilla.mak
@@ -10,8 +10,8 @@

.SUFFIXES: .cxx

-DIR_O=.
-DIR_BIN=..\bin
+DIR_O=$(QWR_TEMPDIR)
+DIR_BIN=$(QWR_BINDIR)

LEXILLA=$(DIR_BIN)\lexilla.dll
LIBLEXILLA=$(DIR_BIN)\liblexilla.lib
@@ -40,8 +40,12 @@ CXXFLAGS=-Zi -TP -MP -W4 -EHsc -std:c++17 $(CRTFLAGS)
CXXDEBUG=-Od -MTd -DDEBUG
CXXNDEBUG=-O2 -MT -DNDEBUG -GL
NAME=-Fo
-LDFLAGS=-OPT:REF -LTCG -IGNORE:4197 -DEBUG $(SUBSYSTEM) $(CETCOMPAT)
+LDFLAGS=-OPT:REF -IGNORE:4197 -DEBUG $(SUBSYSTEM) $(CETCOMPAT)
LDDEBUG=
+LDRELEASE=-LTCG
+LIBFLAGS=
+LIBDEBUG=
+LIBRELEASE=/LTCG
LIBS=
NOLOGO=-nologo

@@ -54,8 +58,11 @@ LDFLAGS=$(LDFLAGS) $(NOLOGO)
!IFDEF DEBUG
CXXFLAGS=$(CXXFLAGS) $(CXXDEBUG)
LDFLAGS=$(LDDEBUG) $(LDFLAGS)
+LIBFLAGS=$(LIBDEBUG) $(LIBFLAGS)
!ELSE
CXXFLAGS=$(CXXFLAGS) $(CXXNDEBUG)
+LDFLAGS=$(LDRELEASE) $(LDFLAGS)
+LIBFLAGS=$(LIBRELEASE) $(LIBFLAGS)
!ENDIF

SCINTILLA_INCLUDE = ../../scintilla/include
@@ -63,7 +70,7 @@ SCINTILLA_INCLUDE = ../../scintilla/include
INCLUDEDIRS=-I../include -I$(SCINTILLA_INCLUDE) -I../src -I../lexlib
CXXFLAGS=$(CXXFLAGS) $(INCLUDEDIRS)

-all: $(SCINTILLA_INCLUDE) $(LEXILLA) $(LIBLEXILLA)
+all: $(DIR_O) $(DIR_BIN) $(SCINTILLA_INCLUDE) $(LEXILLA) $(LIBLEXILLA)

clean:
-del /q $(DIR_O)\*.obj $(DIR_O)\*.o $(DIR_O)\*.pdb \
@@ -73,6 +80,12 @@ clean:
depend:
pyw DepGen.py

+$(DIR_O):
+ -@ if NOT EXIST $(DIR_O) mkdir $(DIR_O)
+
+$(DIR_BIN):
+ -@ if NOT EXIST $(DIR_BIN) mkdir $(DIR_BIN)
+
$(SCINTILLA_INCLUDE):
@echo Scintilla must be installed at ../../scintilla to provide access to Scintilla headers.

@@ -107,7 +120,7 @@ $(LEXILLA): $(LEXILLA_OBJS) LexillaVersion.res
$(LD) $(LDFLAGS) -DEF:Lexilla.def -DLL -OUT:$@ $** $(LIBS)

$(LIBLEXILLA): $(LEXILLA_OBJS)
- LIB -OUT:$@ $**
+ LIB $(LIBFLAGS) -OUT:$@ $**

# Define how to build all the objects and what they depend on

0 comments on commit c9d8d83

Please sign in to comment.