Browse Source

Merge branch 'master' of github.com:icsharpcode/SharpDevelop

pull/522/merge
Peter Forstmeier 12 years ago
parent
commit
0e2cb73f6c
  1. 3
      data/resources/StringResources.resx
  2. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
  3. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Resources/CSharp-Semantic.xshd
  4. 8
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighterVisitor.cs
  5. 3
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionDataFactory.cs
  6. 5
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EntityCompletionData.cs
  7. 52
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EnumMemberCompletionData.cs
  8. 7
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/TypeCompletionData.cs
  9. 24
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeCompletionEditorAdapter.cs
  10. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs
  11. 17
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs
  12. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml
  13. 5
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/IHighlightingItem.cs
  14. 16
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/NamedColorHighlightingItem.cs
  15. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/SimpleHighlightingItem.cs
  16. 205
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopInsightWindow.cs
  17. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopTextEditor.cs
  18. 3
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs
  19. 2
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.xaml.cs
  20. 7
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs
  21. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/OverloadInsightWindow.cs
  22. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs
  23. 35
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs
  24. 6
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs
  25. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd
  26. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs
  27. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs
  28. 10
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XshdColor.cs
  29. 2
      src/Main/Base/Project/Src/Services/ParserService/CodeCompletionOptions.cs

3
data/resources/StringResources.resx

@ -1729,6 +1729,9 @@ Examples: "120", "MainClass", "Main.cs, 120".</value> @@ -1729,6 +1729,9 @@ Examples: "120", "MainClass", "Main.cs, 120".</value>
<data name="Dialog.HighlightingEditor.ColorDlg.Italic" xml:space="preserve">
<value>Italic</value>
</data>
<data name="Dialog.HighlightingEditor.ColorDlg.Underline" xml:space="preserve">
<value>Underlined</value>
</data>
<data name="Dialog.HighlightingEditor.Export" xml:space="preserve">
<value>Export highlighting colors</value>
</data>

1
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj

@ -78,6 +78,7 @@ @@ -78,6 +78,7 @@
<Compile Include="Src\Completion\CSharpCompletionContext.cs" />
<Compile Include="Src\Completion\CSharpInsightItem.cs" />
<Compile Include="Src\Completion\CSharpMethodInsight.cs" />
<Compile Include="Src\Completion\EnumMemberCompletionData.cs" />
<Compile Include="Src\Completion\EventCreationCompletionData.cs" />
<Compile Include="Src\Completion\FormatItemCompletionData.cs" />
<Compile Include="Src\Completion\ImportCompletionData.cs" />

4
src/AddIns/BackendBindings/CSharpBinding/Project/Resources/CSharp-Semantic.xshd

@ -32,7 +32,11 @@ @@ -32,7 +32,11 @@
<!-- Colors used for semantic highlighting -->
<Color name="ReferenceTypes" foreground="#004085" exampleText="System.#{#Uri#}# uri;"/>
<Color name="InterfaceTypes" foreground="#004085" exampleText="System.#{#IDisposable#}# obj;"/>
<Color name="TypeParameters" foreground="#004085" exampleText="class MyList&lt;#{#T#}#&gt; { }"/>
<Color name="DelegateTypes" foreground="#004085" exampleText="System.#{#Action#}#; action;"/>
<Color name="ValueTypes" fontWeight="bold" foreground="#004085" exampleText="System.#{#DateTime#}# date;"/>
<Color name="EnumTypes" fontWeight="bold" foreground="#004085" exampleText="System.#{#ConsoleKey#}# key;"/>
<Color name="MethodCall" foreground="MidnightBlue" fontWeight="bold" exampleText="o.#{#ToString#}#();"/>
<Color name="FieldAccess" fontStyle="italic" exampleText="return this.#{#name#}#;"/>
<Color name="InactiveCode" foreground="Gray" exampleText="#{#Deactivated by #if#}#"/>

8
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighterVisitor.cs

@ -58,10 +58,10 @@ namespace CSharpBinding @@ -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;

3
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionDataFactory.cs

@ -86,8 +86,7 @@ namespace CSharpBinding.Completion @@ -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)

5
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EntityCompletionData.cs

@ -37,14 +37,15 @@ namespace CSharpBinding.Completion @@ -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
};
}

52
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EnumMemberCompletionData.cs

@ -0,0 +1,52 @@ @@ -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
};
}
}
}

7
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/TypeCompletionData.cs

@ -35,16 +35,15 @@ namespace CSharpBinding.Completion @@ -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
};
}

24
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeCompletionEditorAdapter.cs

@ -55,20 +55,30 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -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 {

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs

@ -43,6 +43,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -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; }

17
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs

@ -66,6 +66,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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();
}

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml

@ -44,6 +44,8 @@ @@ -44,6 +44,8 @@
Content="{core:Localize Dialog.HighlightingEditor.ColorDlg.Bold}"/>
<CheckBox IsEnabled="{Binding CanSetFont}" IsChecked="{Binding Italic}"
Content="{core:Localize Dialog.HighlightingEditor.ColorDlg.Italic}"/>
<CheckBox IsEnabled="{Binding CanSetFont}" IsChecked="{Binding Underline}"
Content="{core:Localize Dialog.HighlightingEditor.ColorDlg.Underline}"/>
<Button Name="resetButton" IsEnabled="{Binding IsCustomized}" HorizontalAlignment="Left"
Click="ResetButtonClick" Style="{x:Static core:GlobalStyles.ButtonStyle}" Margin="0,4"
Content="Reset" />

5
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/IHighlightingItem.cs

@ -43,6 +43,11 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -43,6 +43,11 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
/// </summary>
bool Italic { get; set; }
/// <summary>
/// Gets/Sets whether the element uses an underlined font.
/// </summary>
bool Underline { get; set; }
Color Foreground { get; set; }
bool UseDefaultForeground { get; set; }
Color Background { get; set; }

16
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/NamedColorHighlightingItem.cs

@ -68,6 +68,15 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -68,6 +68,15 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
}
}
public bool Underline {
get {
return color.Underline == true;
}
set {
throw new NotSupportedException();
}
}
public Color Foreground {
get {
Color? c = color.Foreground != null ? color.Foreground.GetColor(null) : null;
@ -161,7 +170,12 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -161,7 +170,12 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
marker.ForegroundColor = item.Foreground;
marker.FontStyle = item.Italic ? FontStyles.Italic : FontStyles.Normal;
marker.FontWeight = item.Bold ? FontWeights.Bold : FontWeights.Normal;
});
if(item.Underline)
{
marker.MarkerColor = item.Foreground;
marker.MarkerTypes = TextMarkerTypes.NormalUnderline;
}
});
}
} else {
exampleTextArea.Document.Text = exampleText;

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/SimpleHighlightingItem.cs

@ -40,6 +40,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -40,6 +40,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
public string Name { get; private set; }
public bool Bold { get; set; }
public bool Italic { get; set; }
public bool Underline { get; set; }
public Color Foreground { get; set; }
public bool UseDefaultForeground { get; set; }

205
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopInsightWindow.cs

@ -22,6 +22,7 @@ using System.Collections.ObjectModel; @@ -22,6 +22,7 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
@ -30,17 +31,94 @@ using ICSharpCode.SharpDevelop.Editor.CodeCompletion; @@ -30,17 +31,94 @@ using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
namespace ICSharpCode.AvalonEdit.AddIn
{
class SharpDevelopInsightWindow : OverloadInsightWindow
{
public SharpDevelopInsightWindow(TextArea textArea) : base(textArea)
{
this.Style = ICSharpCode.Core.Presentation.GlobalStyles.WindowStyle;
AttachEvents();
}
internal SharpDevelopInsightWindowAdapter activeAdapter;
public void SetActiveAdapter(SharpDevelopInsightWindowAdapter adapter, bool isNewWindow)
{
if (activeAdapter != null) {
// tell the previous adapter that its window was closed,
// but actually reuse the window for the new adapter
activeAdapter.OnClosed();
}
activeAdapter = adapter;
this.Provider = adapter.Provider;
if (!isNewWindow) {
// reset insight window to initial state
CloseAutomatically = true;
StartOffset = EndOffset = this.TextArea.Caret.Offset;
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(SetPositionToStartOffset));
}
}
void SetPositionToStartOffset()
{
if (document != null && this.StartOffset != this.TextArea.Caret.Offset) {
SetPosition(new TextViewPosition(document.GetLocation(this.StartOffset)));
} else {
SetPosition(this.TextArea.Caret.Position);
}
}
TextDocument document;
Caret caret;
void AttachEvents()
{
document = this.TextArea.Document;
caret = this.TextArea.Caret;
if (document != null)
document.Changed += document_Changed;
if (caret != null)
caret.PositionChanged += caret_PositionChanged;
this.Closed += OnClosed;
}
/// <inheritdoc/>
protected override void DetachEvents()
{
if (document != null)
document.Changed -= document_Changed;
if (caret != null)
caret.PositionChanged -= caret_PositionChanged;
this.Closed -= OnClosed;
base.DetachEvents();
}
void OnClosed(object sender, EventArgs e)
{
activeAdapter.OnClosed();
}
void caret_PositionChanged(object sender, EventArgs e)
{
activeAdapter.OnCaretPositionChanged(e);
}
void document_Changed(object sender, DocumentChangeEventArgs e)
{
activeAdapter.OnDocumentChanged(e);
}
}
/// <summary>
/// Adapter between AvalonEdit InsightWindow and SharpDevelop IInsightWindow interface.
/// </summary>
public class SharpDevelopInsightWindow : OverloadInsightWindow, IInsightWindow
class SharpDevelopInsightWindowAdapter : IInsightWindow
{
sealed class SDItemProvider : IOverloadProvider
{
readonly SharpDevelopInsightWindow insightWindow;
readonly SharpDevelopInsightWindowAdapter insightWindow;
int selectedIndex;
public SDItemProvider(SharpDevelopInsightWindow insightWindow)
public SDItemProvider(SharpDevelopInsightWindowAdapter insightWindow)
{
this.insightWindow = insightWindow;
insightWindow.items.CollectionChanged += insightWindow_items_CollectionChanged;
@ -103,16 +181,21 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -103,16 +181,21 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
readonly ObservableCollection<IInsightItem> items = new ObservableCollection<IInsightItem>();
SharpDevelopInsightWindow insightWindow;
readonly SDItemProvider provider;
public SharpDevelopInsightWindow(TextArea textArea) : base(textArea)
internal IOverloadProvider Provider {
get { return provider; }
}
internal SharpDevelopInsightWindowAdapter(SharpDevelopInsightWindow insightWindow)
{
this.Provider = new SDItemProvider(this);
this.Provider.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
this.insightWindow = insightWindow;
provider = new SDItemProvider(this);
provider.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
if (e.PropertyName == "SelectedIndex")
OnSelectedItemChanged(EventArgs.Empty);
};
this.Style = ICSharpCode.Core.Presentation.GlobalStyles.WindowStyle;
AttachEvents();
}
public IList<IInsightItem> Items {
@ -121,55 +204,28 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -121,55 +204,28 @@ namespace ICSharpCode.AvalonEdit.AddIn
public IInsightItem SelectedItem {
get {
int index = this.Provider.SelectedIndex;
int index = provider.SelectedIndex;
if (index < 0 || index >= items.Count)
return null;
else
return items[index];
}
set {
this.Provider.SelectedIndex = items.IndexOf(value);
provider.SelectedIndex = items.IndexOf(value);
OnSelectedItemChanged(EventArgs.Empty);
}
}
TextDocument document;
Caret caret;
IInsightItem oldSelectedItem;
void AttachEvents()
{
document = this.TextArea.Document;
caret = this.TextArea.Caret;
if (document != null)
document.Changed += document_Changed;
if (caret != null)
caret.PositionChanged += caret_PositionChanged;
}
public event EventHandler<TextChangeEventArgs> DocumentChanged;
void caret_PositionChanged(object sender, EventArgs e)
{
OnCaretPositionChanged(e);
}
/// <inheritdoc/>
protected override void DetachEvents()
{
if (document != null)
document.Changed -= document_Changed;
if (caret != null)
caret.PositionChanged -= caret_PositionChanged;
base.DetachEvents();
}
void document_Changed(object sender, DocumentChangeEventArgs e)
internal void OnDocumentChanged(DocumentChangeEventArgs e)
{
if (DocumentChanged != null)
DocumentChanged(this, e);
}
public event EventHandler<TextChangeEventArgs> DocumentChanged;
public event EventHandler SelectedItemChanged;
protected virtual void OnSelectedItemChanged(EventArgs e)
@ -186,8 +242,6 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -186,8 +242,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
void SelectedItemPropertyChanged(object sender, PropertyChangedEventArgs e)
{
var provider = Provider as SDItemProvider;
if (provider == null) return;
switch (e.PropertyName) {
case "Header":
provider.OnPropertyChanged("CurrentHeader");
@ -199,12 +253,77 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -199,12 +253,77 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
public event EventHandler CaretPositionChanged;
protected virtual void OnCaretPositionChanged(EventArgs e)
internal void OnCaretPositionChanged(EventArgs e)
{
if (CaretPositionChanged != null) {
CaretPositionChanged(this, e);
}
}
public event EventHandler Closed;
internal void OnClosed()
{
if (Closed != null)
Closed(this, EventArgs.Empty);
insightWindow = null;
}
public void Close()
{
if (insightWindow != null)
insightWindow.Close();
}
public double Width {
get {
return insightWindow != null ? insightWindow.Width : 0;
}
set {
if (insightWindow != null)
insightWindow.Width = value;
}
}
public double Height {
get {
return insightWindow != null ? insightWindow.Height : 0;
}
set {
if (insightWindow != null)
insightWindow.Height = value;
}
}
public bool CloseAutomatically {
get {
return insightWindow != null && insightWindow.CloseAutomatically;
}
set {
if (insightWindow != null)
insightWindow.CloseAutomatically = value;
}
}
public int StartOffset {
get {
return insightWindow != null ? insightWindow.StartOffset : 0;
}
set {
if (insightWindow != null)
insightWindow.StartOffset = value;
}
}
public int EndOffset {
get {
return insightWindow != null ? insightWindow.EndOffset : 0;
}
set {
if (insightWindow != null)
insightWindow.EndOffset = value;
}
}
}
}

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopTextEditor.cs

@ -97,7 +97,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -97,7 +97,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
get { return completionWindow; }
}
public SharpDevelopInsightWindow ActiveInsightWindow {
internal SharpDevelopInsightWindow ActiveInsightWindow {
get { return insightWindow; }
}

3
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs

@ -267,7 +267,8 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -267,7 +267,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
Background = CreateBrush(customization.Background),
Foreground = CreateBrush(customization.Foreground),
FontWeight = customization.Bold ? FontWeights.Bold : FontWeights.Normal,
FontStyle = customization.Italic ? FontStyles.Italic : FontStyles.Normal
FontStyle = customization.Italic ? FontStyles.Italic : FontStyles.Normal,
Underline = customization.Underline
};
}
}

2
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.xaml.cs

@ -103,6 +103,8 @@ namespace HexEditor.View @@ -103,6 +103,8 @@ namespace HexEditor.View
preview.FontWeight = FontWeights.Bold;
else
preview.FontWeight = FontWeights.Normal;
if (font.Underline)
preview.TextDecorations = TextDecorations.Underline;
}
}
}

7
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs

@ -64,8 +64,6 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion @@ -64,8 +64,6 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
}
#region ToolTip handling
public bool ShowDocumentationTooltips { get; set; }
void toolTip_Closed(object sender, RoutedEventArgs e)
{
// Clear content after tooltip is closed.
@ -77,11 +75,6 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion @@ -77,11 +75,6 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
void completionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!ShowDocumentationTooltips) {
toolTip.IsOpen = false;
return;
}
var item = completionList.SelectedItem;
if (item == null)
return;

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/OverloadInsightWindow.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion @@ -52,7 +52,7 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (!e.Handled && this.Provider.Count > 1) {
if (!e.Handled && this.Provider != null && this.Provider.Count > 1) {
switch (e.Key) {
case Key.Up:
e.Handled = true;

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs

@ -113,7 +113,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -113,7 +113,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{
if (color == null)
throw new ArgumentNullException("color");
if (color.Foreground == null && color.Background == null && color.FontStyle == null && color.FontWeight == null) {
if (color.Foreground == null && color.Background == null && color.FontStyle == null && color.FontWeight == null && color.Underline == null) {
// Optimization: don't split the HighlightingState when we're not changing
// any property. For example, the "Punctuation" color in C# is
// empty by default.

35
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs

@ -38,6 +38,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -38,6 +38,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
string name;
FontWeight? fontWeight;
FontStyle? fontStyle;
bool? underline;
HighlightingBrush foreground;
HighlightingBrush background;
bool frozen;
@ -84,6 +85,20 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -84,6 +85,20 @@ namespace ICSharpCode.AvalonEdit.Highlighting
}
}
/// <summary>
/// Gets/sets the underline flag. Null if the underline status does not change the font style.
/// </summary>
public bool? Underline {
get {
return underline;
}
set {
if (frozen)
throw new InvalidOperationException();
underline = value;
}
}
/// <summary>
/// Gets/sets the foreground color applied by the highlighting.
/// </summary>
@ -131,6 +146,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -131,6 +146,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
this.FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight"));
if (info.GetBoolean("HasStyle"))
this.FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style"));
if (info.GetBoolean("HasUnderline"))
this.Underline = info.GetBoolean("Underline");
this.Foreground = (HighlightingBrush)info.GetValue("Foreground", typeof(HighlightingBrush));
this.Background = (HighlightingBrush)info.GetValue("Background", typeof(HighlightingBrush));
}
@ -154,6 +171,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -154,6 +171,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting
info.AddValue("HasStyle", this.FontStyle.HasValue);
if (this.FontStyle.HasValue)
info.AddValue("Style", this.FontStyle.Value.ToString());
info.AddValue("HasUnderline", this.Underline.HasValue);
if (this.Underline.HasValue)
info.AddValue("Underline", this.Underline.Value);
info.AddValue("Foreground", this.Foreground);
info.AddValue("Background", this.Background);
}
@ -181,6 +201,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -181,6 +201,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting
b.Append(FontStyle.Value.ToString().ToLowerInvariant());
b.Append("; ");
}
if (Underline != null)
{
b.Append("text-decoration: ");
b.Append(Underline.Value ? "underline" : "none");
b.Append("; ");
}
return b.ToString();
}
@ -232,7 +258,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -232,7 +258,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{
if (other == null)
return false;
return this.name == other.name && this.fontWeight == other.fontWeight && this.fontStyle == other.fontStyle && object.Equals(this.foreground, other.foreground) && object.Equals(this.background, other.background);
return this.name == other.name && this.fontWeight == other.fontWeight
&& this.fontStyle == other.fontStyle && this.underline == other.underline
&& object.Equals(this.foreground, other.foreground) && object.Equals(this.background, other.background);
}
/// <inheritdoc/>
@ -267,11 +295,14 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -267,11 +295,14 @@ namespace ICSharpCode.AvalonEdit.Highlighting
this.foreground = color.foreground;
if (color.background != null)
this.background = color.background;
if (color.underline != null)
this.underline = color.underline;
}
internal bool IsEmptyForMerge {
get {
return fontWeight == null && fontStyle == null && foreground == null && background == null;
return fontWeight == null && fontStyle == null && underline == null
&& foreground == null && background == null;
}
}
}

6
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
@ -231,7 +232,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -231,7 +232,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
if (color == null)
return true;
return color.Background == null && color.Foreground == null
&& color.FontStyle == null && color.FontWeight == null;
&& color.FontStyle == null && color.FontWeight == null
&& color.Underline == null;
}
/// <summary>
@ -263,6 +265,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -263,6 +265,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
tf.Stretch
));
}
if(color.Underline ?? false)
element.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
}
/// <summary>

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd

@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
<xsd:attribute name="background" type="xsd:string" use="optional" />
<xsd:attribute name="fontWeight" type="FontWeight" use="optional" />
<xsd:attribute name="fontStyle" type="FontStyle" use="optional" />
<xsd:attribute name="underline" type="xsd:boolean" use="optional" />
<xsd:anyAttribute namespace="##other" processContents="lax" />
</xsd:attributeGroup>

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs

@ -297,6 +297,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd @@ -297,6 +297,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
color.Background = ParseColor(position, reader.GetAttribute("background"));
color.FontWeight = ParseFontWeight(reader.GetAttribute("fontWeight"));
color.FontStyle = ParseFontStyle(reader.GetAttribute("fontStyle"));
color.Underline = reader.GetBoolAttribute("underline");
return color;
}

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs

@ -204,6 +204,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd @@ -204,6 +204,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
c.Name = color.Name;
c.Foreground = color.Foreground;
c.Background = color.Background;
c.Underline = color.Underline;
c.FontStyle = color.FontStyle;
c.FontWeight = color.FontWeight;
return c;

10
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XshdColor.cs

@ -49,6 +49,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd @@ -49,6 +49,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
/// </summary>
public FontWeight? FontWeight { get; set; }
/// <summary>
/// Gets/sets the underline flag
/// </summary>
public bool? Underline { get; set; }
/// <summary>
/// Gets/sets the font style.
/// </summary>
@ -81,6 +86,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd @@ -81,6 +86,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
if (info.GetBoolean("HasStyle"))
this.FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style"));
this.ExampleText = info.GetString("ExampleText");
if (info.GetBoolean("HasUnderline"))
this.Underline = info.GetBoolean("Underline");
}
/// <summary>
@ -98,6 +105,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd @@ -98,6 +105,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
info.AddValue("Name", this.Name);
info.AddValue("Foreground", this.Foreground);
info.AddValue("Background", this.Background);
info.AddValue("HasUnderline", this.Underline.HasValue);
if (this.Underline.HasValue)
info.AddValue("Underline", this.Underline.Value);
info.AddValue("HasWeight", this.FontWeight.HasValue);
if (this.FontWeight.HasValue)
info.AddValue("Weight", this.FontWeight.Value.ToOpenTypeWeight());

2
src/Main/Base/Project/Src/Services/ParserService/CodeCompletionOptions.cs

@ -84,7 +84,7 @@ namespace ICSharpCode.SharpDevelop @@ -84,7 +84,7 @@ namespace ICSharpCode.SharpDevelop
}
public static string CompletionCharList {
get { return properties.Get("CompletionCharList", @"{}[]().,:;+-*/%&|^!~=<>?@#'""\"); }
get { return properties.Get("CompletionCharList", @" {}[]().,:;+-*/%&|^!~=<>?@#'""\"); }
set { properties.Set("CompletionCharList", value); }
}

Loading…
Cancel
Save