Skip to content

A Swiss Army knife for developers.

Added options to Regex Tester tool (#42)

Etienne Baudouxeeab922141f3
diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.cs
index 4117c10cf..4946e62ef 100644
--- a/src/dev/impl/DevToys/LanguageManager.cs
+++ b/src/dev/impl/DevToys/LanguageManager.cs
@@ -589,16 +589,96 @@ namespace DevToys
{
private readonly ResourceLoader _resources = ResourceLoader.GetForViewIndependentUse("RegEx");
+ /// <summary>
+ /// Gets the resource Configuration.
+ /// </summary>
+ public string Configuration => _resources.GetString("Configuration");
+
+ /// <summary>
+ /// Gets the resource CultureInvariant.
+ /// </summary>
+ public string CultureInvariant => _resources.GetString("CultureInvariant");
+
+ /// <summary>
+ /// Gets the resource CultureInvariantDescription.
+ /// </summary>
+ public string CultureInvariantDescription => _resources.GetString("CultureInvariantDescription");
+
/// <summary>
/// Gets the resource DisplayName.
/// </summary>
public string DisplayName => _resources.GetString("DisplayName");
+ /// <summary>
+ /// Gets the resource EcmaScript.
+ /// </summary>
+ public string EcmaScript => _resources.GetString("EcmaScript");
+
+ /// <summary>
+ /// Gets the resource EcmaScriptDescription.
+ /// </summary>
+ public string EcmaScriptDescription => _resources.GetString("EcmaScriptDescription");
+
+ /// <summary>
+ /// Gets the resource IgnoreCase.
+ /// </summary>
+ public string IgnoreCase => _resources.GetString("IgnoreCase");
+
+ /// <summary>
+ /// Gets the resource IgnoreCaseDescription.
+ /// </summary>
+ public string IgnoreCaseDescription => _resources.GetString("IgnoreCaseDescription");
+
+ /// <summary>
+ /// Gets the resource IgnoreWhitespace.
+ /// </summary>
+ public string IgnoreWhitespace => _resources.GetString("IgnoreWhitespace");
+
+ /// <summary>
+ /// Gets the resource IgnoreWhitespaceDescription.
+ /// </summary>
+ public string IgnoreWhitespaceDescription => _resources.GetString("IgnoreWhitespaceDescription");
+
+ /// <summary>
+ /// Gets the resource Multiline.
+ /// </summary>
+ public string Multiline => _resources.GetString("Multiline");
+
+ /// <summary>
+ /// Gets the resource MultilineDescription.
+ /// </summary>
+ public string MultilineDescription => _resources.GetString("MultilineDescription");
+
+ /// <summary>
+ /// Gets the resource Options.
+ /// </summary>
+ public string Options => _resources.GetString("Options");
+
/// <summary>
/// Gets the resource RegularExpression.
/// </summary>
public string RegularExpression => _resources.GetString("RegularExpression");
+ /// <summary>
+ /// Gets the resource RightToLeft.
+ /// </summary>
+ public string RightToLeft => _resources.GetString("RightToLeft");
+
+ /// <summary>
+ /// Gets the resource RightToLeftDescription.
+ /// </summary>
+ public string RightToLeftDescription => _resources.GetString("RightToLeftDescription");
+
+ /// <summary>
+ /// Gets the resource Singleline.
+ /// </summary>
+ public string Singleline => _resources.GetString("Singleline");
+
+ /// <summary>
+ /// Gets the resource SinglelineDescription.
+ /// </summary>
+ public string SinglelineDescription => _resources.GetString("SinglelineDescription");
+
/// <summary>
/// Gets the resource Text.
/// </summary>
diff --git a/src/dev/impl/DevToys/Strings/en/RegEx.resw b/src/dev/impl/DevToys/Strings/en/RegEx.resw
index 67fc5511b..14cdb6410 100644
--- a/src/dev/impl/DevToys/Strings/en/RegEx.resw
+++ b/src/dev/impl/DevToys/Strings/en/RegEx.resw
@@ -117,12 +117,60 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <data name="Configuration" xml:space="preserve">
+ <value>Configuration</value>
+ </data>
+ <data name="CultureInvariant" xml:space="preserve">
+ <value>Culture Invariant</value>
+ </data>
+ <data name="CultureInvariantDescription" xml:space="preserve">
+ <value>Specifies that cultural differences in language is ignored.</value>
+ </data>
<data name="DisplayName" xml:space="preserve">
<value>Regex Tester</value>
</data>
+ <data name="EcmaScript" xml:space="preserve">
+ <value>ECMA Script</value>
+ </data>
+ <data name="EcmaScriptDescription" xml:space="preserve">
+ <value>Enables ECMAScript-compliant behavior for the expression. This value can be used only in conjunction with the Culture Invariant, Ignore Case and Multiline options.</value>
+ </data>
+ <data name="IgnoreCase" xml:space="preserve">
+ <value>Ignore Case</value>
+ </data>
+ <data name="IgnoreCaseDescription" xml:space="preserve">
+ <value>Specifies case-insensitive matching.</value>
+ </data>
+ <data name="IgnoreWhitespace" xml:space="preserve">
+ <value>Ignore Whitespace</value>
+ </data>
+ <data name="IgnoreWhitespaceDescription" xml:space="preserve">
+ <value>Eliminates unescaped white space from the pattern and enables comments marked with #. However, this value does not affect or eliminate white space in character classes, numeric quantifiers, or tokens that mark the beginning of individual regular expression language elements.</value>
+ </data>
+ <data name="Multiline" xml:space="preserve">
+ <value>Multiline</value>
+ </data>
+ <data name="MultilineDescription" xml:space="preserve">
+ <value>Changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string.</value>
+ </data>
+ <data name="Options" xml:space="preserve">
+ <value>Options</value>
+ </data>
<data name="RegularExpression" xml:space="preserve">
<value>Regular expression</value>
</data>
+ <data name="RightToLeft" xml:space="preserve">
+ <value>Right To Left</value>
+ </data>
+ <data name="RightToLeftDescription" xml:space="preserve">
+ <value>Specifies that the search will be from right to left instead of from left to right.</value>
+ </data>
+ <data name="Singleline" xml:space="preserve">
+ <value>Singleline</value>
+ </data>
+ <data name="SinglelineDescription" xml:space="preserve">
+ <value>Changes the meaning of the dot (.) so it matches every character (instead of every character except \n).</value>
+ </data>
<data name="Text" xml:space="preserve">
<value>Text</value>
</data>
diff --git a/src/dev/impl/DevToys/Strings/fr/RegEx.resw b/src/dev/impl/DevToys/Strings/fr/RegEx.resw
index 669319777..dc5d98a0d 100644
--- a/src/dev/impl/DevToys/Strings/fr/RegEx.resw
+++ b/src/dev/impl/DevToys/Strings/fr/RegEx.resw
@@ -117,12 +117,60 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <data name="Configuration" xml:space="preserve">
+ <value>Configuration</value>
+ </data>
+ <data name="CultureInvariant" xml:space="preserve">
+ <value>Culture Indépendente</value>
+ </data>
+ <data name="CultureInvariantDescription" xml:space="preserve">
+ <value>Indique que les différences culturelles dans la langue ne sont pas prises en compte.</value>
+ </data>
<data name="DisplayName" xml:space="preserve">
<value>Testeur de RegEx</value>
</data>
+ <data name="EcmaScript" xml:space="preserve">
+ <value>ECMA Script</value>
+ </data>
+ <data name="EcmaScriptDescription" xml:space="preserve">
+ <value>Active un comportement conforme ECMAScript pour l’expression. Cette valeur ne peut être utilisée qu'en conjonction avec les options Culture Indépendente, Ignorer la Casse et Multiligne.</value>
+ </data>
+ <data name="IgnoreCase" xml:space="preserve">
+ <value>Ignorer la Casse</value>
+ </data>
+ <data name="IgnoreCaseDescription" xml:space="preserve">
+ <value>Spécifie la correspondance qui ne respecte pas la casse.</value>
+ </data>
+ <data name="IgnoreWhitespace" xml:space="preserve">
+ <value>Ignorer les Espaces Blancs</value>
+ </data>
+ <data name="IgnoreWhitespaceDescription" xml:space="preserve">
+ <value>Élimine l'espace blanc sans séquence d'échappement du modèle et active les commentaires marqués avec #. Cependant, cette valeur n’affecte ni n’élimine l’espace blanc dans les classes de caractères, les quantificateurs numériques ou les jetons qui marquent le début d’éléments de langage d’expression régulière.</value>
+ </data>
+ <data name="Multiline" xml:space="preserve">
+ <value>Multiligne</value>
+ </data>
+ <data name="MultilineDescription" xml:space="preserve">
+ <value>Modifie la signification de ^ et $ de sorte qu'ils correspondent respectivement au début et à la fin de n'importe quelle ligne, et non simplement au début et à la fin de la chaîne entière.</value>
+ </data>
+ <data name="Options" xml:space="preserve">
+ <value>Options</value>
+ </data>
<data name="RegularExpression" xml:space="preserve">
<value>Expression regulière</value>
</data>
+ <data name="RightToLeft" xml:space="preserve">
+ <value>Droite à Gauche</value>
+ </data>
+ <data name="RightToLeftDescription" xml:space="preserve">
+ <value>Spécifie que la recherche sera effectuée de droite à gauche et non de gauche à droite.</value>
+ </data>
+ <data name="Singleline" xml:space="preserve">
+ <value>Singleline</value>
+ </data>
+ <data name="SinglelineDescription" xml:space="preserve">
+ <value>Modifie la signification du point (.) de sorte qu'il corresponde à chaque caractère (et non à chaque caractère sauf \n).</value>
+ </data>
<data name="Text" xml:space="preserve">
<value>Texte</value>
</data>
diff --git a/src/dev/impl/DevToys/Strings/ru/RegEx.resw b/src/dev/impl/DevToys/Strings/ru/RegEx.resw
index 15207eecb..3e8965549 100644
--- a/src/dev/impl/DevToys/Strings/ru/RegEx.resw
+++ b/src/dev/impl/DevToys/Strings/ru/RegEx.resw
@@ -117,12 +117,60 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <data name="Configuration" xml:space="preserve">
+ <value>Configuration</value>
+ </data>
+ <data name="CultureInvariant" xml:space="preserve">
+ <value>Culture Invariant</value>
+ </data>
+ <data name="CultureInvariantDescription" xml:space="preserve">
+ <value>Specifies that cultural differences in language is ignored.</value>
+ </data>
<data name="DisplayName" xml:space="preserve">
<value>Проверка регулярных выражений</value>
</data>
+ <data name="EcmaScript" xml:space="preserve">
+ <value>ECMA Script</value>
+ </data>
+ <data name="EcmaScriptDescription" xml:space="preserve">
+ <value>Enables ECMAScript-compliant behavior for the expression. This value can be used only in conjunction with the Culture Invariant, Ignore Case and Multiline options.</value>
+ </data>
+ <data name="IgnoreCase" xml:space="preserve">
+ <value>Ignore Case</value>
+ </data>
+ <data name="IgnoreCaseDescription" xml:space="preserve">
+ <value>Specifies case-insensitive matching.</value>
+ </data>
+ <data name="IgnoreWhitespace" xml:space="preserve">
+ <value>Ignore Whitespace</value>
+ </data>
+ <data name="IgnoreWhitespaceDescription" xml:space="preserve">
+ <value>Eliminates unescaped white space from the pattern and enables comments marked with #. However, this value does not affect or eliminate white space in character classes, numeric quantifiers, or tokens that mark the beginning of individual regular expression language elements.</value>
+ </data>
+ <data name="Multiline" xml:space="preserve">
+ <value>Multiline</value>
+ </data>
+ <data name="MultilineDescription" xml:space="preserve">
+ <value>Changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string.</value>
+ </data>
+ <data name="Options" xml:space="preserve">
+ <value>Options</value>
+ </data>
<data name="RegularExpression" xml:space="preserve">
<value>Регулярное выражение</value>
</data>
+ <data name="RightToLeft" xml:space="preserve">
+ <value>Right To Left</value>
+ </data>
+ <data name="RightToLeftDescription" xml:space="preserve">
+ <value>Specifies that the search will be from right to left instead of from left to right.</value>
+ </data>
+ <data name="Singleline" xml:space="preserve">
+ <value>Singleline</value>
+ </data>
+ <data name="SinglelineDescription" xml:space="preserve">
+ <value>Changes the meaning of the dot (.) so it matches every character (instead of every character except \n).</value>
+ </data>
<data name="Text" xml:space="preserve">
<value>Текст</value>
</data>
diff --git a/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml b/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml
index fe9532cd0..332d55deb 100644
--- a/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml
+++ b/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml
@@ -9,6 +9,7 @@
xmlns:converters="using:DevToys.UI.Converters"
mc:Ignorable="d"
HorizontalAlignment="Stretch"
+ CornerRadius="{ThemeResource ControlCornerRadius}"
d:DesignHeight="300"
d:DesignWidth="400">
<UserControl.Resources>
@@ -16,13 +17,11 @@
<converters:NullToBooleanConverter x:Key="NullToFalseConverter" IsInverted="True"/>
<Style x:Key="GridSettingBlockStyle" TargetType="Grid">
- <Setter Property="Background" Value="{ThemeResource ExpanderHeaderBackground}" />
<Setter Property="BorderBrush" Value="{ThemeResource ExpanderHeaderBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ExpanderHeaderBorderThickness}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="MinHeight" Value="{StaticResource ExpanderMinHeight}" />
<Setter Property="Padding" Value="{StaticResource ExpanderContentPadding}" />
- <Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
</Style>
</UserControl.Resources>
@@ -37,6 +36,9 @@
HorizontalContentAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch"
+ Padding="0"
+ Background="{x:Bind ContentBackground, Mode=OneWay}"
+ CornerRadius="{x:Bind CornerRadius}"
IsExpanded="{x:Bind IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<muxc:Expander.Header>
<local:ExpandableSettingHeaderControl
@@ -57,7 +59,9 @@
<Grid
x:Name="NonExpanderGrid"
x:Load="{x:Bind ExpandableContent, Mode=OneWay, Converter={StaticResource NullToTrueConverter}}"
- Style="{StaticResource GridSettingBlockStyle}">
+ Style="{StaticResource GridSettingBlockStyle}"
+ Background="{x:Bind HeaderBackground, Mode=OneWay}"
+ CornerRadius="{x:Bind CornerRadius}">
<local:ExpandableSettingHeaderControl
Title="{x:Bind Title, Mode=OneWay}"
Description="{x:Bind Description, Mode=OneWay}"
diff --git a/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml.cs b/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml.cs
index 130f92593..34adeba79 100644
--- a/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml.cs
+++ b/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml.cs
@@ -3,6 +3,7 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Markup;
+using Windows.UI.Xaml.Media;
namespace DevToys.UI.Controls
{
@@ -76,6 +77,32 @@ namespace DevToys.UI.Controls
set => SetValue(IsExpandedProperty, value);
}
+ public static readonly DependencyProperty ContentBackgroundProperty
+ = DependencyProperty.Register(
+ nameof(ContentBackground),
+ typeof(Brush),
+ typeof(ExpandableSettingControl),
+ new PropertyMetadata(Application.Current.Resources["ExpanderContentBackground"]));
+
+ public Brush ContentBackground
+ {
+ get => (Brush)GetValue(ContentBackgroundProperty);
+ set => SetValue(ContentBackgroundProperty, value);
+ }
+
+ public static readonly DependencyProperty HeaderBackgroundProperty
+ = DependencyProperty.Register(
+ nameof(HeaderBackground),
+ typeof(Brush),
+ typeof(ExpandableSettingControl),
+ new PropertyMetadata(Application.Current.Resources["ExpanderHeaderBackground"]));
+
+ public Brush HeaderBackground
+ {
+ get => (Brush)GetValue(HeaderBackgroundProperty);
+ set => SetValue(HeaderBackgroundProperty, value);
+ }
+
public ExpandableSettingControl()
{
InitializeComponent();
diff --git a/src/dev/impl/DevToys/UI/Controls/ExpandableSettingHeaderControl.xaml b/src/dev/impl/DevToys/UI/Controls/ExpandableSettingHeaderControl.xaml
index 54ffc3f02..68d2a7302 100644
--- a/src/dev/impl/DevToys/UI/Controls/ExpandableSettingHeaderControl.xaml
+++ b/src/dev/impl/DevToys/UI/Controls/ExpandableSettingHeaderControl.xaml
@@ -40,7 +40,7 @@
<ContentPresenter
x:Name="SettingIconElement"
Margin="2,0,20,0"
- x:Load="{x:Bind Icon, Mode=OneWay, Converter={StaticResource NullToFalseConverter}}"
+ Width="20"
Content="{x:Bind Icon, Mode=OneWay}" />
<Grid
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolViewModel.cs
index aadbcff84..4c9cfab27 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolViewModel.cs
@@ -1,5 +1,6 @@
#nullable enable
+using DevToys.Api.Core.Settings;
using DevToys.Api.Tools;
using DevToys.Core.Threading;
using DevToys.UI.Controls;
@@ -17,6 +18,48 @@ namespace DevToys.ViewModels.Tools.RegEx
[Export(typeof(RegExToolViewModel))]
public sealed class RegExToolViewModel : ObservableRecipient, IToolViewModel
{
+ private static readonly SettingDefinition<bool> IgnoreCaseSetting
+ = new(
+ name: $"{nameof(RegExToolViewModel)}.{nameof(IgnoreCaseSetting)}",
+ isRoaming: true,
+ defaultValue: false);
+
+ private static readonly SettingDefinition<bool> IgnoreWhitespaceSetting
+ = new(
+ name: $"{nameof(RegExToolViewModel)}.{nameof(IgnoreWhitespaceSetting)}",
+ isRoaming: true,
+ defaultValue: false);
+
+ private static readonly SettingDefinition<bool> CultureInvariantSetting
+ = new(
+ name: $"{nameof(RegExToolViewModel)}.{nameof(CultureInvariantSetting)}",
+ isRoaming: true,
+ defaultValue: false);
+
+ private static readonly SettingDefinition<bool> SinglelineSetting
+ = new(
+ name: $"{nameof(RegExToolViewModel)}.{nameof(SinglelineSetting)}",
+ isRoaming: true,
+ defaultValue: false);
+
+ private static readonly SettingDefinition<bool> MultilineSetting
+ = new(
+ name: $"{nameof(RegExToolViewModel)}.{nameof(MultilineSetting)}",
+ isRoaming: true,
+ defaultValue: false);
+
+ private static readonly SettingDefinition<bool> RightToLeftSetting
+ = new(
+ name: $"{nameof(RegExToolViewModel)}.{nameof(RightToLeftSetting)}",
+ isRoaming: true,
+ defaultValue: false);
+
+ private static readonly SettingDefinition<bool> EcmaScriptSetting
+ = new(
+ name: $"{nameof(RegExToolViewModel)}.{nameof(EcmaScriptSetting)}",
+ isRoaming: true,
+ defaultValue: false);
+
private readonly Queue<(string pattern, string text)> _regExMatchingQueue = new();
private bool _calculationInProgress;
@@ -27,6 +70,106 @@ namespace DevToys.ViewModels.Tools.RegEx
internal RegExStrings Strings => LanguageManager.Instance.RegEx;
+ internal ISettingsProvider SettingsProvider { get; }
+
+ internal bool IgnoreCase
+ {
+ get => SettingsProvider.GetSetting(IgnoreCaseSetting);
+ set
+ {
+ if (SettingsProvider.GetSetting(IgnoreCaseSetting) != value)
+ {
+ SettingsProvider.SetSetting(IgnoreCaseSetting, value);
+ OnPropertyChanged();
+ QueueRegExMatch();
+ }
+ }
+ }
+
+ internal bool IgnoreWhitespace
+ {
+ get => SettingsProvider.GetSetting(IgnoreWhitespaceSetting);
+ set
+ {
+ if (SettingsProvider.GetSetting(IgnoreWhitespaceSetting) != value)
+ {
+ SettingsProvider.SetSetting(IgnoreWhitespaceSetting, value);
+ OnPropertyChanged();
+ QueueRegExMatch();
+ }
+ }
+ }
+
+ internal bool CultureInvariant
+ {
+ get => SettingsProvider.GetSetting(CultureInvariantSetting);
+ set
+ {
+ if (SettingsProvider.GetSetting(CultureInvariantSetting) != value)
+ {
+ SettingsProvider.SetSetting(CultureInvariantSetting, value);
+ OnPropertyChanged();
+ QueueRegExMatch();
+ }
+ }
+ }
+
+ internal bool Singleline
+ {
+ get => SettingsProvider.GetSetting(SinglelineSetting);
+ set
+ {
+ if (SettingsProvider.GetSetting(SinglelineSetting) != value)
+ {
+ SettingsProvider.SetSetting(SinglelineSetting, value);
+ OnPropertyChanged();
+ QueueRegExMatch();
+ }
+ }
+ }
+
+ internal bool Multiline
+ {
+ get => SettingsProvider.GetSetting(MultilineSetting);
+ set
+ {
+ if (SettingsProvider.GetSetting(MultilineSetting) != value)
+ {
+ SettingsProvider.SetSetting(MultilineSetting, value);
+ OnPropertyChanged();
+ QueueRegExMatch();
+ }
+ }
+ }
+
+ internal bool RightToLeft
+ {
+ get => SettingsProvider.GetSetting(RightToLeftSetting);
+ set
+ {
+ if (SettingsProvider.GetSetting(RightToLeftSetting) != value)
+ {
+ SettingsProvider.SetSetting(RightToLeftSetting, value);
+ OnPropertyChanged();
+ QueueRegExMatch();
+ }
+ }
+ }
+
+ internal bool EcmaScript
+ {
+ get => SettingsProvider.GetSetting(EcmaScriptSetting);
+ set
+ {
+ if (SettingsProvider.GetSetting(EcmaScriptSetting) != value)
+ {
+ SettingsProvider.SetSetting(EcmaScriptSetting, value);
+ OnPropertyChanged();
+ QueueRegExMatch();
+ }
+ }
+ }
+
internal string? RegularExpression
{
get => _regularExpression;
@@ -49,6 +192,12 @@ namespace DevToys.ViewModels.Tools.RegEx
internal ICustomTextBox? MatchTextBox { private get; set; }
+ [ImportingConstructor]
+ public RegExToolViewModel(ISettingsProvider settingsProvider)
+ {
+ SettingsProvider = settingsProvider;
+ }
+
private void QueueRegExMatch()
{
_regExMatchingQueue.Enqueue(new(RegularExpression ?? string.Empty, Text ?? string.Empty));
@@ -74,7 +223,7 @@ namespace DevToys.ViewModels.Tools.RegEx
{
string pattern = data.pattern.Trim('/');
- var regex = new Regex(data.pattern, RegexOptions.Multiline);
+ var regex = new Regex(data.pattern, GetOptions());
MatchCollection matches = regex.Matches(data.text.Replace("\r\n", "\r"));
foreach (Match match in matches)
@@ -104,5 +253,40 @@ namespace DevToys.ViewModels.Tools.RegEx
_calculationInProgress = false;
}
+
+ private RegexOptions GetOptions()
+ {
+ RegexOptions options = RegexOptions.None;
+ if (EcmaScript)
+ {
+ options |= RegexOptions.ECMAScript;
+ }
+ if (CultureInvariant)
+ {
+ options |= RegexOptions.CultureInvariant;
+ }
+ if (IgnoreCase)
+ {
+ options |= RegexOptions.IgnoreCase;
+ }
+ if (IgnoreWhitespace && !EcmaScript)
+ {
+ options |= RegexOptions.IgnorePatternWhitespace;
+ }
+ if (Singleline && !EcmaScript)
+ {
+ options |= RegexOptions.Singleline;
+ }
+ if (Multiline)
+ {
+ options |= RegexOptions.Multiline;
+ }
+ if (RightToLeft && !EcmaScript)
+ {
+ options |= RegexOptions.RightToLeft;
+ }
+
+ return options;
+ }
}
}
diff --git a/src/dev/impl/DevToys/Views/Tools/RegEx/RegExToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/RegEx/RegExToolPage.xaml
index 741f0dbba..65b59ed09 100644
--- a/src/dev/impl/DevToys/Views/Tools/RegEx/RegExToolPage.xaml
+++ b/src/dev/impl/DevToys/Views/Tools/RegEx/RegExToolPage.xaml
@@ -4,9 +4,12 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:controls="using:DevToys.UI.Controls"
+ xmlns:controls="using:DevToys.UI.Controls" xmlns:converters="using:DevToys.UI.Converters"
mc:Ignorable="d"
NavigationCacheMode="Required">
+ <Page.Resources>
+ <converters:InvertedBooleanConverter x:Key="InvertedBooleanConverter"/>
+ </Page.Resources>
<Grid Margin="0,0,0,16" RowSpacing="12">
<Grid.ChildrenTransitions>
@@ -16,21 +19,98 @@
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
+ <StackPanel Grid.Row="0" Spacing="4" >
+ <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.Configuration}" />
+
+ <controls:ExpandableSettingControl
+ Title="{x:Bind ViewModel.Strings.Options}"
+ ContentBackground="Transparent">
+ <controls:ExpandableSettingControl.Icon>
+ <FontIcon Glyph="&#xF6A9;" />
+ </controls:ExpandableSettingControl.Icon>
+ <controls:ExpandableSettingControl.ExpandableContent>
+ <StackPanel Spacing="0" HorizontalAlignment="Stretch">
+ <controls:ExpandableSettingControl
+ CornerRadius="0,0,4,4"
+ Title="{x:Bind ViewModel.Strings.EcmaScript}"
+ Description="{x:Bind ViewModel.Strings.EcmaScriptDescription}">
+ <ToggleSwitch
+ Style="{StaticResource RightAlignedToggleSwitchStyle}"
+ IsOn="{x:Bind ViewModel.EcmaScript, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
+ </controls:ExpandableSettingControl>
+ <controls:ExpandableSettingControl
+ CornerRadius="0"
+ Title="{x:Bind ViewModel.Strings.CultureInvariant}"
+ Description="{x:Bind ViewModel.Strings.CultureInvariantDescription}">
+ <ToggleSwitch
+ Style="{StaticResource RightAlignedToggleSwitchStyle}"
+ IsOn="{x:Bind ViewModel.CultureInvariant, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
+ </controls:ExpandableSettingControl>
+ <controls:ExpandableSettingControl
+ CornerRadius="0"
+ Title="{x:Bind ViewModel.Strings.IgnoreCase}"
+ Description="{x:Bind ViewModel.Strings.IgnoreCaseDescription}">
+ <ToggleSwitch
+ Style="{StaticResource RightAlignedToggleSwitchStyle}"
+ IsOn="{x:Bind ViewModel.IgnoreCase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
+ </controls:ExpandableSettingControl>
+ <controls:ExpandableSettingControl
+ CornerRadius="0"
+ Title="{x:Bind ViewModel.Strings.IgnoreWhitespace}"
+ Description="{x:Bind ViewModel.Strings.IgnoreWhitespaceDescription}">
+ <ToggleSwitch
+ Style="{StaticResource RightAlignedToggleSwitchStyle}"
+ IsOn="{x:Bind ViewModel.IgnoreWhitespace, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ IsEnabled="{x:Bind ViewModel.EcmaScript, Mode=OneWay, Converter={StaticResource InvertedBooleanConverter}}"/>
+ </controls:ExpandableSettingControl>
+ <controls:ExpandableSettingControl
+ CornerRadius="0"
+ Title="{x:Bind ViewModel.Strings.Singleline}"
+ Description="{x:Bind ViewModel.Strings.SinglelineDescription}">
+ <ToggleSwitch
+ Style="{StaticResource RightAlignedToggleSwitchStyle}"
+ IsOn="{x:Bind ViewModel.Singleline, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ IsEnabled="{x:Bind ViewModel.EcmaScript, Mode=OneWay, Converter={StaticResource InvertedBooleanConverter}}"/>
+ </controls:ExpandableSettingControl>
+ <controls:ExpandableSettingControl
+ CornerRadius="0"
+ Title="{x:Bind ViewModel.Strings.Multiline}"
+ Description="{x:Bind ViewModel.Strings.MultilineDescription}">
+ <ToggleSwitch
+ Style="{StaticResource RightAlignedToggleSwitchStyle}"
+ IsOn="{x:Bind ViewModel.Multiline, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
+ </controls:ExpandableSettingControl>
+ <controls:ExpandableSettingControl
+ CornerRadius="0"
+ Title="{x:Bind ViewModel.Strings.RightToLeft}"
+ Description="{x:Bind ViewModel.Strings.RightToLeftDescription}">
+ <ToggleSwitch
+ Style="{StaticResource RightAlignedToggleSwitchStyle}"
+ IsOn="{x:Bind ViewModel.RightToLeft, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ IsEnabled="{x:Bind ViewModel.EcmaScript, Mode=OneWay, Converter={StaticResource InvertedBooleanConverter}}"/>
+ </controls:ExpandableSettingControl>
+ </StackPanel>
+ </controls:ExpandableSettingControl.ExpandableContent>
+ </controls:ExpandableSettingControl>
+ </StackPanel>
+
<controls:CustomTextBox
- Grid.Row="0"
+ Grid.Row="1"
Header="{x:Bind ViewModel.Strings.RegularExpression}"
Text="{x:Bind ViewModel.RegularExpression, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<controls:CustomTextBox
x:Name="MatchTextBox"
- Grid.Row="1"
+ Grid.Row="2"
Header="{x:Bind ViewModel.Strings.Text}"
AcceptsReturn="True"
IsRichTextEdit="True"
+ MinHeight="150"
Text="{x:Bind ViewModel.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Page>
diff --git a/src/dev/impl/DevToys/Views/Tools/Settings/SettingsToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Settings/SettingsToolPage.xaml
index 1d58f357b..d2404d7f8 100644
--- a/src/dev/impl/DevToys/Views/Tools/Settings/SettingsToolPage.xaml
+++ b/src/dev/impl/DevToys/Views/Tools/Settings/SettingsToolPage.xaml
@@ -40,7 +40,7 @@
<FontIcon Glyph="&#xF592;" />
</controls:ExpandableSettingControl.Icon>
<controls:ExpandableSettingControl.ExpandableContent>
- <StackPanel Spacing="4" Margin="42,0,6,0">
+ <StackPanel Padding="12" Spacing="4" Margin="42,0,6,0">
<RadioButton
Content="{x:Bind ViewModel.Strings.Light}"
IsChecked="{x:Bind ViewModel.Theme, Mode=TwoWay, ConverterParameter='Light', Converter={StaticResource EnumToBooleanConverter}}"/>
@@ -64,7 +64,7 @@
</controls:ExpandableSettingControl.Icon>
<ToggleSwitch Style="{StaticResource RightAlignedToggleSwitchStyle}" IsOn="{x:Bind ViewModel.SmartDetection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<controls:ExpandableSettingControl.ExpandableContent>
- <StackPanel Spacing="4" HorizontalAlignment="Stretch">
+ <StackPanel Padding="12" Spacing="4" Margin="42,0,42,0" HorizontalAlignment="Stretch">
<CheckBox
IsChecked="{x:Bind ViewModel.SmartDetection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Content="{x:Bind ViewModel.Strings.SmartDetectionPaste}"
@@ -145,7 +145,7 @@
<FontIcon Glyph="&#xF4E4;" />
</controls:ExpandableSettingControl.Icon>
<controls:ExpandableSettingControl.ExpandableContent>
- <Grid Margin="42,0,6,0">
+ <Grid Margin="42,12,6,12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>