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>
<data name="Dialog.HighlightingEditor.ColorDlg.Italic" xml:space="preserve"> <data name="Dialog.HighlightingEditor.ColorDlg.Italic" xml:space="preserve">
<value>Italic</value> <value>Italic</value>
</data> </data>
<data name="Dialog.HighlightingEditor.ColorDlg.Underline" xml:space="preserve">
<value>Underlined</value>
</data>
<data name="Dialog.HighlightingEditor.Export" xml:space="preserve"> <data name="Dialog.HighlightingEditor.Export" xml:space="preserve">
<value>Export highlighting colors</value> <value>Export highlighting colors</value>
</data> </data>

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

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

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

@ -32,7 +32,11 @@
<!-- Colors used for semantic highlighting --> <!-- Colors used for semantic highlighting -->
<Color name="ReferenceTypes" foreground="#004085" exampleText="System.#{#Uri#}# uri;"/> <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="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="MethodCall" foreground="MidnightBlue" fontWeight="bold" exampleText="o.#{#ToString#}#();"/>
<Color name="FieldAccess" fontStyle="italic" exampleText="return this.#{#name#}#;"/> <Color name="FieldAccess" fontStyle="italic" exampleText="return this.#{#name#}#;"/>
<Color name="InactiveCode" foreground="Gray" exampleText="#{#Deactivated by #if#}#"/> <Color name="InactiveCode" foreground="Gray" exampleText="#{#Deactivated by #if#}#"/>

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

@ -58,10 +58,10 @@ namespace CSharpBinding
//this.defaultTextColor = ???; //this.defaultTextColor = ???;
this.referenceTypeColor = highlighting.GetNamedColor("ReferenceTypes"); this.referenceTypeColor = highlighting.GetNamedColor("ReferenceTypes");
this.valueTypeColor = highlighting.GetNamedColor("ValueTypes"); this.valueTypeColor = highlighting.GetNamedColor("ValueTypes");
this.interfaceTypeColor = this.referenceTypeColor; this.interfaceTypeColor = highlighting.GetNamedColor("InterfaceTypes");
this.enumerationTypeColor = this.valueKeywordColor; this.enumerationTypeColor = highlighting.GetNamedColor("EnumTypes");
this.typeParameterTypeColor = this.referenceTypeColor; this.typeParameterTypeColor = highlighting.GetNamedColor("TypeParameters");
this.delegateTypeColor = this.referenceTypeColor; this.delegateTypeColor = highlighting.GetNamedColor("DelegateType");
this.methodDeclarationColor = this.methodCallColor = highlighting.GetNamedColor("MethodCall"); this.methodDeclarationColor = this.methodCallColor = highlighting.GetNamedColor("MethodCall");
//this.eventDeclarationColor = this.eventAccessColor = defaultTextColor; //this.eventDeclarationColor = this.eventAccessColor = defaultTextColor;
//this.propertyDeclarationColor = this.propertyAccessColor = defaultTextColor; //this.propertyDeclarationColor = this.propertyAccessColor = defaultTextColor;

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

@ -86,8 +86,7 @@ namespace CSharpBinding.Completion
ICompletionData ICompletionDataFactory.CreateMemberCompletionData(IType type, IEntity member) ICompletionData ICompletionDataFactory.CreateMemberCompletionData(IType type, IEntity member)
{ {
string typeName = builder.ConvertType(type).ToString(); return new EnumMemberCompletionData(type, member, builder);
return new CompletionData(typeName + "." + member.Name);
} }
ICompletionData ICompletionDataFactory.CreateLiteralCompletionData(string title, string description, string insertText) 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
public EntityCompletionData(IEntity entity) : base(entity.Name) public EntityCompletionData(IEntity entity) : base(entity.Name)
{ {
this.entity = entity; this.entity = entity;
this.Description = entity.Documentation;
this.Image = ClassBrowserIconService.GetIcon(entity); 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() protected override object CreateFancyDescription()
{ {
return new FlowDocumentScrollViewer { return new FlowDocumentScrollViewer {
Document = XmlDocFormatter.CreateTooltip(entity, false), Document = XmlDocFormatter.CreateTooltip(entity, entity is ITypeDefinition),
VerticalScrollBarVisibility = ScrollBarVisibility.Auto VerticalScrollBarVisibility = ScrollBarVisibility.Auto
}; };
} }

52
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
};
}
}
}

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

@ -35,16 +35,15 @@ namespace CSharpBinding.Completion
public TypeCompletionData(IType type) : base(type.Name) public TypeCompletionData(IType type) : base(type.Name)
{ {
this.type = type; this.type = type;
ITypeDefinition typeDef = type.GetDefinition();
if (typeDef != null)
this.Description = typeDef.Documentation;
this.Image = ClassBrowserIconService.GetIcon(type); 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() protected override object CreateFancyDescription()
{ {
return new FlowDocumentScrollViewer { return new FlowDocumentScrollViewer {
Document = XmlDocFormatter.CreateTooltip(type, false), Document = XmlDocFormatter.CreateTooltip(type),
VerticalScrollBarVisibility = ScrollBarVisibility.Auto VerticalScrollBarVisibility = ScrollBarVisibility.Auto
}; };
} }

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

@ -55,20 +55,30 @@ namespace ICSharpCode.AvalonEdit.AddIn
{ {
if (items == null) if (items == null)
return null; return null;
var insightWindow = new SharpDevelopInsightWindow(this.TextEditor.TextArea); var insightWindow = textEditor.ActiveInsightWindow;
insightWindow.Items.AddRange(items); bool isNewWindow = false;
if (insightWindow.Items.Count > 0) { if (insightWindow == null) {
insightWindow.SelectedItem = insightWindow.Items[0]; 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 { } else {
// don't open insight window when there are no items // don't open insight window when there are no items
return null; return null;
} }
textEditor.ShowInsightWindow(insightWindow); insightWindow.SetActiveAdapter(adapter, isNewWindow);
return insightWindow; if (isNewWindow)
{
textEditor.ShowInsightWindow(insightWindow);
}
return adapter;
} }
public override IInsightWindow ActiveInsightWindow { public override IInsightWindow ActiveInsightWindow {
get { return textEditor.ActiveInsightWindow; } get { return textEditor.ActiveInsightWindow.activeAdapter; }
} }
public override ICompletionListWindow ActiveCompletionWindow { public override ICompletionListWindow ActiveCompletionWindow {

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

@ -43,6 +43,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public bool Bold { get; set; } public bool Bold { get; set; }
public bool Italic { get; set; } public bool Italic { get; set; }
public bool Underline { get; set; }
public Color? Foreground { get; set; } public Color? Foreground { get; set; }
public Color? Background { 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
{ {
OnPropertyChanged("Bold"); OnPropertyChanged("Bold");
OnPropertyChanged("Italic"); OnPropertyChanged("Italic");
OnPropertyChanged("Underline");
OnPropertyChanged("Foreground"); OnPropertyChanged("Foreground");
OnPropertyChanged("UseDefaultForeground"); OnPropertyChanged("UseDefaultForeground");
OnPropertyChanged("Background"); OnPropertyChanged("Background");
@ -73,7 +74,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
OnPropertyChanged("IsCustomized"); 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? foreground = null, bool? useDefaultForeground = null,
Color? background = null, bool? useDefaultBackground = null) Color? background = null, bool? useDefaultBackground = null)
{ {
@ -82,6 +83,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
newColor.Name = this.Name; newColor.Name = this.Name;
newColor.Bold = bold ?? this.Bold; newColor.Bold = bold ?? this.Bold;
newColor.Italic = italic ?? this.Italic; newColor.Italic = italic ?? this.Italic;
newColor.Underline = underline ?? this.Underline;
if (useDefaultBackground ?? this.UseDefaultBackground) if (useDefaultBackground ?? this.UseDefaultBackground)
newColor.Background = null; newColor.Background = null;
@ -99,7 +101,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
else if (customization != null) else if (customization != null)
customizationList.Remove(customization); 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) == original.UseDefaultBackground &&
(newColor.Background == null || newColor.Background == original.Background) && (newColor.Background == null || newColor.Background == original.Background) &&
(newColor.Foreground == null) == original.UseDefaultForeground && (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 { public Color Foreground {
get { get {
return (customization != null) ? (customization.Foreground ?? original.Foreground) : original.Foreground; return (customization != null) ? (customization.Foreground ?? original.Foreground) : original.Foreground;
@ -191,7 +202,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
public void Reset() public void Reset()
{ {
original.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(); AllPropertiesChanged();
} }

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

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

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

@ -43,6 +43,11 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
/// </summary> /// </summary>
bool Italic { get; set; } bool Italic { get; set; }
/// <summary>
/// Gets/Sets whether the element uses an underlined font.
/// </summary>
bool Underline { get; set; }
Color Foreground { get; set; } Color Foreground { get; set; }
bool UseDefaultForeground { get; set; } bool UseDefaultForeground { get; set; }
Color Background { 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
} }
} }
public bool Underline {
get {
return color.Underline == true;
}
set {
throw new NotSupportedException();
}
}
public Color Foreground { public Color Foreground {
get { get {
Color? c = color.Foreground != null ? color.Foreground.GetColor(null) : null; Color? c = color.Foreground != null ? color.Foreground.GetColor(null) : null;
@ -161,7 +170,12 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
marker.ForegroundColor = item.Foreground; marker.ForegroundColor = item.Foreground;
marker.FontStyle = item.Italic ? FontStyles.Italic : FontStyles.Normal; marker.FontStyle = item.Italic ? FontStyles.Italic : FontStyles.Normal;
marker.FontWeight = item.Bold ? FontWeights.Bold : FontWeights.Normal; marker.FontWeight = item.Bold ? FontWeights.Bold : FontWeights.Normal;
}); if(item.Underline)
{
marker.MarkerColor = item.Foreground;
marker.MarkerTypes = TextMarkerTypes.NormalUnderline;
}
});
} }
} else { } else {
exampleTextArea.Document.Text = exampleText; exampleTextArea.Document.Text = exampleText;

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

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

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

@ -22,6 +22,7 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.CodeCompletion; using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
@ -30,17 +31,94 @@ using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
namespace ICSharpCode.AvalonEdit.AddIn 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> /// <summary>
/// Adapter between AvalonEdit InsightWindow and SharpDevelop IInsightWindow interface. /// Adapter between AvalonEdit InsightWindow and SharpDevelop IInsightWindow interface.
/// </summary> /// </summary>
public class SharpDevelopInsightWindow : OverloadInsightWindow, IInsightWindow class SharpDevelopInsightWindowAdapter : IInsightWindow
{ {
sealed class SDItemProvider : IOverloadProvider sealed class SDItemProvider : IOverloadProvider
{ {
readonly SharpDevelopInsightWindow insightWindow; readonly SharpDevelopInsightWindowAdapter insightWindow;
int selectedIndex; int selectedIndex;
public SDItemProvider(SharpDevelopInsightWindow insightWindow) public SDItemProvider(SharpDevelopInsightWindowAdapter insightWindow)
{ {
this.insightWindow = insightWindow; this.insightWindow = insightWindow;
insightWindow.items.CollectionChanged += insightWindow_items_CollectionChanged; insightWindow.items.CollectionChanged += insightWindow_items_CollectionChanged;
@ -103,16 +181,21 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
readonly ObservableCollection<IInsightItem> items = new ObservableCollection<IInsightItem>(); 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.insightWindow = insightWindow;
this.Provider.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { provider = new SDItemProvider(this);
provider.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
if (e.PropertyName == "SelectedIndex") if (e.PropertyName == "SelectedIndex")
OnSelectedItemChanged(EventArgs.Empty); OnSelectedItemChanged(EventArgs.Empty);
}; };
this.Style = ICSharpCode.Core.Presentation.GlobalStyles.WindowStyle;
AttachEvents();
} }
public IList<IInsightItem> Items { public IList<IInsightItem> Items {
@ -121,55 +204,28 @@ namespace ICSharpCode.AvalonEdit.AddIn
public IInsightItem SelectedItem { public IInsightItem SelectedItem {
get { get {
int index = this.Provider.SelectedIndex; int index = provider.SelectedIndex;
if (index < 0 || index >= items.Count) if (index < 0 || index >= items.Count)
return null; return null;
else else
return items[index]; return items[index];
} }
set { set {
this.Provider.SelectedIndex = items.IndexOf(value); provider.SelectedIndex = items.IndexOf(value);
OnSelectedItemChanged(EventArgs.Empty); OnSelectedItemChanged(EventArgs.Empty);
} }
} }
TextDocument document;
Caret caret;
IInsightItem oldSelectedItem; IInsightItem oldSelectedItem;
void AttachEvents() public event EventHandler<TextChangeEventArgs> DocumentChanged;
{
document = this.TextArea.Document;
caret = this.TextArea.Caret;
if (document != null)
document.Changed += document_Changed;
if (caret != null)
caret.PositionChanged += caret_PositionChanged;
}
void caret_PositionChanged(object sender, EventArgs e) internal void OnDocumentChanged(DocumentChangeEventArgs 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)
{ {
if (DocumentChanged != null) if (DocumentChanged != null)
DocumentChanged(this, e); DocumentChanged(this, e);
} }
public event EventHandler<TextChangeEventArgs> DocumentChanged;
public event EventHandler SelectedItemChanged; public event EventHandler SelectedItemChanged;
protected virtual void OnSelectedItemChanged(EventArgs e) protected virtual void OnSelectedItemChanged(EventArgs e)
@ -186,8 +242,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
void SelectedItemPropertyChanged(object sender, PropertyChangedEventArgs e) void SelectedItemPropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
var provider = Provider as SDItemProvider;
if (provider == null) return;
switch (e.PropertyName) { switch (e.PropertyName) {
case "Header": case "Header":
provider.OnPropertyChanged("CurrentHeader"); provider.OnPropertyChanged("CurrentHeader");
@ -199,12 +253,77 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
public event EventHandler CaretPositionChanged; public event EventHandler CaretPositionChanged;
protected virtual void OnCaretPositionChanged(EventArgs e) internal void OnCaretPositionChanged(EventArgs e)
{ {
if (CaretPositionChanged != null) { if (CaretPositionChanged != null) {
CaretPositionChanged(this, e); 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
get { return completionWindow; } get { return completionWindow; }
} }
public SharpDevelopInsightWindow ActiveInsightWindow { internal SharpDevelopInsightWindow ActiveInsightWindow {
get { return insightWindow; } get { return insightWindow; }
} }

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

@ -267,7 +267,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
Background = CreateBrush(customization.Background), Background = CreateBrush(customization.Background),
Foreground = CreateBrush(customization.Foreground), Foreground = CreateBrush(customization.Foreground),
FontWeight = customization.Bold ? FontWeights.Bold : FontWeights.Normal, 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
preview.FontWeight = FontWeights.Bold; preview.FontWeight = FontWeights.Bold;
else else
preview.FontWeight = FontWeights.Normal; 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
} }
#region ToolTip handling #region ToolTip handling
public bool ShowDocumentationTooltips { get; set; }
void toolTip_Closed(object sender, RoutedEventArgs e) void toolTip_Closed(object sender, RoutedEventArgs e)
{ {
// Clear content after tooltip is closed. // Clear content after tooltip is closed.
@ -77,11 +75,6 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
void completionList_SelectionChanged(object sender, SelectionChangedEventArgs e) void completionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (!ShowDocumentationTooltips) {
toolTip.IsOpen = false;
return;
}
var item = completionList.SelectedItem; var item = completionList.SelectedItem;
if (item == null) if (item == null)
return; return;

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

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

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

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

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

@ -38,6 +38,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
string name; string name;
FontWeight? fontWeight; FontWeight? fontWeight;
FontStyle? fontStyle; FontStyle? fontStyle;
bool? underline;
HighlightingBrush foreground; HighlightingBrush foreground;
HighlightingBrush background; HighlightingBrush background;
bool frozen; bool frozen;
@ -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> /// <summary>
/// Gets/sets the foreground color applied by the highlighting. /// Gets/sets the foreground color applied by the highlighting.
/// </summary> /// </summary>
@ -131,6 +146,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
this.FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight")); this.FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight"));
if (info.GetBoolean("HasStyle")) if (info.GetBoolean("HasStyle"))
this.FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style")); 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.Foreground = (HighlightingBrush)info.GetValue("Foreground", typeof(HighlightingBrush));
this.Background = (HighlightingBrush)info.GetValue("Background", typeof(HighlightingBrush)); this.Background = (HighlightingBrush)info.GetValue("Background", typeof(HighlightingBrush));
} }
@ -154,6 +171,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting
info.AddValue("HasStyle", this.FontStyle.HasValue); info.AddValue("HasStyle", this.FontStyle.HasValue);
if (this.FontStyle.HasValue) if (this.FontStyle.HasValue)
info.AddValue("Style", this.FontStyle.Value.ToString()); 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("Foreground", this.Foreground);
info.AddValue("Background", this.Background); info.AddValue("Background", this.Background);
} }
@ -181,6 +201,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting
b.Append(FontStyle.Value.ToString().ToLowerInvariant()); b.Append(FontStyle.Value.ToString().ToLowerInvariant());
b.Append("; "); b.Append("; ");
} }
if (Underline != null)
{
b.Append("text-decoration: ");
b.Append(Underline.Value ? "underline" : "none");
b.Append("; ");
}
return b.ToString(); return b.ToString();
} }
@ -232,7 +258,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{ {
if (other == null) if (other == null)
return false; 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/> /// <inheritdoc/>
@ -267,11 +295,14 @@ namespace ICSharpCode.AvalonEdit.Highlighting
this.foreground = color.foreground; this.foreground = color.foreground;
if (color.background != null) if (color.background != null)
this.background = color.background; this.background = color.background;
if (color.underline != null)
this.underline = color.underline;
} }
internal bool IsEmptyForMerge { internal bool IsEmptyForMerge {
get { 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 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
@ -231,7 +232,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
if (color == null) if (color == null)
return true; return true;
return color.Background == null && color.Foreground == null return color.Background == null && color.Foreground == null
&& color.FontStyle == null && color.FontWeight == null; && color.FontStyle == null && color.FontWeight == null
&& color.Underline == null;
} }
/// <summary> /// <summary>
@ -263,6 +265,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
tf.Stretch tf.Stretch
)); ));
} }
if(color.Underline ?? false)
element.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
} }
/// <summary> /// <summary>

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save