public void ReplaceAllTest() { FindReplaceMgr target = MakeSample(@"Hallo 1 bla bla Hallo2 Hallo 3. Testen testen test tesssst"); target.TextToFind = "testen testen"; target.ReplacementText = "xxx"; target.CaseSensitive = false; bool AskBefore = false; // test basic replacement target.ReplaceAll(AskBefore); Assert.AreEqual(Editors[0].Text, @"Hallo 1 bla bla Hallo2 Hallo 3. xxx test tesssst"); // test wrapping through all open files target.SearchIn = FindReplaceMgr.SearchScope.AllDocuments; target.TextToFind = "bla"; target.ReplaceAll(AskBefore); Assert.AreEqual(Editors[2].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen testen test tesssst"); Assert.AreEqual(Editors[1].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen testen test tesssst"); Assert.AreEqual(Editors[0].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. xxx test tesssst"); // variable length target.UseWildcards = true; target.CaseSensitive = true; target.TextToFind = "tes*st"; target.ReplaceAll(AskBefore); Assert.AreEqual(Editors[2].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen xxx"); Assert.AreEqual(Editors[1].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen xxx"); Assert.AreEqual(Editors[0].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. xxx xxx"); }
private FindReplaceMgr MakeSample(string SampleText) { Editors.Clear(); Editors.Add(new TextEditor() { Text = SampleText }); Editors.Add(new TextEditor() { Text = SampleText }); Editors.Add(new TextEditor() { Text = SampleText }); Editors.Add(new TextEditor() { Text = SampleText }); FindReplaceMgr ret = new FindReplaceMgr() { Editors = Editors, InterfaceConverter = new IEditorConverter(), CurrentEditor = Editors[0] }; return(ret); }
public static void SetAEConfig() { FindReplaceMgr FRM = SetFindReplaceDiag(); FWindow.FMain.CommandBindings.Add(FRM.FindBinding); FWindow.FMain.CommandBindings.Add(FRM.ReplaceBinding); FWindow.FMain.CommandBindings.Add(FRM.FindNextBinding); }
public static FindReplaceMgr SetFindReplaceDiag() { FindReplaceMgr FRM = new FindReplaceMgr(); FRM.CurrentEditor = new TextEditorAdapter(FWindow.FMain.AssetPropertiesBox_Main); FRM.ShowSearchIn = false; FRM.OwnerWindow = FWindow.FMain; return(FRM); }
public MainWindow() { DataContext = this; InitializeComponent(); FindReplaceMgr fr = Resources["FRep"] as FindReplaceMgr; fr.OwnerWindow = this; //CommandBindings.Add(fr.FindBinding); //BindingOperations.SetBinding(fr, FindReplaceVM.CurrentEditorProperty, new Binding("ActiveView") { Source=this, Mode=BindingMode.TwoWay }); //BindingOperations.SetBinding(fr, FindReplaceVM.EditorsProperty, new Binding("Views") { Source = this }); }
public Editor() { InitializeComponent(); DataContext = this; TextEditor.PreviewDragEnter += new DragEventHandler(TextEditor_OnDragOver); TextEditor.PreviewDragOver += new DragEventHandler(TextEditor_OnDragOver); TextEditor.KeyDown += new KeyEventHandler(TextEditor_KeyDown); TextEditor.TextArea.TextEntered += new TextCompositionEventHandler(TextArea_TextEntered); ContextMenuChord.Click += new RoutedEventHandler(ContextMenuChord_Click); ContextMenuTitle.Click += new RoutedEventHandler(ContextMenuTitle_Click); ContextMenuSubTitle.Click += new RoutedEventHandler(ContextMenuSubTitle_Click); ContextMenuChorus.Click += new RoutedEventHandler(ContextMenuChorus_Click); ContextMenuTabular.Click += new RoutedEventHandler(ContextMenuTabular_Click); ContextMenuComment.Click += new RoutedEventHandler(ContextMenuComment_Click); ContextMenuConvertToPro.Click += new RoutedEventHandler(ContextMenuConvertToPro_Click); // Load our custom highlighting definition IHighlightingDefinition customHighlighting; using (Stream s = typeof(Editor).Assembly.GetManifestResourceStream("PdfChords.ChordProHighlighting.xshd")) { if (s == null) { throw new InvalidOperationException("Could not find embedded resource"); } using (XmlReader reader = new XmlTextReader(s)) { customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd. HighlightingLoader.Load(reader, HighlightingManager.Instance); } } HighlightingManager.Instance.RegisterHighlighting("Custom Highlighting", new string[] { ".cool" }, customHighlighting); TextEditor.SyntaxHighlighting = customHighlighting; // find and replace dialog; FindReplacePopup = new FindReplaceMgr(); FindReplacePopup.CurrentEditor = new FindReplace.TextEditorAdapter(TextEditor); FindReplacePopup.ShowSearchIn = false; CommandBindings.Add(FindReplacePopup.FindBinding); CommandBindings.Add(FindReplacePopup.ReplaceBinding); CommandBindings.Add(FindReplacePopup.FindNextBinding); }
public void FindNextTest2() { FindReplaceMgr target = MakeSample(@"aaaaaaaaaaaaaaa"); // basic Find target.CaseSensitive = false; target.TextToFind = "a"; target.FindNext(); Assert.AreEqual(1, Editors[0].CaretOffset); target.FindNext(); Assert.AreEqual(2, Editors[0].CaretOffset); target.FindNext(); Assert.AreEqual(3, Editors[0].CaretOffset); target.FindNext(); Assert.AreEqual(4, Editors[0].CaretOffset); target.FindNext(); Assert.AreEqual(5, Editors[0].CaretOffset); }
public void FindNextTest_WholeWord() { FindReplaceMgr target = MakeSample(@"aaa abcabc abc aaaa"); // basic Find target.CaseSensitive = false; target.WholeWord = true; target.TextToFind = "abc"; target.FindNext(); Assert.AreEqual <int>(22, Editors[0].CaretOffset); Assert.AreEqual <int>(3, Editors[0].SelectionLength); }
public void FindNextTest3() { FindReplaceMgr target = MakeSample("script\r\nscript\r\nend_script"); // basic Find target.CaseSensitive = false; target.TextToFind = "script"; target.SearchIn = FindReplaceMgr.SearchScope.CurrentDocument; target.SearchUp = true; target.FindNext(); Assert.AreEqual <int>(Editors[0].Text.Length, Editors[0].CaretOffset); target.FindNext(); Assert.AreEqual <int>(14, Editors[0].CaretOffset); target.FindNext(); Assert.AreEqual <int>(6, Editors[0].CaretOffset); target.FindNext(); Assert.AreEqual <int>(Editors[0].Text.Length, Editors[0].CaretOffset); }
public void ReplaceTest() { FindReplaceMgr target = MakeSample(@"Hallo 1 bla bla Hallo2 Hallo 3. Testen testen test tesssst"); target.TextToFind = "bla"; target.ReplacementText = "blu"; target.Replace(); target.Replace(); Assert.AreEqual(Editors[0].Text, @"Hallo 1 blu bla Hallo2 Hallo 3. Testen testen test tesssst"); target.SearchIn = FindReplaceMgr.SearchScope.AllDocuments; target.FindNext(); target.Replace(); target.Replace(); Assert.AreEqual(Editors[1].Text, @"Hallo 1 blu blu Hallo2 Hallo 3. Testen testen test tesssst"); }
public void FindPreviousTest() { FindReplaceMgr target = MakeSample(@"Hallo 1 bla bla Hallo2 Hallo 3. Testen testen test tesssst"); // basic Find target.CaseSensitive = true; target.TextToFind = "Hallo"; Editors[0].SelectionStart = 27; target.FindPrevious(); Assert.AreEqual(16, Editors[0].SelectionStart); Editors[0].SelectionStart = 28; target.FindPrevious(); Assert.AreEqual(23, Editors[0].SelectionStart); target.FindPrevious(); Assert.AreEqual(16, Editors[0].SelectionStart); //Assert.AreEqual(Editors[0].SelectedText, "bla Hallo2"); // wildcards //Editors[0].CaretOffset = 0; //target.UseWildcards = true; //target.TextToFind = "ha*o2"; }
public void FindNextTest() { FindReplaceMgr target = MakeSample(@"Hallo 1 bla bla Hallo2 Hallo 3. Testen testen test tesssst"); // basic Find target.CaseSensitive = false; target.TextToFind = "bla hallo2"; target.FindNext(); Assert.AreEqual(12 + target.TextToFind.Length, Editors[0].CaretOffset); Assert.AreEqual("bla Hallo2", Editors[0].SelectedText); // wildcards Editors[0].CaretOffset = 0; target.UseWildcards = true; target.TextToFind = " ha*o2"; target.FindNext(); Assert.AreEqual(22, Editors[0].CaretOffset); Assert.AreEqual(" Hallo2", Editors[0].SelectedText); Editors[0].CaretOffset = 0; target.TextToFind = " ha?o2"; target.FindNext(); Assert.AreEqual(0, Editors[0].CaretOffset); Editors[0].CaretOffset = 0; target.TextToFind = " ha??o2"; target.FindNext(); Assert.AreEqual(22, Editors[0].CaretOffset); target.CaseSensitive = true; Editors[0].CaretOffset = 0; target.TextToFind = " ha??o2"; target.FindNext(); Assert.AreEqual(0, Editors[0].CaretOffset); // regex Editors[0].CaretOffset = 0; Editors[0].Text = @"Hallo1bla Hallo2 bla. Testen testen test tesssst"; target.UseWildcards = false; target.UseRegEx = true; target.CaseSensitive = true; target.TextToFind = @"hallo\d\s+bla"; target.FindNext(); Assert.AreEqual(0, Editors[0].CaretOffset); target.CaseSensitive = false; target.FindNext(); Assert.AreEqual(22, Editors[0].CaretOffset); Assert.AreEqual("Hallo2 bla", Editors[0].SelectedText); // jump over several editors Editors[0].Text = Editors[1].Text = @"Hallo1bla Hallo2 bla. Testen testen test tesssst"; Editors[2].Text = Editors[3].Text = @"foo"; target.CurrentEditor = Editors[1]; Editors[1].CaretOffset = 0; target.UseWildcards = false; target.UseRegEx = false; target.TextToFind = "hallo1"; target.SearchIn = FindReplaceMgr.SearchScope.AllDocuments; target.FindNext(); target.FindNext(); Assert.AreEqual(Editors[0], target.CurrentEditor); Assert.AreEqual("Hallo1", Editors[0].SelectedText); // no match to be found... target.TextToFind = "sdfsgsgsfgsfgsf"; target.FindNext(); Assert.AreEqual(Editors[0], target.CurrentEditor); }
public FindReplaceDialog(FindReplaceMgr theVM) { InitializeComponent(); DataContext = TheVM = theVM; }
private void Initialize(bool newInstance, string[] args) { ShowEndOfLine = AppSettings.Settings.ShowEndOfLine; ShowSpaces = AppSettings.Settings.ShowSpaces; ShowTabs = AppSettings.Settings.ShowTabs; var entryAssembly = Assembly.GetEntryAssembly(); Title = "LSLCCEditor v" + entryAssembly.GetName().Version; var assembly = entryAssembly.Location; var appDirectory = Path.GetDirectoryName(assembly); _libraryDataProvider = new LSLXmlLibraryDataProvider(new[] { "lsl" }); try { _libraryDataProvider.FillFromXmlDirectory(Path.Combine(appDirectory, "library_data")); } catch (LSLLibraryDataXmlSyntaxException err) { MessageBox.Show(this, "There is a syntax error in one of your XML library data files and the application must close." + LSLFormatTools.CreateNewLinesString(2) + err.Message, "Library Data Syntax Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); } _codeValidatorStrategies = new LSLCodeValidatorStrategies { ExpressionValidator = new LSLDefaultExpressionValidator(), StringLiteralPreProcessor = new LSLDefaultStringPreProcessor(), SyntaxErrorListener = new WindowSyntaxErrorListener(this), SyntaxWarningListener = new WindowSyntaxWarningListener(this), LibraryDataProvider = _libraryDataProvider }; foreach (var dataMenuItem in _libraryDataProvider.SubsetDescriptions.Select(subset => new MenuItem { StaysOpenOnClick = true, IsCheckable = true, Header = subset.Value.FriendlyName, Tag = subset.Value.Subset, ToolTip = new ToolTip { Content = new TextBlock { Text = subset.Value.Description } } })) { dataMenuItem.Checked += DataMenuItemOnChecked; dataMenuItem.Unchecked += DataMenuItemOnUnChecked; TabLibraryDataMenu.Items.Add(dataMenuItem); } FindDialogManager = new FindReplaceMgr { OwnerWindow = this, InterfaceConverter = new IEditorConverter(), ShowSearchIn = false }; if (args.Length > 0) { foreach (string arg in args) { var tab = CreateEditorTab(); if (tab.OpenFileInteractive(arg)) { EditorTabs.Add(tab); } } } else { EditorTabs.Add(CreateEditorTab()); } if (!newInstance) { StartOpenTabPipeServer(); } _selectingStartupTabDuringWindowLoad = true; TabControl.SelectedIndex = 0; var initialTab = (EditorTab)TabControl.SelectedItem; initialTab.IsSelected = true; SetLibraryMenuFromTab(initialTab); FindDialogManager.CurrentEditor = initialTab.Content.EditControl.Editor; initialTab.Content.EditControl.Editor.TextChanged += Editor_OnTextChanged; EditRedoMenuItem.IsEnabled = initialTab.Content.EditControl.Editor.CanRedo; EditUndoMenuItem.IsEnabled = initialTab.Content.EditControl.Editor.CanUndo; _selectingStartupTabDuringWindowLoad = false; }