From f35b3e2268d0c9cbf02367c179bef36abbf27639 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 21 May 2012 17:33:51 +0200 Subject: [PATCH] implement importer for .vssettings syntax highlighting and fix some styling/theming bugs --- SharpDevelop.sln | 2 +- .../AvalonEdit.AddIn/AvalonEdit.AddIn.csproj | 4 +- .../Src/ChangeMarkerMargin.cs | 37 ++- .../Src/CustomizableHighlightingColorizer.cs | 12 + .../Src/Options/HighlightingOptions.xaml | 13 +- .../Src/Options/HighlightingOptions.xaml.cs | 299 +++++++++++++++--- .../Folding/FoldingMargin.cs | 16 +- .../Highlighting/Resources/CSharp-Mode.xshd | 2 +- .../Rendering/TextView.cs | 30 ++ .../Rendering/VisualLineLinkText.cs | 4 +- .../Project/ICSharpCode.SharpDevelop.csproj | 1 + .../ContextActionsBulbControl.xaml | 4 +- .../Base/Project/Src/Util/ExtensionMethods.cs | 6 + .../Base/Project/Src/Util/MultiDictionary.cs | 117 +++++++ 14 files changed, 495 insertions(+), 52 deletions(-) create mode 100644 src/Main/Base/Project/Src/Util/MultiDictionary.cs diff --git a/SharpDevelop.sln b/SharpDevelop.sln index 873d53ea78..169e5f2f62 100644 --- a/SharpDevelop.sln +++ b/SharpDevelop.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.2.0.8634-beta +# SharpDevelop 4.2.0.8783 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}" ProjectSection(SolutionItems) = postProject EndProjectSection diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj index 87cde8b6bd..e65e76b4cc 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj @@ -64,6 +64,9 @@ + + 3.5 + 3.0 @@ -241,7 +244,6 @@ - \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs index cbe6842867..fbf2af3dc1 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs @@ -43,6 +43,35 @@ namespace ICSharpCode.AvalonEdit.AddIn } } + #region Brushes + public static readonly DependencyProperty AddedLineBrushProperty = + DependencyProperty.Register("AddedLineBrush", typeof(Brush), typeof(ChangeMarkerMargin), + new FrameworkPropertyMetadata(Brushes.LightGreen)); + + public Brush AddedLineBrush { + get { return (Brush)GetValue(AddedLineBrushProperty); } + set { SetValue(AddedLineBrushProperty, value); } + } + + public static readonly DependencyProperty ChangedLineBrushProperty = + DependencyProperty.Register("ChangedLineBrush", typeof(Brush), typeof(ChangeMarkerMargin), + new FrameworkPropertyMetadata(Brushes.LightBlue)); + + public Brush ChangedLineBrush { + get { return (Brush)GetValue(ChangedLineBrushProperty); } + set { SetValue(ChangedLineBrushProperty, value); } + } + + public static readonly DependencyProperty UnsavedLineBrushProperty = + DependencyProperty.Register("UnsavedLineBrush", typeof(Brush), typeof(ChangeMarkerMargin), + new FrameworkPropertyMetadata(Brushes.Yellow)); + + public Brush UnsavedLineBrush { + get { return (Brush)GetValue(UnsavedLineBrushProperty); } + set { SetValue(UnsavedLineBrushProperty, value); } + } + #endregion + protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; @@ -52,7 +81,7 @@ namespace ICSharpCode.AvalonEdit.AddIn var zeroLineInfo = changeWatcher.GetChange(0); foreach (VisualLine line in textView.VisualLines) { - Rect rect = new Rect(0, line.VisualTop - textView.ScrollOffset.Y, 5, line.Height); + Rect rect = new Rect(0, line.VisualTop - textView.ScrollOffset.Y - 1, 5, line.Height + 2); LineChangeInfo info = changeWatcher.GetChange(line.FirstDocumentLine.LineNumber); @@ -64,14 +93,14 @@ namespace ICSharpCode.AvalonEdit.AddIn case ChangeType.None: break; case ChangeType.Added: - drawingContext.DrawRectangle(Brushes.LightGreen, null, rect); + drawingContext.DrawRectangle(AddedLineBrush, null, rect); break; case ChangeType.Deleted: case ChangeType.Modified: - drawingContext.DrawRectangle(Brushes.LightBlue, null, rect); + drawingContext.DrawRectangle(ChangedLineBrush, null, rect); break; case ChangeType.Unsaved: - drawingContext.DrawRectangle(Brushes.Yellow, null, rect); + drawingContext.DrawRectangle(UnsavedLineBrush, null, rect); break; default: throw new Exception("Invalid value for ChangeType"); diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs index 22f99bdb23..59aa6744e6 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs @@ -12,6 +12,7 @@ using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Rendering; +using ICSharpCode.SharpDevelop.Project.Commands; namespace ICSharpCode.AvalonEdit.AddIn { @@ -24,6 +25,7 @@ namespace ICSharpCode.AvalonEdit.AddIn public const string SelectedText = "Selected text"; public const string NonPrintableCharacters = "Non-printable characters"; public const string LineNumbers = "Line numbers"; + public const string LinkText = "Link text"; public static void ApplyCustomizationsToDefaultElements(TextEditor textEditor, IEnumerable customizations) { @@ -42,6 +44,7 @@ namespace ICSharpCode.AvalonEdit.AddIn bool assignedSelectedText = false; bool assignedNonPrintableCharacter = false; bool assignedLineNumbers = false; + bool assignedLinkText = false; foreach (CustomizedHighlightingColor color in customizations) { switch (color.Name) { case DefaultTextAndBackground: @@ -88,6 +91,15 @@ namespace ICSharpCode.AvalonEdit.AddIn if (color.Foreground != null) textEditor.LineNumbersForeground = CreateFrozenBrush(color.Foreground.Value); break; + case LinkText: + if (assignedLinkText) + continue; + assignedLinkText = true; + if (color.Foreground != null) + textEditor.TextArea.TextView.LinkTextForegroundBrush = CreateFrozenBrush(color.Foreground.Value); + if (color.Background != null) + textEditor.TextArea.TextView.LinkTextBackgroundBrush = CreateFrozenBrush(color.Background.Value); + break; } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml index f8ab41dd0c..6820ef027d 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml @@ -1,4 +1,11 @@ - + @@ -39,6 +46,10 @@ + +