// TODO: move this into SharpDevelopTextEditor public void UpdateCustomizedHighlighting() { string language = this.SyntaxHighlighting != null ? this.SyntaxHighlighting.Name : null; CustomizableHighlightingColorizer.ApplyCustomizationsToDefaultElements(this, FetchCustomizations(language)); BracketHighlightRenderer.ApplyCustomizationsToRendering(this.bracketRenderer, FetchCustomizations(language)); HighlightingOptions.ApplyToFolding(this, FetchCustomizations(language)); this.TextArea.TextView.Redraw(); // manually redraw if default elements didn't change but customized highlightings did }
public static void ApplyCustomizationsToRendering(BracketHighlightRenderer renderer, IEnumerable<CustomizedHighlightingColor> customizations) { renderer.UpdateColors(DefaultBackground, DefaultBorder); foreach (CustomizedHighlightingColor color in customizations) { if (color.Name == BracketHighlight) { renderer.UpdateColors(color.Background ?? Colors.Blue, color.Foreground ?? Colors.Blue); } } }
public static void ApplyCustomizationsToRendering(BracketHighlightRenderer renderer, IEnumerable <CustomizedHighlightingColor> customizations) { renderer.UpdateColors(DefaultBackground, DefaultBorder); foreach (CustomizedHighlightingColor color in customizations) { if (color.Name == BracketHighlight) { renderer.UpdateColors(color.Background ?? Colors.Blue, color.Foreground ?? Colors.Blue); } } }
public static void ApplyCustomizationsToRendering(BracketHighlightRenderer renderer, IEnumerable<CustomizedHighlightingColor> customizations) { renderer.UpdateColors(DefaultBackground, DefaultBorder); foreach (CustomizedHighlightingColor color in customizations) { if (color.Name == BracketHighlight) { renderer.UpdateColors(color.Background ?? Colors.Blue, color.Foreground ?? Colors.Blue); // 'break;' is necessary because more specific customizations come first in the list // (language-specific customizations are first, followed by 'all languages' customizations) break; } } }
public static void ApplyCustomizationsToRendering(BracketHighlightRenderer renderer, IEnumerable <CustomizedHighlightingColor> customizations) { renderer.UpdateColors(DefaultBackground, DefaultBorder); foreach (CustomizedHighlightingColor color in customizations) { if (color.Name == BracketHighlight) { renderer.UpdateColors(color.Background ?? Colors.Blue, color.Foreground ?? Colors.Blue); // 'break;' is necessary because more specific customizations come first in the list // (language-specific customizations are first, followed by 'all languages' customizations) break; } } }
public CodeEditorView() { this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted)); UpdateCustomizedHighlighting(); this.bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView); this.caretReferencesRenderer = new CaretReferencesRenderer(this); this.contextActionsRenderer = new ContextActionsRenderer(this); this.MouseHover += TextEditorMouseHover; this.MouseHoverStopped += TextEditorMouseHoverStopped; this.MouseLeave += TextEditorMouseLeave; this.TextArea.TextView.MouseDown += TextViewMouseDown; this.TextArea.Caret.PositionChanged += HighlightBrackets; SetupTabSnippetHandler(); }
public CodeEditorView() { this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted)); this.bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView); this.caretReferencesRenderer = new CaretReferencesRenderer(this); this.contextActionsRenderer = new ContextActionsRenderer(this); this.hiddenDefinitionRenderer = new HiddenDefinition.HiddenDefinitionRenderer(this); UpdateCustomizedHighlighting(); this.MouseHover += TextEditorMouseHover; this.MouseHoverStopped += TextEditorMouseHoverStopped; this.MouseLeave += TextEditorMouseLeave; this.TextArea.TextView.MouseDown += TextViewMouseDown; this.TextArea.Caret.PositionChanged += HighlightBrackets; this.TextArea.TextView.VisualLinesChanged += CodeEditorView_VisualLinesChanged; SetupTabSnippetHandler(); }
void Init() { // Apply common editor settings to this instance CommonEditorSettings.Instance.AssignToEditor(Editor); // If Ctrl+MouseWheel was pressed/turned, increase/decrease font size Editor.PreviewMouseWheel += new MouseWheelEventHandler((object sender, MouseWheelEventArgs e)=> { if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { CommonEditorSettings.Instance.FontSize = CommonEditorSettings.Instance.FontSize+( e.Delta > 0 ? 1 : -1); CommonEditorSettings.Instance.AssignAllOpenEditors(); e.Handled = true; } }); /* * HACK: To re-focus the editor when this document is activated (the user chose this document tab page) * , it's simply needed to catch the Loaded-Event which calls Focus on the editor instance then! */ Editor.Loaded += new RoutedEventHandler((object sender, RoutedEventArgs e) => { DoOutsideModificationCheck(); Editor.Focus(); }); #region UI Command registration /* * UI Command hack - delete the DeleteLine command (which is bound statically to Ctrl-D) * and override it with our line duplication event */ var commandBindings=Editor.TextArea.CommandBindings; foreach(CommandBinding cb in commandBindings) if (cb.Command == AvalonEditCommands.DeleteLine) { // Note: We have to break the for-loop because we change the commandBinding's contents! commandBindings.Remove(cb); break; } CommandBindings.Add(new CommandBinding(IDEUICommands.DoubleLine,DoubleLine)); CommandBindings.Add(new CommandBinding(ApplicationCommands.Save,Save_event)); CommandBindings.Add(new CommandBinding(IDEUICommands.ToggleBreakpoint,ToggleBreakpoint_event)); #endregion // Setup editor overlay // Let a grid own the entire control // - this enables us in EditorDocument derivates to insert additional controls var gr = new Grid(); MainEditorContainer = gr; AddChild(gr); gr.Children.Add(Editor); // Let there be no border Editor.Margin = new System.Windows.Thickness(0); Editor.BorderBrush = null; // Init bracket hightlighter bracketHightlighter = new BracketHighlightRenderer(Editor.TextArea.TextView); //TODO: More editor settings Editor.ShowLineNumbers = true; Editor.TextChanged += new EventHandler(Editor_TextChanged); Editor.Document.PropertyChanged+=new System.ComponentModel.PropertyChangedEventHandler(Document_PropertyChanged); // Register Marker strategy MarkerStrategy = new TextMarkerService(Editor); Editor.TextArea.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(TextArea_MouseRightButtonDown); // Make UTF-8 encoding default Editor.Encoding = Encoding.UTF8; // Enhance text rendering TextOptions.SetTextFormattingMode(Editor.TextArea.TextView, TextFormattingMode.Display); TextOptions.SetTextRenderingMode(Editor.TextArea.TextView, TextRenderingMode.ClearType); // Load file contents if file path given Reload(); // Initially draw all probably required text markers RefreshErrorHighlightings(); RefreshBreakpointHighlightings(); RefreshDebugHighlightings(); }