mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
PowerRename: Add Lookbehind (#7571)
* Add boost-regex library * If enabled use boost lib for regex Add property `_useBoostLib` to `CPowerRenameRegEx`. If enabled for replacements with regular expressions the Boost Library is used instead of the Standard Library. * Extend signatures to create RegEx with Boost Extend create and constructor singatures of `CPowerRenameRegEx` with an option to enable (or disabled, which is default) the Boost Library. * Verify Lookbehind fails with STD library To verify that the boost library is disabled as expected, check if a lookbehind fails. * Add Unit tests for RegEx with Boost Add unit tests to verify regex replacement with Boost Library. They are copied and adapted from the Standard Library tests. * Improve verify capturing groups test with Boost It is possible to use a capturing group followed by numbers as replacement if the group number is enclosed in curly braces. Added test cases based on the Standard Library tests. * Add useBoostLib to settings interface * Get library option from settings object * Reduce signatures of RegEx by "useBoost" Remove the parameter added in 19105cf, as it became obsolete. * Settings: Read useBoostLib from JSON file * Add UseBoostLib Option to UI * Boost Lib label states the regex syntax difference * Fix Regex with Boost Lib tests - Do not load settings another time in CPowerRenameRegEx ctor - Set flag correctly in standard library regex tests * Add "lookbehind" to dictionary * change Library to lowercase, and also add a comment As suggested by @enricogior. Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com> * Change Library to lowercase and add a comment As suggested by @enricogior. Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
MaxMRUSize = 0;
|
||||
ShowIcon = false;
|
||||
ExtendedContextMenuOnly = false;
|
||||
UseBoostLib = false;
|
||||
}
|
||||
|
||||
private int _maxSize;
|
||||
@@ -48,6 +49,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
|
||||
public bool ExtendedContextMenuOnly { get; set; }
|
||||
|
||||
public bool UseBoostLib { get; set; }
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
MaxMRUSize = new IntProperty();
|
||||
ShowIcon = new BoolProperty();
|
||||
ExtendedContextMenuOnly = new BoolProperty();
|
||||
UseBoostLib = new BoolProperty();
|
||||
Enabled = new BoolProperty();
|
||||
}
|
||||
|
||||
@@ -34,5 +35,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
|
||||
[JsonPropertyName("bool_show_extended_menu")]
|
||||
public BoolProperty ExtendedContextMenuOnly { get; set; }
|
||||
|
||||
[JsonPropertyName("bool_use_boost_lib")]
|
||||
public BoolProperty UseBoostLib { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
Properties.MaxMRUSize.Value = localProperties.MaxMRUSize;
|
||||
Properties.ShowIcon.Value = localProperties.ShowIcon;
|
||||
Properties.ExtendedContextMenuOnly.Value = localProperties.ExtendedContextMenuOnly;
|
||||
Properties.UseBoostLib.Value = localProperties.UseBoostLib;
|
||||
|
||||
Version = "1";
|
||||
Name = ModuleName;
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
_powerRenameRestoreFlagsOnLaunch = Settings.Properties.PersistState.Value;
|
||||
_powerRenameMaxDispListNumValue = Settings.Properties.MaxMRUSize.Value;
|
||||
_autoComplete = Settings.Properties.MRUEnabled.Value;
|
||||
_powerRenameUseBoostLib = Settings.Properties.UseBoostLib.Value;
|
||||
_powerRenameEnabled = GeneralSettingsConfig.Enabled.PowerRename;
|
||||
}
|
||||
|
||||
@@ -76,6 +77,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
private bool _powerRenameRestoreFlagsOnLaunch;
|
||||
private int _powerRenameMaxDispListNumValue;
|
||||
private bool _autoComplete;
|
||||
private bool _powerRenameUseBoostLib;
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
@@ -199,6 +201,24 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseBoostLib
|
||||
{
|
||||
get
|
||||
{
|
||||
return _powerRenameUseBoostLib;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _powerRenameUseBoostLib)
|
||||
{
|
||||
_powerRenameUseBoostLib = value;
|
||||
Settings.Properties.UseBoostLib.Value = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetSettingsSubPath()
|
||||
{
|
||||
return _settingsConfigFileFolder + "\\" + ModuleName;
|
||||
|
||||
@@ -817,4 +817,11 @@
|
||||
<data name="FancyZones_WindowBehavior_GroupSettings.Text" xml:space="preserve">
|
||||
<value>Window behavior</value>
|
||||
</data>
|
||||
<data name="PowerRename_BehaviorHeader.Text" xml:space="preserve">
|
||||
<value>Behavior</value>
|
||||
</data>
|
||||
<data name="PowerRename_Toggle_UseBoostLib.Content" xml:space="preserve">
|
||||
<value>Use Boost library (provides extended features but may use different regex syntax)</value>
|
||||
<comment>Boost is a product name, should not be translated</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -90,6 +90,15 @@
|
||||
Margin="0, 17, 0, 0"
|
||||
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.RestoreFlagsOnLaunch}"
|
||||
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/>
|
||||
|
||||
<TextBlock x:Uid="PowerRename_BehaviorHeader"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Foreground="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled, Converter={StaticResource ModuleEnabledToForegroundConverter}}"/>
|
||||
|
||||
<CheckBox x:Uid="PowerRename_Toggle_UseBoostLib"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.UseBoostLib}"
|
||||
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user