Merge branch 'master' of github.com:icsharpcode/SharpDevelop into newNR
Conflicts: src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditSyntaxHighlighterAdapter.cs src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs src/AddIns/Misc/SearchAndReplace/Project/Gui/SearchResultNode.cs src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedLine.cs src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/IHighlighter.cs src/Main/Base/Project/Src/Editor/IEditorControlService.cs src/Main/Base/Project/Src/Editor/ISyntaxHighlighter.cs src/Main/Base/Project/Src/Editor/Search/SearchResultMatch.cs src/Main/Base/Project/Src/Editor/Search/SearchResultsPad.cs src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs
This commit is contained in:
Коммит
c2905f4ba3
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
|
@ -24,6 +25,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
sealed class HighlightingState
|
||||
{
|
||||
internal Brush Foreground;
|
||||
internal Brush Background;
|
||||
internal FontFamily Family;
|
||||
internal FontWeight? Weight;
|
||||
internal FontStyle? Style;
|
||||
|
@ -32,6 +34,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
{
|
||||
return new HighlightingState {
|
||||
Foreground = this.Foreground,
|
||||
Background = this.Background,
|
||||
Family = this.Family,
|
||||
Weight = this.Weight,
|
||||
Style = this.Style
|
||||
|
@ -70,6 +73,13 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
stateChanges.Add(new HighlightingState());
|
||||
}
|
||||
|
||||
HighlightedInlineBuilder(string text, int[] offsets, HighlightingState[] states)
|
||||
{
|
||||
this.text = text;
|
||||
stateChangeOffsets.AddRange(offsets);
|
||||
stateChanges.AddRange(states);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text.
|
||||
/// </summary>
|
||||
|
@ -96,6 +106,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
HighlightingState state = stateChanges[i];
|
||||
if (color.Foreground != null)
|
||||
state.Foreground = color.Foreground.GetBrush(null);
|
||||
if (color.Background != null)
|
||||
state.Background = color.Background.GetBrush(null);
|
||||
if (color.FontStyle != null)
|
||||
state.Style = color.FontStyle;
|
||||
if (color.FontWeight != null)
|
||||
|
@ -115,6 +127,18 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the background brush on the specified text segment.
|
||||
/// </summary>
|
||||
public void SetBackground(int offset, int length, Brush brush)
|
||||
{
|
||||
int startIndex = GetIndexForOffset(offset);
|
||||
int endIndex = GetIndexForOffset(offset + length);
|
||||
for (int i = startIndex; i < endIndex; i++) {
|
||||
stateChanges[i].Background = brush;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the font weight on the specified text segment.
|
||||
/// </summary>
|
||||
|
@ -164,6 +188,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
HighlightingState state = stateChanges[i];
|
||||
if (state.Foreground != null)
|
||||
r.Foreground = state.Foreground;
|
||||
if (state.Background != null)
|
||||
r.Background = state.Background;
|
||||
if (state.Weight != null)
|
||||
r.FontWeight = state.Weight.Value;
|
||||
if (state.Family != null)
|
||||
|
@ -174,5 +200,15 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
}
|
||||
return runs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clones this HighlightedInlineBuilder.
|
||||
/// </summary>
|
||||
public HighlightedInlineBuilder Clone()
|
||||
{
|
||||
return new HighlightedInlineBuilder(this.text,
|
||||
stateChangeOffsets.ToArray(),
|
||||
stateChanges.Select(sc => sc.Clone()).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
/// </summary>
|
||||
public IList<HighlightedSection> Sections { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default color of all text outside a <see cref="HighlightedSection"/>.
|
||||
/// </summary>
|
||||
public HighlightingColor DefaultTextColor { get; set; }
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
void ValidateInvariants()
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
/// </remarks>
|
||||
public class HighlightingManager : IHighlightingDefinitionReferenceResolver
|
||||
{
|
||||
sealed class DelayLoadedHighlightingDefinition : IHighlightingDefinition
|
||||
sealed class DelayLoadedHighlightingDefinition : IHighlightingDefinition2
|
||||
{
|
||||
readonly object lockObj = new object();
|
||||
readonly string name;
|
||||
|
@ -104,6 +104,15 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
{
|
||||
return this.Name;
|
||||
}
|
||||
|
||||
public IDictionary<string, string> Properties {
|
||||
get {
|
||||
var def = GetDefinition() as IHighlightingDefinition2;
|
||||
if (def != null)
|
||||
return def.Properties;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly object lockObj = new object();
|
||||
|
|
|
@ -40,4 +40,15 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
/// </summary>
|
||||
IEnumerable<HighlightingColor> NamedHighlightingColors { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extension of IHighlightingDefinition to avoid breaking changes in the API.
|
||||
/// </summary>
|
||||
public interface IHighlightingDefinition2 : IHighlightingDefinition
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the list of properties.
|
||||
/// </summary>
|
||||
IDictionary<string, string> Properties { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
<Color name="TrueFalse" fontWeight="bold" foreground="DarkCyan" exampleText="b = false; a = true;" />
|
||||
<Color name="TypeKeywords" fontWeight="bold" foreground="DarkCyan" exampleText="if (x is int) { a = x as int; type = typeof(int); size = sizeof(int); c = new object(); }"/>
|
||||
|
||||
<Property name="DocCommentMarker" value="///" />
|
||||
|
||||
<RuleSet name="CommentMarkerSet">
|
||||
<Keywords fontWeight="bold" foreground="Red">
|
||||
<Word>TODO</Word>
|
||||
|
|
|
@ -50,6 +50,13 @@
|
|||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="Property">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="value" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<!-- Regular expression -->
|
||||
<xsd:simpleType name="regex">
|
||||
<xsd:restriction base="xsd:string"/>
|
||||
|
@ -135,6 +142,7 @@
|
|||
<xsd:element name="SyntaxDefinition">
|
||||
<xsd:complexType>
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:element ref="Property"/>
|
||||
<xsd:element ref="Color"/>
|
||||
<xsd:element ref="RuleSet"/>
|
||||
</xsd:choice>
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
<Color name="FunctionKeywords" foreground="Blue" exampleText="CInt(a)" />
|
||||
<Color name="ContextKeywords" foreground="Blue" exampleText="Declare Unicode Sub SomeMethod" />
|
||||
|
||||
<Property name="DocCommentMarker" value="'''" />
|
||||
|
||||
<RuleSet ignoreCase="true">
|
||||
<Span color="String">
|
||||
<Begin>"</Begin>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<SyntaxDefinition name="XmlDoc" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
|
||||
<Color name="XmlString" foreground="Silver" fontWeight="bold" />
|
||||
<Color name="DocComment" foreground="Gray" />
|
||||
<Color name="XmlPunctuation" fontWeight="bold" />
|
||||
<Color name="KnownDocTags" fontWeight="bold" />
|
||||
<Color name="XmlString" foreground="Silver" fontWeight="bold" exampleText="${DocCommentMarker} <exception cref="System.Exception" />" />
|
||||
<Color name="DocComment" foreground="Gray" exampleText="${DocCommentMarker} <exception cref="System.Exception" />" />
|
||||
<Color name="XmlPunctuation" fontWeight="bold" exampleText="${DocCommentMarker} <exception cref="System.Exception" />" />
|
||||
<Color name="KnownDocTags" fontWeight="bold" exampleText="${DocCommentMarker} <exception cref="System.Exception" />" />
|
||||
|
||||
<RuleSet name="DocCommentSet">
|
||||
<Span color="DocComment">
|
||||
|
|
|
@ -64,6 +64,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
|
|||
case "RuleSet":
|
||||
c.Add(ParseRuleSet(reader));
|
||||
break;
|
||||
case "Property":
|
||||
c.Add(ParseProperty(reader));
|
||||
break;
|
||||
case "Color":
|
||||
c.Add(ParseNamedColor(reader));
|
||||
break;
|
||||
|
@ -85,6 +88,15 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
|
|||
}
|
||||
}
|
||||
|
||||
static XshdElement ParseProperty(XmlReader reader)
|
||||
{
|
||||
XshdProperty property = new XshdProperty();
|
||||
SetPosition(property, reader);
|
||||
property.Name = reader.GetAttribute("name");
|
||||
property.Value = reader.GetAttribute("value");
|
||||
return property;
|
||||
}
|
||||
|
||||
static XshdRuleSet ParseRuleSet(XmlReader reader)
|
||||
{
|
||||
XshdRuleSet ruleSet = new XshdRuleSet();
|
||||
|
|
|
@ -5,15 +5,15 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using ICSharpCode.AvalonEdit.Utils;
|
||||
|
||||
namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
|
||||
{
|
||||
[Serializable]
|
||||
sealed class XmlHighlightingDefinition : IHighlightingDefinition
|
||||
sealed class XmlHighlightingDefinition : IHighlightingDefinition2
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
|
||||
|
@ -37,6 +37,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
|
|||
throw new HighlightingDefinitionInvalidException("Could not find main RuleSet.");
|
||||
// Translate elements within the rulesets (resolving references and processing imports)
|
||||
xshd.AcceptElements(new TranslateElementVisitor(this, rnev.ruleSets, resolver));
|
||||
|
||||
foreach (var p in xshd.Elements.OfType<XshdProperty>())
|
||||
propDict.Add(p.Name, p.Value);
|
||||
}
|
||||
|
||||
#region RegisterNamedElements
|
||||
|
@ -358,6 +361,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
|
|||
|
||||
Dictionary<string, HighlightingRuleSet> ruleSetDict = new Dictionary<string, HighlightingRuleSet>();
|
||||
Dictionary<string, HighlightingColor> colorDict = new Dictionary<string, HighlightingColor>();
|
||||
[OptionalField]
|
||||
Dictionary<string, string> propDict = new Dictionary<string, string>();
|
||||
|
||||
public HighlightingRuleSet MainRuleSet { get; private set; }
|
||||
|
||||
|
@ -391,5 +396,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
|
|||
{
|
||||
return this.Name;
|
||||
}
|
||||
|
||||
public IDictionary<string, string> Properties {
|
||||
get {
|
||||
return propDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
|
||||
{
|
||||
/// <summary>
|
||||
/// A property in an Xshd file.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class XshdProperty : XshdElement
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets/sets the name.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the value.
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new XshdColor instance.
|
||||
/// </summary>
|
||||
public XshdProperty()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override object AcceptVisitor(IXshdVisitor visitor)
|
||||
{
|
||||
return null;
|
||||
// return visitor.VisitProperty(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -211,6 +211,7 @@
|
|||
<Compile Include="Highlighting\Xshd\XmlHighlightingDefinition.cs" />
|
||||
<Compile Include="Highlighting\Xshd\XshdColor.cs" />
|
||||
<Compile Include="Highlighting\Xshd\XshdImport.cs" />
|
||||
<Compile Include="Highlighting\Xshd\XshdProperty.cs" />
|
||||
<Compile Include="Highlighting\Xshd\XshdReference.cs" />
|
||||
<Compile Include="Highlighting\Xshd\XshdElement.cs" />
|
||||
<Compile Include="Highlighting\Xshd\XshdKeywords.cs" />
|
||||
|
|
|
@ -30,25 +30,35 @@ namespace ICSharpCode.AvalonEdit.Rendering
|
|||
this.target = target;
|
||||
this.target.MouseLeave += MouseHoverLogicMouseLeave;
|
||||
this.target.MouseMove += MouseHoverLogicMouseMove;
|
||||
this.target.MouseEnter += MouseHoverLogicMouseEnter;
|
||||
}
|
||||
|
||||
|
||||
void MouseHoverLogicMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
Point newPosition = e.GetPosition(this.target);
|
||||
Vector mouseMovement = mouseHoverStartPoint - newPosition;
|
||||
Vector mouseMovement = mouseHoverStartPoint - e.GetPosition(this.target);
|
||||
if (Math.Abs(mouseMovement.X) > SystemParameters.MouseHoverWidth
|
||||
|| Math.Abs(mouseMovement.Y) > SystemParameters.MouseHoverHeight)
|
||||
{
|
||||
StopHovering();
|
||||
mouseHoverStartPoint = newPosition;
|
||||
mouseHoverLastEventArgs = e;
|
||||
mouseHoverTimer = new DispatcherTimer(SystemParameters.MouseHoverTime, DispatcherPriority.Background,
|
||||
OnMouseHoverTimerElapsed, this.target.Dispatcher);
|
||||
mouseHoverTimer.Start();
|
||||
StartHovering(e);
|
||||
}
|
||||
// do not set e.Handled - allow others to also handle MouseMove
|
||||
}
|
||||
|
||||
|
||||
void MouseHoverLogicMouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
StartHovering(e);
|
||||
// do not set e.Handled - allow others to also handle MouseEnter
|
||||
}
|
||||
|
||||
void StartHovering(MouseEventArgs e)
|
||||
{
|
||||
StopHovering();
|
||||
mouseHoverStartPoint = e.GetPosition(this.target);
|
||||
mouseHoverLastEventArgs = e;
|
||||
mouseHoverTimer = new DispatcherTimer(SystemParameters.MouseHoverTime, DispatcherPriority.Background, OnMouseHoverTimerElapsed, this.target.Dispatcher);
|
||||
mouseHoverTimer.Start();
|
||||
}
|
||||
|
||||
void MouseHoverLogicMouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
StopHovering();
|
||||
|
@ -116,6 +126,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
|
|||
if (!disposed) {
|
||||
this.target.MouseLeave -= MouseHoverLogicMouseLeave;
|
||||
this.target.MouseMove -= MouseHoverLogicMouseMove;
|
||||
this.target.MouseEnter -= MouseHoverLogicMouseEnter;
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче