@@ -226,7 +226,7 @@ private void Init()
226
226
227
227
// Construit l'arbre des éléments de languages de replace.
228
228
BuildReplaceLanguageElements ( ) ;
229
-
229
+
230
230
csEval
231
231
. ReferenceAssemblyOf ( this )
232
232
. ReferenceDomainAssemblies ( )
@@ -567,6 +567,14 @@ List<RegexResult> GetMatchesFor(string text, string fileName = "", int selection
567
567
568
568
MatchesResultLabel . Content = $ "{ i } matches [Index,Length] + { countAllCaptures - i } empties matches found in { ff } /{ ft } files";
569
569
}
570
+ else if ( Config . Instance . TextSourceOn == RegexTextSource . CSharpScript )
571
+ {
572
+ dynamic sourceScript = CSharpTextSourceScript ;
573
+
574
+ MatchResultsTreeView . ItemsSource = GetMatchesFor ( sourceScript . Get ( ) . ToString ( ) , "script" ) ;
575
+
576
+ MatchesResultLabel . Content = $ "{ i } matches [Index,Length] + { countAllCaptures - i } empties matches";
577
+ }
570
578
else
571
579
{
572
580
lastMatchesText = GetText ( ) ;
@@ -681,13 +689,23 @@ private void ReplaceAllButton_Click(object sender, RoutedEventArgs e)
681
689
nbrOfElementToReplace = regex . Matches ( text ) . Count ;
682
690
lastSelectionStart = GetSelectionStartIndex ? . Invoke ( ) ?? 0 ;
683
691
lastSelectionLength = GetSelectionLength ? . Invoke ( ) ?? 0 ;
684
-
692
+
685
693
SetSelectedText ( script . After ( regex . Replace ( text , match =>
686
694
{
687
695
index ++ ;
688
696
return script . Replace ( match , index , currentFileName , index , 0 ) ;
689
697
} ) , currentFileName , null ) ) ;
690
698
break ;
699
+ case RegexTextSource . CSharpScript :
700
+ dynamic scriptSource = CSharpTextSourceScript ;
701
+ text = script . Before ( scriptSource . Get ( ) . ToString ( ) , "script" ) ;
702
+ nbrOfElementToReplace = regex . Matches ( text ) . Count ;
703
+ SetTextInNew ( script . After ( regex . Replace ( text , match =>
704
+ {
705
+ index ++ ;
706
+ return script . Replace ( match , index , "script" , index , 0 ) ;
707
+ } ) , "script" , null ) ) ;
708
+ break ;
691
709
default :
692
710
currentFileName = GetCurrentFileName ? . Invoke ( ) ?? string . Empty ;
693
711
text = script . Before ( GetCurrentText ( ) , currentFileName ) ;
@@ -754,6 +772,12 @@ private void ReplaceAllButton_Click(object sender, RoutedEventArgs e)
754
772
nbrOfElementToReplace = regex . Matches ( text ) . Count ;
755
773
SetSelectedText ( regex . Replace ( text , ReplaceEditor . Text ) ) ;
756
774
break ;
775
+ case RegexTextSource . CSharpScript :
776
+ dynamic script = CSharpTextSourceScript ;
777
+ text = script . Get ( ) . ToString ( ) ;
778
+ nbrOfElementToReplace = regex . Matches ( text ) . Count ;
779
+ SetTextInNew ( regex . Replace ( text , ReplaceEditor . Text ) ) ;
780
+ break ;
757
781
default :
758
782
text = GetCurrentText ( ) ;
759
783
nbrOfElementToReplace = regex . Matches ( text ) . Count ;
@@ -870,6 +894,11 @@ void Extract(string text, string fileName = "")
870
894
fileNames = GetFiles ( ) ;
871
895
fileNames . ForEach ( fileName => Extract ( File . ReadAllText ( fileName ) , fileName ) ) ;
872
896
}
897
+ else if ( Config . Instance . TextSourceOn == RegexTextSource . CSharpScript )
898
+ {
899
+ dynamic sourceScript = CSharpTextSourceScript ;
900
+ Extract ( sourceScript . Get ( ) . ToString ( ) , "script" ) ;
901
+ }
873
902
else
874
903
{
875
904
currentFileName = GetCurrentFileName ? . Invoke ( ) ?? string . Empty ;
@@ -981,14 +1010,17 @@ private void MatchResultsTreeView_SelectedItemChanged(object sender, RoutedPrope
981
1010
{
982
1011
RegexResult regexResult = e . NewValue as RegexResult ;
983
1012
984
- if ( regexResult ? . FileName . Length > 0 )
1013
+ if ( ! regexResult ? . FileName . Equals ( "script" ) ?? true )
985
1014
{
986
- if ( ( TryOpen ? . Invoke ( regexResult . FileName , true ) ?? false ) && ! ( regexResult is RegexFileResult ) )
1015
+ if ( regexResult ? . FileName . Length > 0 )
1016
+ {
1017
+ if ( ( TryOpen ? . Invoke ( regexResult . FileName , true ) ?? false ) && ! ( regexResult is RegexFileResult ) )
1018
+ SetPosition ( regexResult . Index , regexResult . Length ) ;
1019
+ }
1020
+ else if ( regexResult != null && lastMatchesText . Equals ( GetText ( ) ) )
1021
+ {
987
1022
SetPosition ( regexResult . Index , regexResult . Length ) ;
988
- }
989
- else if ( regexResult != null && lastMatchesText . Equals ( GetText ( ) ) )
990
- {
991
- SetPosition ( regexResult . Index , regexResult . Length ) ;
1023
+ }
992
1024
}
993
1025
}
994
1026
catch
@@ -1722,7 +1754,6 @@ private void Save_as_MenuItem_Click(object sender, RoutedEventArgs e)
1722
1754
replacePatternElement . AppendChild ( replacePatternText ) ;
1723
1755
optionsElement . AppendChild ( optionsText ) ;
1724
1756
1725
-
1726
1757
xmlDoc . Save ( dialog . FileName ) ;
1727
1758
}
1728
1759
catch ( Exception ex )
0 commit comments