mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
[PowerRename] upper/lower/titlecase transform feature (#4183)
* Add basic transform functionality * Add basic transform functionality * Change toupper/tolower/isspace to towupper/towlower/towisspace. For loops omitted if possible. * Avoid wcslen() in for statement * Avoid wcslen() in for statement * Add basic transform functionality * Change toupper/tolower/isspace to towupper/towlower/towisspace. For loops omitted if possible. * Avoid wcslen() in for statement * Avoid wcslen() in for statement * Add basic transform functionality * Change toupper/tolower/isspace to towupper/towlower/towisspace. For loops omitted if possible. * Avoid wcslen() in for statement * Adjust Powerrename Interface * Add trimming rename string * Remove leading and trailing spaces from rename string * Add support for transforming only item name or extension. Temporarily remove trimming to refactor. Change CAPITALIZED to TITLECASE * Fix bug when search for area is empty * Add trimming back with refactor(leading spaces, trailing spaces, trailing dots) * Now supports transforming when search area is empty * Add smarter titlecase Transformation breaks when new filename contains an unusable character (\/?:*?"<>|) These characters need to be removed from new name anyway. * minor bugfix * Add unittests, contains failing tests * Remove unnecessary/failing tests * remove generated file * some code formatting and fix memory leak issues * Use proper allocation, change int to size_t * Refactor. Move transforming to Helpers.cpp * Refactor. Move trimming to Helpers.cpp * Change StrDup to SHStrDup. Some refactoring. * Fix memery leak, add proper result controls, use newNameToUse in functon calls becaause it is where the final form of the string is tracked * Change declarations of strings, add proper result controls * Slightly widen the labels to cover the whole text * Add extended characters support * Rename a variable * Correctly identify the last word for titlecase * Add empty line to last line of resource.h
This commit is contained in:
committed by
GitHub
parent
e8685de7f7
commit
30f442d774
@@ -229,5 +229,57 @@ namespace PowerRenameManagerTests
|
||||
|
||||
RenameHelper(renamePairs, ARRAYSIZE(renamePairs), L"foo", L"bar", DEFAULT_FLAGS | ExcludeSubfolders);
|
||||
}
|
||||
|
||||
TEST_METHOD (VerifyUppercaseTransform)
|
||||
{
|
||||
rename_pairs renamePairs[] = {
|
||||
{ L"foo", L"BAR", true, true, 0 },
|
||||
{ L"foo.test", L"BAR.TEST", true, true, 0 },
|
||||
{ L"TEST", L"TEST_norename", true, false, 0 }
|
||||
};
|
||||
|
||||
RenameHelper(renamePairs, ARRAYSIZE(renamePairs), L"foo", L"bar", DEFAULT_FLAGS | Uppercase);
|
||||
}
|
||||
|
||||
TEST_METHOD (VerifyLowercaseTransform)
|
||||
{
|
||||
rename_pairs renamePairs[] = {
|
||||
{ L"Foo", L"bar", false, true, 0 },
|
||||
{ L"Foo.teST", L"bar.test", false, true, 0 },
|
||||
{ L"test", L"test_norename", false, false, 0 }
|
||||
};
|
||||
|
||||
RenameHelper(renamePairs, ARRAYSIZE(renamePairs), L"foo", L"bar", DEFAULT_FLAGS | Lowercase);
|
||||
}
|
||||
|
||||
TEST_METHOD (VerifyTitlecaseTransform)
|
||||
{
|
||||
rename_pairs renamePairs[] = {
|
||||
{ L"foo and the to", L"Bar and the To", false, true, 0 },
|
||||
{ L"Test", L"Test_norename", false, false, 0 }
|
||||
};
|
||||
|
||||
RenameHelper(renamePairs, ARRAYSIZE(renamePairs), L"foo", L"bar", DEFAULT_FLAGS | Titlecase);
|
||||
}
|
||||
|
||||
TEST_METHOD (VerifyNameOnlyTransform)
|
||||
{
|
||||
rename_pairs renamePairs[] = {
|
||||
{ L"foo.txt", L"BAR.txt", false, true, 0 },
|
||||
{ L"TEST", L"TEST_norename", false, false, 1 }
|
||||
};
|
||||
|
||||
RenameHelper(renamePairs, ARRAYSIZE(renamePairs), L"foo", L"bar", DEFAULT_FLAGS | Uppercase | NameOnly);
|
||||
}
|
||||
|
||||
TEST_METHOD (VerifyExtensionOnlyTransform)
|
||||
{
|
||||
rename_pairs renamePairs[] = {
|
||||
{ L"foo.FOO", L"foo.bar", false, true, 0 },
|
||||
{ L"foo.bar", L"foo.bar_rename", false, false, 0 }
|
||||
};
|
||||
|
||||
RenameHelper(renamePairs, ARRAYSIZE(renamePairs), L"foo", L"bar", DEFAULT_FLAGS | Lowercase | ExtensionOnly);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user