Merge remote-tracking branch 'origin/master' into newNR
This commit is contained in:
Коммит
774a5524a6
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0"?>
|
||||
<SyntaxDefinition name="MarkDown" extensions=".md" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
|
||||
<Color name="Heading" foreground="Maroon" exampleText="# Title #" />
|
||||
<Color name="Emphasis" fontStyle="italic" exampleText="*this* is important!" />
|
||||
<Color name="StrongEmphasis" fontWeight="bold" exampleText="**this** is more important!" />
|
||||
<Color name="Code" exampleText="this is `int.GetHashCode()`" />
|
||||
<Color name="BlockQuote" foreground="DarkBlue" exampleText="> This is a\r\n> quote." />
|
||||
<Color name="Link" foreground="Blue" exampleText="[text](http://example.com)" />
|
||||
<Color name="Image" foreground="Green" exampleText="[text][http://example.com/test.png]" />
|
||||
<Color name="LineBreak" background="LightGray" exampleText="end of line \r\n2nd line " />
|
||||
|
||||
<RuleSet ignoreCase="true">
|
||||
<Rule color="Heading">
|
||||
^\#.*
|
||||
</Rule>
|
||||
<Rule color="StrongEmphasis">
|
||||
\*\*.*\*\*
|
||||
</Rule>
|
||||
<Rule color="StrongEmphasis">
|
||||
__.*__
|
||||
</Rule>
|
||||
<Rule color="Emphasis">
|
||||
\*(?![ ]).*\*
|
||||
</Rule>
|
||||
<Rule color="Emphasis">
|
||||
_.*_
|
||||
</Rule>
|
||||
<Rule color="Code">
|
||||
`.*`
|
||||
</Rule>
|
||||
<Span color="Code" ruleSet="C#/" multiline="true">
|
||||
<Begin>^\t</Begin>
|
||||
<End>^(?!\t)</End>
|
||||
</Span>
|
||||
<Span color="Code" ruleSet="C#/" multiline="true">
|
||||
<Begin>^[ ]{4}</Begin>
|
||||
<End>^(?![ ]{4})</End>
|
||||
</Span>
|
||||
<Span color="BlockQuote" multiline="true">
|
||||
<Begin>^></Begin>
|
||||
<End>^(?!>)</End>
|
||||
</Span>
|
||||
<Rule color="Image">
|
||||
\!\[.*\]\[.*\]
|
||||
</Rule>
|
||||
<Rule color="Link">
|
||||
\[.*\]\(.*\)
|
||||
</Rule>
|
||||
<Rule color="Link">
|
||||
\[.*\]\[.*\]
|
||||
</Rule>
|
||||
<Rule color="LineBreak">
|
||||
[ ]{2}$
|
||||
</Rule>
|
||||
</RuleSet>
|
||||
</SyntaxDefinition>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xsd:schema targetNamespace="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<xsd:schema version="2" elementFormDefault="qualified" targetNamespace="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- Font Weight -->
|
||||
<xsd:simpleType name="FontWeight">
|
||||
<xsd:union>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<xsd:enumeration value="bold"/>
|
||||
<xsd:enumeration value="normal"/>
|
||||
<xsd:enumeration value="regular"/>
|
||||
<!-- should we support other font weigth names? -->
|
||||
<!-- should we support other font weight names? -->
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:union>
|
||||
|
@ -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:anyAttribute namespace="##other" processContents="lax" />
|
||||
</xsd:attributeGroup>
|
||||
|
||||
<xsd:attributeGroup name="ColorReferenceAttributes">
|
||||
|
@ -54,6 +55,7 @@
|
|||
<xsd:complexType>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="value" type="xsd:string" use="required" />
|
||||
<xsd:anyAttribute namespace="##other" processContents="lax" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
@ -76,7 +78,15 @@
|
|||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="Word" type="xsd:string"/>
|
||||
<xsd:element name="Word">
|
||||
<xsd:complexType>
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:string">
|
||||
<xsd:anyAttribute namespace="##other" processContents="lax" />
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<!-- Spans -->
|
||||
<xsd:element name="Span">
|
||||
|
@ -132,9 +142,11 @@
|
|||
<xsd:element ref="Span"/>
|
||||
<xsd:element ref="Import"/>
|
||||
<xsd:element ref="Rule"/>
|
||||
<xsd:any namespace="##other" processContents="lax" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="name" type="xsd:string" use="optional" />
|
||||
<xsd:attribute name="ignoreCase" type="xsd:boolean" use="optional" />
|
||||
<xsd:anyAttribute namespace="##other" processContents="lax" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
@ -145,9 +157,11 @@
|
|||
<xsd:element ref="Property"/>
|
||||
<xsd:element ref="Color"/>
|
||||
<xsd:element ref="RuleSet"/>
|
||||
<xsd:any namespace="##other" processContents="lax" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="name" type="xsd:string" use="optional" />
|
||||
<xsd:attribute name="extensions" type="xsd:string" use="optional" />
|
||||
<xsd:anyAttribute namespace="##other" processContents="lax" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
|
@ -42,6 +42,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
|
|||
".booproj;.build;.xfrm;.targets;.xaml;.xpt;" +
|
||||
".xft;.map;.wsdl;.disco;.ps1xml;.nuspec").Split(';'),
|
||||
"XML-Mode.xshd");
|
||||
hlm.RegisterHighlighting("MarkDown", new[] { ".md" }, "MarkDown-Mode.xshd");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
|
|||
return;
|
||||
while (reader.Read() && reader.NodeType != XmlNodeType.EndElement) {
|
||||
Debug.Assert(reader.NodeType == XmlNodeType.Element);
|
||||
if (reader.NamespaceURI != Namespace) {
|
||||
if (!reader.IsEmptyElement)
|
||||
reader.Skip();
|
||||
continue;
|
||||
}
|
||||
switch (reader.Name) {
|
||||
case "RuleSet":
|
||||
c.Add(ParseRuleSet(reader));
|
||||
|
|
|
@ -446,4 +446,7 @@
|
|||
<ItemGroup>
|
||||
<EmbeddedResource Include="Highlighting\Resources\PowerShell.xshd" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Highlighting\Resources\MarkDown-Mode.xshd" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -74,7 +74,8 @@ namespace ICSharpCode.AvalonEdit.Search
|
|||
void ExecuteFind(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
panel.Open();
|
||||
panel.SearchPattern = TextArea.Selection.GetText();
|
||||
if (!(TextArea.Selection.IsEmpty || TextArea.Selection.IsMultiline))
|
||||
panel.SearchPattern = TextArea.Selection.GetText();
|
||||
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, (Action)delegate { panel.Reactivate(); });
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ namespace ICSharpCode.AvalonEdit.Search
|
|||
TextArea textArea;
|
||||
TextDocument currentDocument;
|
||||
SearchResultBackgroundRenderer renderer;
|
||||
SearchResult currentResult;
|
||||
TextBox searchTextBox;
|
||||
SearchPanelAdorner adorner;
|
||||
|
||||
|
@ -176,15 +175,13 @@ namespace ICSharpCode.AvalonEdit.Search
|
|||
if (textArea == null)
|
||||
throw new ArgumentNullException("textArea");
|
||||
this.textArea = textArea;
|
||||
var layer = AdornerLayer.GetAdornerLayer(textArea);
|
||||
adorner = new SearchPanelAdorner(textArea, this);
|
||||
if (layer != null)
|
||||
layer.Add(adorner);
|
||||
DataContext = this;
|
||||
|
||||
renderer = new SearchResultBackgroundRenderer();
|
||||
currentDocument = textArea.Document;
|
||||
currentDocument.TextChanged += textArea_Document_TextChanged;
|
||||
if (currentDocument != null)
|
||||
currentDocument.TextChanged += textArea_Document_TextChanged;
|
||||
textArea.DocumentChanged += textArea_DocumentChanged;
|
||||
KeyDown += SearchLayerKeyDown;
|
||||
|
||||
|
@ -251,8 +248,7 @@ namespace ICSharpCode.AvalonEdit.Search
|
|||
if (result == null)
|
||||
result = renderer.CurrentResults.FirstSegment;
|
||||
if (result != null) {
|
||||
currentResult = result;
|
||||
SetResult(result);
|
||||
SelectResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,8 +263,7 @@ namespace ICSharpCode.AvalonEdit.Search
|
|||
if (result == null)
|
||||
result = renderer.CurrentResults.LastSegment;
|
||||
if (result != null) {
|
||||
currentResult = result;
|
||||
SetResult(result);
|
||||
SelectResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,20 +271,20 @@ namespace ICSharpCode.AvalonEdit.Search
|
|||
|
||||
void DoSearch(bool changeSelection)
|
||||
{
|
||||
if (IsClosed)
|
||||
return;
|
||||
renderer.CurrentResults.Clear();
|
||||
currentResult = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(SearchPattern)) {
|
||||
int offset = textArea.Caret.Offset;
|
||||
if (changeSelection) {
|
||||
textArea.ClearSelection();
|
||||
}
|
||||
// We cast from ISearchResult to SearchResult; this is safe because we always use the built-in strategy
|
||||
foreach (SearchResult result in strategy.FindAll(textArea.Document, 0, textArea.Document.TextLength)) {
|
||||
if (currentResult == null && result.StartOffset >= offset) {
|
||||
currentResult = result;
|
||||
if (changeSelection) {
|
||||
SetResult(result);
|
||||
}
|
||||
if (changeSelection && result.StartOffset >= offset) {
|
||||
SelectResult(result);
|
||||
changeSelection = false;
|
||||
}
|
||||
renderer.CurrentResults.Add(result);
|
||||
}
|
||||
|
@ -303,15 +298,10 @@ namespace ICSharpCode.AvalonEdit.Search
|
|||
textArea.TextView.InvalidateLayer(KnownLayer.Selection);
|
||||
}
|
||||
|
||||
void SetResult(SearchResult result)
|
||||
void SelectResult(SearchResult result)
|
||||
{
|
||||
textArea.Caret.Offset = currentResult.StartOffset;
|
||||
textArea.Selection = Selection.Create(textArea, currentResult.StartOffset, currentResult.EndOffset);
|
||||
var foldingManager = textArea.GetService(typeof(FoldingManager)) as FoldingManager;
|
||||
if (foldingManager != null) {
|
||||
foreach (var folding in foldingManager.GetFoldingsContaining(result.StartOffset))
|
||||
folding.IsFolded = false;
|
||||
}
|
||||
textArea.Caret.Offset = result.StartOffset;
|
||||
textArea.Selection = Selection.Create(textArea, result.StartOffset, result.EndOffset);
|
||||
textArea.Caret.BringCaretToView();
|
||||
// show caret even if the editor does not have the Keyboard Focus
|
||||
textArea.Caret.Show();
|
||||
|
@ -353,13 +343,19 @@ namespace ICSharpCode.AvalonEdit.Search
|
|||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
bool hasFocus = this.IsKeyboardFocusWithin;
|
||||
|
||||
var layer = AdornerLayer.GetAdornerLayer(textArea);
|
||||
if (layer != null)
|
||||
layer.Remove(adorner);
|
||||
messageView.IsOpen = false;
|
||||
textArea.TextView.BackgroundRenderers.Remove(renderer);
|
||||
textArea.Focus();
|
||||
if (hasFocus)
|
||||
textArea.Focus();
|
||||
IsClosed = true;
|
||||
|
||||
// Clear existing search results so that the segments don't have to be maintained
|
||||
renderer.CurrentResults.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -384,6 +380,7 @@ namespace ICSharpCode.AvalonEdit.Search
|
|||
layer.Add(adorner);
|
||||
textArea.TextView.BackgroundRenderers.Add(renderer);
|
||||
IsClosed = false;
|
||||
DoSearch(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Загрузка…
Ссылка в новой задаче