Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plugin pipeline aliases or simple plugins to be registered in the GUI #2257

Merged
merged 52 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
b07bbbb
WIP
sdottaka Mar 15, 2024
e31defb
WIP
sdottaka Mar 16, 2024
fe3fd88
WIP
sdottaka Mar 17, 2024
2729a96
WIP
sdottaka Mar 17, 2024
a7d5c99
WIP
sdottaka Mar 17, 2024
6ec39d4
Merge branch 'master' into add-plugin-pipepline-alias
sdottaka Mar 18, 2024
30119a3
WIP
sdottaka Mar 18, 2024
b7de88d
WIP
sdottaka Mar 19, 2024
1226129
WIP
sdottaka Mar 20, 2024
c431ab9
Merge remote-tracking branch 'origin/master' into add-plugin-pipeplin…
sdottaka Mar 20, 2024
38659ae
Merge branch 'master' into add-plugin-pipepline-alias
sdottaka Mar 20, 2024
4cad1c7
WIP
sdottaka Mar 21, 2024
2473ee9
WIP
sdottaka Mar 21, 2024
d95aa7f
WIP
sdottaka Mar 23, 2024
0d51e8b
WIP
sdottaka Mar 24, 2024
d6a7116
WIP
sdottaka Mar 24, 2024
ffc2dda
Merge branch 'master' into add-plugin-pipepline-alias
sdottaka Mar 24, 2024
55081bf
WIP
sdottaka Mar 26, 2024
f34d21d
WIP
sdottaka Mar 27, 2024
4953d52
WIP
sdottaka Mar 28, 2024
8da16f6
WIP
sdottaka Mar 29, 2024
6eb6808
WIP
sdottaka Mar 30, 2024
d53d437
Merge remote-tracking branch 'origin/master' into add-plugin-pipeplin…
sdottaka Mar 31, 2024
e0cd9b5
WIP
sdottaka Mar 31, 2024
d619ae1
Merge branch 'master' into add-plugin-pipepline-alias
sdottaka Mar 31, 2024
1384203
WIP
sdottaka Apr 1, 2024
a8cb9ea
WIP
sdottaka Apr 1, 2024
e2cf164
WIP
sdottaka Apr 2, 2024
ee53ac6
WIP
sdottaka Apr 3, 2024
bcee84c
WIP
sdottaka Apr 4, 2024
377b6f8
Merge branch 'master' into add-plugin-pipepline-alias
sdottaka Apr 4, 2024
97b9f92
WIP
sdottaka Apr 5, 2024
92822a8
WIP
sdottaka Apr 7, 2024
7a7f500
WIP
sdottaka Apr 8, 2024
3c9b41e
WIP
sdottaka Apr 9, 2024
3d327a1
WIP
sdottaka Apr 10, 2024
1977fca
WIP
sdottaka Apr 11, 2024
2d16625
WIP
sdottaka Apr 11, 2024
ad4019c
Merge branch 'master' into add-plugin-pipepline-alias
sdottaka Apr 13, 2024
3230302
WIP
sdottaka Apr 13, 2024
c3dd084
WIP
sdottaka Apr 13, 2024
1d06072
WIP
sdottaka Apr 14, 2024
6317a60
WIP
sdottaka Apr 14, 2024
f3d7254
WIP
sdottaka Apr 15, 2024
6d45c2b
WIP
sdottaka Apr 15, 2024
4b2e130
WIP
sdottaka Apr 16, 2024
f835ea2
WIP
sdottaka Apr 18, 2024
a3b6f57
WIP
sdottaka Apr 18, 2024
e5ad2cf
WIP
sdottaka Apr 19, 2024
5d6e86b
WIP
sdottaka Apr 19, 2024
749c706
WIP
sdottaka Apr 20, 2024
84386d5
WIP
sdottaka Apr 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions Src/ConfigLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,34 +112,23 @@ void CConfigLog::WritePluginsInLogFile(const wchar_t *transformationEvent)
{
const PluginInfoPtr& plugin = piPluginArray->at(iPlugin);
String sPluginText;
if (plugin->m_filepath.find(':') != String::npos)
{
String sFileName = paths::GetLongPath(plugin->m_filepath);
if (sFileName.length() > sEXEPath.length())
if (sFileName.substr(0, sEXEPath.length()) == sEXEPath)
sFileName = _T(".") + sFileName.erase(0, sEXEPath.length());

String sModifiedTime = _T("");
sModifiedTime = GetLastModified(plugin->m_filepath);
if (!sModifiedTime.empty())
sModifiedTime = _T("[") + sModifiedTime + _T("]");

sPluginText = strutils::format
(_T("\r\n %s%-36s path=%s %s"),
plugin->m_disabled ? _T("!") : _T(" "),
plugin->m_name,
sFileName,
sModifiedTime
);
}
else
{
sPluginText = strutils::format
(_T("\r\n %s%-36s"),
plugin->m_disabled ? _T("!") : _T(" "),
plugin->m_name
);
}
String sFileName = paths::GetLongPath(plugin->m_filepath);
if (sFileName.length() > sEXEPath.length())
if (sFileName.substr(0, sEXEPath.length()) == sEXEPath)
sFileName = _T(".") + sFileName.erase(0, sEXEPath.length());

String sModifiedTime = _T("");
sModifiedTime = GetLastModified(plugin->m_filepath);
if (!sModifiedTime.empty())
sModifiedTime = _T("[") + sModifiedTime + _T("]");

sPluginText = strutils::format
(_T("\r\n %s%-36s path=%s %s"),
plugin->m_disabled ? _T("!") : _T(" "),
plugin->m_name,
sFileName,
sModifiedTime
);
m_pfile->WriteString(sPluginText);
}
}
Expand Down Expand Up @@ -403,11 +392,14 @@ bool CConfigLog::DoFile(String &sError)
WritePluginsInLogFile(L"FILE_PACK_UNPACK");
WritePluginsInLogFile(L"BUFFER_PACK_UNPACK");
WritePluginsInLogFile(L"FILE_FOLDER_PACK_UNPACK");
WritePluginsInLogFile(L"ALIAS_PACK_UNPACK");
FileWriteString(_T("\r\n Prediffers: "));
WritePluginsInLogFile(L"FILE_PREDIFF");
WritePluginsInLogFile(L"BUFFER_PREDIFF");
WritePluginsInLogFile(L"ALIAS_PREDIFF");
FileWriteString(_T("\r\n Editor scripts: "));
WritePluginsInLogFile(L"EDITOR_SCRIPT");
WritePluginsInLogFile(L"ALIAS_EDITOR_SCRIPT");
if (!plugin::IsWindowsScriptThere())
FileWriteString(_T("\r\n .sct scripts disabled (Windows Script Host not found)\r\n"));

Expand Down
44 changes: 41 additions & 3 deletions Src/FileTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,49 @@ String PluginForFile::MakeArguments(const std::vector<String>& args, const std::
return newstr;
}

static std::vector<PluginForFile::PipelineItem>
ExpandAliases(const String& pluginPipeline, const String& filteredFilenames, const wchar_t* aliasEvent, String& errorMessage, int stack = 0)
{
std::vector<PluginForFile::PipelineItem> pipelineResolved;
auto parseResult = PluginForFile::ParsePluginPipeline(pluginPipeline, errorMessage);
if (!errorMessage.empty())
return pipelineResolved;
for (auto& item : parseResult)
{
PluginInfo* plugin = nullptr;
if (item.name == _T("<Automatic>") || item.name == _("<Automatic>"))
plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(aliasEvent, filteredFilenames);
else
plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(aliasEvent, item.name);
if (plugin)
{
if (stack > 20)
{
errorMessage = strutils::format_string1(_("Circular reference in plugin pipeline: %1"), pluginPipeline);
return pipelineResolved;
}
String pipeline = plugin->m_pipeline;
Fixed Show fixed Hide fixed
for (size_t i = 0; i < 9; ++i)
strutils::replace(pipeline, _T("${") + strutils::to_str(i + 1) + _T("}"), (i < item.args.size()) ? item.args[i] : _T(""));
String args = PluginForFile::MakeArguments(item.args, {});
strutils::replace(pipeline, _T("${*}"), args);
auto parseResult2 = ExpandAliases(pipeline, filteredFilenames, aliasEvent, errorMessage, stack + 1);
if (!errorMessage.empty())
return pipelineResolved;
for (auto& item2 : parseResult2)
pipelineResolved.push_back(item2);
}
else
pipelineResolved.push_back(item);
}
return pipelineResolved;
}

bool PackingInfo::GetPackUnpackPlugin(const String& filteredFilenames, bool bUrl, bool bReverse,
std::vector<std::tuple<PluginInfo*, std::vector<String>, bool>>& plugins,
String *pPluginPipelineResolved, String *pURLHandlerResolved, String& errorMessage) const
{
auto result = ParsePluginPipeline(errorMessage);
auto result = ExpandAliases(this->m_PluginPipeline, filteredFilenames, L"ALIAS_PACK_UNPACK", errorMessage);
if (!errorMessage.empty())
return false;
if (bUrl)
Expand Down Expand Up @@ -518,7 +556,7 @@ bool PrediffingInfo::GetPrediffPlugin(const String& filteredFilenames, bool bRev
std::vector<std::tuple<PluginInfo*, std::vector<String>, bool>>& plugins,
String *pPluginPipelineResolved, String& errorMessage) const
{
auto result = ParsePluginPipeline(errorMessage);
auto result = ExpandAliases(this->m_PluginPipeline, filteredFilenames, L"ALIAS_PREDIFF", errorMessage);
if (!errorMessage.empty())
return false;
std::vector<PluginForFile::PipelineItem> pipelineResolved;
Expand Down Expand Up @@ -656,7 +694,7 @@ bool PrediffingInfo::Prediffing(String & filepath, const String& filteredText, b
bool EditorScriptInfo::GetEditorScriptPlugin(std::vector<std::tuple<PluginInfo*, std::vector<String>, int>>& plugins,
String& errorMessage) const
{
auto result = ParsePluginPipeline(errorMessage);
auto result = ExpandAliases(this->m_PluginPipeline, _T(""), L"ALIAS_EDITOR_SCRIPT", errorMessage);
if (!errorMessage.empty())
return false;
for (auto& [pluginName, args, quoteChar] : result)
Expand Down
6 changes: 3 additions & 3 deletions Src/FileTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ std::pair<
>
CreatePluginMenuInfos(const String& filteredFilenames, const std::vector<std::wstring>& events, unsigned baseId);

inline const std::vector<std::wstring> UnpackerEventNames = { L"BUFFER_PACK_UNPACK", L"FILE_PACK_UNPACK", L"FILE_FOLDER_PACK_UNPACK" };
inline const std::vector<std::wstring> PredifferEventNames = { L"BUFFER_PREDIFF", L"FILE_PREDIFF" };
inline const std::vector<std::wstring> EditorScriptEventNames = { L"EDITOR_SCRIPT" };
inline const std::vector<std::wstring> UnpackerEventNames = { L"BUFFER_PACK_UNPACK", L"FILE_PACK_UNPACK", L"FILE_FOLDER_PACK_UNPACK", L"ALIAS_PACK_UNPACK" };
inline const std::vector<std::wstring> PredifferEventNames = { L"BUFFER_PREDIFF", L"FILE_PREDIFF", L"ALIAS_PREDIFF" };
inline const std::vector<std::wstring> EditorScriptEventNames = { L"EDITOR_SCRIPT", L"ALIAS_EDITOR_SCRIPT" };

}
Loading
Loading