コード例 #1
0
        void UpdateSyntaxHighlighting(FileName fileName)
        {
            var oldHighlighter = primaryTextEditor.GetService <IHighlighter>();

            var highlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(fileName));
            var highlighter  = SD.EditorControlService.CreateHighlighter(document);

            primaryTextEditor.SyntaxHighlighting = highlighting;
            primaryTextEditor.TextArea.TextView.LineTransformers.RemoveAll(t => t is HighlightingColorizer);
            primaryTextEditor.TextArea.TextView.LineTransformers.Insert(0, new HighlightingColorizer(highlighter));
            primaryTextEditor.UpdateCustomizedHighlighting();

            // Dispose the old highlighter; necessary to avoid memory leaks as
            // semantic highlighters might attach to global parser events.
            if (oldHighlighter != null)
            {
                oldHighlighter.Dispose();
            }
        }
コード例 #2
0
 void CustomizedHighlightingColor_ActiveColorsChanged(object sender, EventArgs e)
 {
     // CustomizableHighlightingColorizer loads the new values automatically, we just need
     // to force a refresh in AvalonEdit.
     primaryTextEditor.UpdateCustomizedHighlighting();
     if (secondaryTextEditor != null)
     {
         secondaryTextEditor.UpdateCustomizedHighlighting();
     }
 }
コード例 #3
0
        void OnSplitView(object sender, ExecutedRoutedEventArgs e)
        {
            if (secondaryTextEditor == null)
            {
                // create secondary editor
                this.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star), MinHeight = minRowHeight
                });
                secondaryTextEditor        = CreateTextEditor();
                secondaryTextEditorAdapter = (CodeEditorAdapter)secondaryTextEditor.TextArea.GetService(typeof(ITextEditor));
                Debug.Assert(primaryTextEditorAdapter != null);

                secondaryTextEditor.SetBinding(TextEditor.DocumentProperty,
                                               new Binding(TextEditor.DocumentProperty.Name)
                {
                    Source = primaryTextEditor
                });
                secondaryTextEditor.SetBinding(TextEditor.IsReadOnlyProperty,
                                               new Binding(TextEditor.IsReadOnlyProperty.Name)
                {
                    Source = primaryTextEditor
                });
                secondaryTextEditor.SyntaxHighlighting = primaryTextEditor.SyntaxHighlighting;
                secondaryTextEditor.UpdateCustomizedHighlighting();

                gridSplitter = new GridSplitter {
                    Height = 4,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Top
                };
                SetRow(gridSplitter, 2);
                this.Children.Add(gridSplitter);

                secondaryTextEditor.Margin = new Thickness(0, 4, 0, 0);
                SetRow(secondaryTextEditor, 2);
                this.Children.Add(secondaryTextEditor);

                secondaryTextEditorAdapter.FileNameChanged();
                FetchParseInformation();
            }
            else
            {
                // remove secondary editor
                this.Children.Remove(secondaryTextEditor);
                this.Children.Remove(gridSplitter);
                secondaryTextEditorAdapter.Language.Detach();
                DisposeTextEditor(secondaryTextEditor);
                secondaryTextEditor        = null;
                secondaryTextEditorAdapter = null;
                gridSplitter = null;
                this.RowDefinitions.RemoveAt(this.RowDefinitions.Count - 1);
                this.ActiveTextEditor = primaryTextEditor;
            }
        }
コード例 #4
0
 void CustomizedHighlightingColor_ActiveColorsChanged(object sender, EventArgs e)
 {
     // CustomizableHighlightingColorizer loads the new values automatically, we just need
     // to force a refresh in AvalonEdit.
     primaryTextEditor.UpdateCustomizedHighlighting();
     if (secondaryTextEditor != null)
     {
         secondaryTextEditor.UpdateCustomizedHighlighting();
     }
     foreach (var bookmark in BookmarkManager.GetBookmarks(fileName).OfType <SDMarkerBookmark>())
     {
         bookmark.SetMarker();
     }
 }
コード例 #5
0
ファイル: CodeEditor.cs プロジェクト: Altaxo/Altaxo
		void OnSplitView(object sender, ExecutedRoutedEventArgs e)
		{
			if (secondaryTextEditor == null) {
				// create secondary editor
				this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = minRowHeight });
				secondaryTextEditor = CreateTextEditor();
				secondaryTextEditorAdapter = (CodeEditorAdapter)secondaryTextEditor.TextArea.GetService(typeof(ITextEditor));
				Debug.Assert(primaryTextEditorAdapter != null);
				
				secondaryTextEditor.SetBinding(TextEditor.DocumentProperty,
				                               new Binding(TextEditor.DocumentProperty.Name) { Source = primaryTextEditor });
				secondaryTextEditor.SetBinding(TextEditor.IsReadOnlyProperty,
				                               new Binding(TextEditor.IsReadOnlyProperty.Name) { Source = primaryTextEditor });
				secondaryTextEditor.SyntaxHighlighting = primaryTextEditor.SyntaxHighlighting;
				secondaryTextEditor.UpdateCustomizedHighlighting();
				
				gridSplitter = new GridSplitter {
					Height = 4,
					HorizontalAlignment = HorizontalAlignment.Stretch,
					VerticalAlignment = VerticalAlignment.Top
				};
				SetRow(gridSplitter, 2);
				this.Children.Add(gridSplitter);
				
				secondaryTextEditor.Margin = new Thickness(0, 4, 0, 0);
				SetRow(secondaryTextEditor, 2);
				this.Children.Add(secondaryTextEditor);
				
				secondaryTextEditorAdapter.FileNameChanged();
				FetchParseInformation();
			} else {
				// remove secondary editor
				this.Children.Remove(secondaryTextEditor);
				this.Children.Remove(gridSplitter);
				secondaryTextEditorAdapter.Language.Detach();
				DisposeTextEditor(secondaryTextEditor);
				secondaryTextEditor = null;
				secondaryTextEditorAdapter = null;
				gridSplitter = null;
				this.RowDefinitions.RemoveAt(this.RowDefinitions.Count - 1);
				this.ActiveTextEditor = primaryTextEditor;
			}
		}