microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.35k stars 6.55k forks source link

[PowerRename] Regex help in UI: Add ^, $, .* #35847

Open htcfreek opened 3 days ago

htcfreek commented 3 days ago

Description of the new feature / enhancement

Adding the following syntax to the regex help flyout in the PowerRename window will be helpful for users that have not so much knowledge about regex:

Scenario when this would be used?

We sometimes get issues asking how to add text to the start or end of a file name without replacing explicit characters. (Example issue: #35797)

Supporting information

No response

ms-10-us commented 3 days ago

Can I work on this issue? Please let me know. Thanks!

htcfreek commented 3 days ago

@ms-10-us Your contribution is welcome and thank you for your work on this. Feel free to open a PR. If you have any further questions don't worry to ask them.

ms-10-us commented 3 days ago

@htcfreek

I am a new developer. I have lots of questions about this project. I need to know which code to work on and where to insert my code. I am also facing some problems understanding the feature itself. I would really appreciate it if someone can please help with those questions. I am open to any suggestions from anyone. Thanks!

htcfreek commented 3 days ago

@ms-10-us The feature in the ui is a simple flyout that show some syntax examples as help. (Or do you mean the regex function itself?)

The list seems to be auto generated based on a data object. You have to update the following two places:

https://github.com/microsoft/PowerToys/blob/main/src%2Fmodules%2Fpowerrename%2FPowerRenameUILib%2FPowerRenameXAML%2FMainWindow.xaml.cpp#L173-L179

https://github.com/microsoft/PowerToys/blob/main/src%2Fmodules%2Fpowerrename%2FPowerRenameUILib%2FStrings%2Fen-us%2FResources.resw

I hope this helps so far and answers your questions.

musabaku commented 2 days ago

@htcfreek , Can I provide the current assignee with an example of how I think one part of the solution may look like @ms-10-us

m_searchRegExShortcuts.Append(winrt::make<PatternSnippet>(L"^", manager.MainResourceMap().GetValue(L"Resources/RegExCheatSheet_StartOfString").ValueAsString()));

In MainWindow.xaml.cpp file

<data name="RegExCheatSheet_StartOfString" xml:space="preserve">
    <value>Start of the string (use ^)</value>
</data>

In Resources.resw file

ms-10-us commented 2 days ago

Hello @musabaku , @htcfreek

Thank you for your help. I am facing problems with C++ library.

Image

Do you happen to know how to fix this issue? I will include the tasks.json c_cpp_properites.json , and launch.json files.

Any help is greatly appreciated.

Thanks!

c_cpp_properties.json launch.json tasks.json

htcfreek commented 2 days ago

@ms-10-us Maybe some file paths are to long. And I suggest to not open the solution from an OneDrive path (see your screenshot).

There is no reason why some files should missing as you only edit existing ones. And by the way, you should edit the resource strings using the resw editor in vs. Please don't edit the xml code manually.

If you stopped a running build in the past maybe git clean -xfd helps to fix broken build artifacts.

And last but not least: If you think your code changes are all done you can open a (draft) PR. Then we can see if it is a local problem and builds on our CI pipeline or not.