diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index 0be935f412..0fd83c63fb 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -1729,6 +1729,9 @@ Examples: "120", "MainClass", "Main.cs, 120". Italic + + Underlined + Export highlighting colors diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj index 970be27a88..848785d6fb 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj @@ -78,6 +78,7 @@ + diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/CSharp-Semantic.xshd b/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/CSharp-Semantic.xshd index 157dc9e717..3e1bba50c7 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/CSharp-Semantic.xshd +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/CSharp-Semantic.xshd @@ -32,7 +32,11 @@ + + + + diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighterVisitor.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighterVisitor.cs index 8e4765c939..f50df9abb3 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighterVisitor.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighterVisitor.cs @@ -58,10 +58,10 @@ namespace CSharpBinding //this.defaultTextColor = ???; this.referenceTypeColor = highlighting.GetNamedColor("ReferenceTypes"); this.valueTypeColor = highlighting.GetNamedColor("ValueTypes"); - this.interfaceTypeColor = this.referenceTypeColor; - this.enumerationTypeColor = this.valueKeywordColor; - this.typeParameterTypeColor = this.referenceTypeColor; - this.delegateTypeColor = this.referenceTypeColor; + this.interfaceTypeColor = highlighting.GetNamedColor("InterfaceTypes"); + this.enumerationTypeColor = highlighting.GetNamedColor("EnumTypes"); + this.typeParameterTypeColor = highlighting.GetNamedColor("TypeParameters"); + this.delegateTypeColor = highlighting.GetNamedColor("DelegateType"); this.methodDeclarationColor = this.methodCallColor = highlighting.GetNamedColor("MethodCall"); //this.eventDeclarationColor = this.eventAccessColor = defaultTextColor; //this.propertyDeclarationColor = this.propertyAccessColor = defaultTextColor; diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionDataFactory.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionDataFactory.cs index c3f005e892..9396dc084c 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionDataFactory.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionDataFactory.cs @@ -86,8 +86,7 @@ namespace CSharpBinding.Completion ICompletionData ICompletionDataFactory.CreateMemberCompletionData(IType type, IEntity member) { - string typeName = builder.ConvertType(type).ToString(); - return new CompletionData(typeName + "." + member.Name); + return new EnumMemberCompletionData(type, member, builder); } ICompletionData ICompletionDataFactory.CreateLiteralCompletionData(string title, string description, string insertText) diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EntityCompletionData.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EntityCompletionData.cs index 65ea84fc1b..16d627ef43 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EntityCompletionData.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EntityCompletionData.cs @@ -37,14 +37,15 @@ namespace CSharpBinding.Completion public EntityCompletionData(IEntity entity) : base(entity.Name) { this.entity = entity; - this.Description = entity.Documentation; this.Image = ClassBrowserIconService.GetIcon(entity); + // don't set this.Description -- we use CreateFancyDescription() instead, + // and accessing entity.Documentation in the constructor is too slow } protected override object CreateFancyDescription() { return new FlowDocumentScrollViewer { - Document = XmlDocFormatter.CreateTooltip(entity, false), + Document = XmlDocFormatter.CreateTooltip(entity, entity is ITypeDefinition), VerticalScrollBarVisibility = ScrollBarVisibility.Auto }; } diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EnumMemberCompletionData.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EnumMemberCompletionData.cs new file mode 100644 index 0000000000..9d0b2c9d33 --- /dev/null +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EnumMemberCompletionData.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Linq; +using System.Windows.Controls; +using ICSharpCode.NRefactory.CSharp.Refactoring; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Editor; +namespace CSharpBinding.Completion +{ + class EnumMemberCompletionData : CompletionData + { + IType enumType; + + IEntity member; + + public EnumMemberCompletionData(IType enumType, IEntity member, TypeSystemAstBuilder builder) : base(enumType.Name + "." + member.Name) + { + this.enumType = enumType; + this.member = member; + this.Image = ClassBrowserIconService.Const; + this.CompletionText = builder.ConvertType(enumType).ToString() + "." + member.Name; + } + + protected override object CreateFancyDescription() + { + return new FlowDocumentScrollViewer { + Document = XmlDocFormatter.CreateTooltip(member, false), + VerticalScrollBarVisibility = ScrollBarVisibility.Auto + }; + } + } +} + + diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/TypeCompletionData.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/TypeCompletionData.cs index e2351811c4..a60836e910 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/TypeCompletionData.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/TypeCompletionData.cs @@ -35,16 +35,15 @@ namespace CSharpBinding.Completion public TypeCompletionData(IType type) : base(type.Name) { this.type = type; - ITypeDefinition typeDef = type.GetDefinition(); - if (typeDef != null) - this.Description = typeDef.Documentation; this.Image = ClassBrowserIconService.GetIcon(type); + // don't set this.Description -- we use CreateFancyDescription() instead, + // and accessing entity.Documentation in the constructor is too slow } protected override object CreateFancyDescription() { return new FlowDocumentScrollViewer { - Document = XmlDocFormatter.CreateTooltip(type, false), + Document = XmlDocFormatter.CreateTooltip(type), VerticalScrollBarVisibility = ScrollBarVisibility.Auto }; } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeCompletionEditorAdapter.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeCompletionEditorAdapter.cs index 4c21ee704e..16ef070ad6 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeCompletionEditorAdapter.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeCompletionEditorAdapter.cs @@ -55,20 +55,30 @@ namespace ICSharpCode.AvalonEdit.AddIn { if (items == null) return null; - var insightWindow = new SharpDevelopInsightWindow(this.TextEditor.TextArea); - insightWindow.Items.AddRange(items); - if (insightWindow.Items.Count > 0) { - insightWindow.SelectedItem = insightWindow.Items[0]; + var insightWindow = textEditor.ActiveInsightWindow; + bool isNewWindow = false; + if (insightWindow == null) { + insightWindow = new SharpDevelopInsightWindow(this.TextEditor.TextArea); + isNewWindow = true; + } + var adapter = new SharpDevelopInsightWindowAdapter(insightWindow); + adapter.Items.AddRange(items); + if (adapter.Items.Count > 0) { + adapter.SelectedItem = adapter.Items[0]; } else { // don't open insight window when there are no items return null; } - textEditor.ShowInsightWindow(insightWindow); - return insightWindow; + insightWindow.SetActiveAdapter(adapter, isNewWindow); + if (isNewWindow) + { + textEditor.ShowInsightWindow(insightWindow); + } + return adapter; } public override IInsightWindow ActiveInsightWindow { - get { return textEditor.ActiveInsightWindow; } + get { return textEditor.ActiveInsightWindow.activeAdapter; } } public override ICompletionListWindow ActiveCompletionWindow { diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs index a5df6f78c6..c113ed576c 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs @@ -43,6 +43,7 @@ namespace ICSharpCode.AvalonEdit.AddIn public bool Bold { get; set; } public bool Italic { get; set; } + public bool Underline { get; set; } public Color? Foreground { get; set; } public Color? Background { get; set; } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs index ce076196b5..e18c5be58a 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs @@ -66,6 +66,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options { OnPropertyChanged("Bold"); OnPropertyChanged("Italic"); + OnPropertyChanged("Underline"); OnPropertyChanged("Foreground"); OnPropertyChanged("UseDefaultForeground"); OnPropertyChanged("Background"); @@ -73,7 +74,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options OnPropertyChanged("IsCustomized"); } - void SetCustomization(bool? bold = null, bool? italic = null, + void SetCustomization(bool? bold = null, bool? italic = null, bool? underline = null, Color? foreground = null, bool? useDefaultForeground = null, Color? background = null, bool? useDefaultBackground = null) { @@ -82,6 +83,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options newColor.Name = this.Name; newColor.Bold = bold ?? this.Bold; newColor.Italic = italic ?? this.Italic; + newColor.Underline = underline ?? this.Underline; if (useDefaultBackground ?? this.UseDefaultBackground) newColor.Background = null; @@ -99,7 +101,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options else if (customization != null) customizationList.Remove(customization); - if (newColor.Bold == original.Bold && newColor.Italic == original.Italic && + if (newColor.Bold == original.Bold && newColor.Italic == original.Italic && newColor.Underline == original.Underline && (newColor.Background == null) == original.UseDefaultBackground && (newColor.Background == null || newColor.Background == original.Background) && (newColor.Foreground == null) == original.UseDefaultForeground && @@ -140,6 +142,15 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options } } + public bool Underline { + get { + return (customization != null) ? customization.Underline : original.Underline; + } + set { + SetCustomization(underline: value); + } + } + public Color Foreground { get { return (customization != null) ? (customization.Foreground ?? original.Foreground) : original.Foreground; @@ -191,7 +202,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options public void Reset() { original.Reset(); - SetCustomization(original.Bold, original.Italic, original.Foreground, original.UseDefaultForeground, original.Background, original.UseDefaultBackground); + SetCustomization(original.Bold, original.Italic, original.Underline, original.Foreground, original.UseDefaultForeground, original.Background, original.UseDefaultBackground); AllPropertiesChanged(); } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml index 93508d4370..b78fff3c35 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml @@ -44,6 +44,8 @@ Content="{core:Localize Dialog.HighlightingEditor.ColorDlg.Bold}"/> +