[PowerRename] Add option for Capitalization (#10213)

* Add camelcase instances + helper translation

* Add camel case testing

* Update Helpers.cpp

* Update PowerRenameUI.cpp

* Update src/modules/powerrename/ui/PowerRenameUI.cpp

Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>

* Change camel case to capitalized, move ui

* Update PowerRenameManagerTests.cpp

* Update PowerRenameUI.base.rc

* Update PowerRenameUI.base.rc

Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
This commit is contained in:
Clare DuVal
2021-04-09 08:24:06 -04:00
committed by GitHub
parent c08be14919
commit 0a6de4561f
9 changed files with 75 additions and 8 deletions

View File

@@ -159,6 +159,42 @@ HRESULT GetTransformedFileName(_Out_ PWSTR result, UINT cchMax, _In_ PCWSTR sour
{
hr = StringCchCopy(result, cchMax, source);
}
}
else if (flags & Capitalized)
{
if (!(flags & ExtensionOnly))
{
std::wstring stem = fs::path(source).stem().wstring();
std::wstring extension = fs::path(source).extension().wstring();
size_t stemLength = stem.length();
while (stemLength > 0 && (iswspace(stem[stemLength - 1]) || iswpunct(stem[stemLength - 1])))
{
stemLength--;
}
for (size_t i = 0; i < stemLength; i++)
{
if (!i || iswspace(stem[i - 1]) || iswpunct(stem[i - 1]))
{
if (iswspace(stem[i]) || iswpunct(stem[i]))
{
continue;
}
stem[i] = towupper(stem[i]);
}
else
{
stem[i] = towlower(stem[i]);
}
}
hr = StringCchPrintf(result, cchMax, L"%s%s", stem.c_str(), extension.c_str());
}
else
{
hr = StringCchCopy(result, cchMax, source);
}
}
else
{