Skip to content

Commit 8b9875c

Browse files
author
danwalmsley
authored
Merge pull request #41 from danwalmsley/netstandard1.3
Netstandard1.3
2 parents 161fdc9 + c34fac2 commit 8b9875c

9 files changed

Lines changed: 88 additions & 122 deletions

File tree

build.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ var nuspecNuGetBehaviors = new NuGetPackSettings()
182182
},
183183
Files = new []
184184
{
185-
new NuSpecContent { Source = "src/AvaloniaEdit/bin/" + configuration + "/netstandard1.1/AvaloniaEdit.dll", Target = "lib/netstandard1.1" },
185+
new NuSpecContent { Source = "src/AvaloniaEdit/bin/" + configuration + "/netstandard1.3/AvaloniaEdit.dll", Target = "lib/netstandard1.3" },
186186
},
187187
BasePath = Directory("./"),
188188
OutputDirectory = nugetRoot
Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard1.1</TargetFramework>
4+
<TargetFramework>netstandard1.3</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<EmbeddedResource Include="Editing\TextArea.xaml" />
9-
<EmbeddedResource Include="TextEditor.xaml" />
10-
<EmbeddedResource Include="AvaloniaEdit.xaml" />
11-
<EmbeddedResource Include="CodeCompletion\CompletionList.xaml" />
12-
<EmbeddedResource Include="CodeCompletion\InsightWindow.xaml" />
13-
</ItemGroup>
14-
15-
<ItemGroup>
16-
<EmbeddedResource Include="Highlighting\Resources\ASPX.xshd" />
17-
<EmbeddedResource Include="Highlighting\Resources\Boo.xshd" />
18-
<EmbeddedResource Include="Highlighting\Resources\Coco-Mode.xshd" />
19-
<EmbeddedResource Include="Highlighting\Resources\CPP-Mode.xshd" />
20-
<EmbeddedResource Include="Highlighting\Resources\CSharp-Mode.xshd" />
21-
<EmbeddedResource Include="Highlighting\Resources\CSS-Mode.xshd" />
22-
<EmbeddedResource Include="Highlighting\Resources\HTML-Mode.xshd" />
23-
<EmbeddedResource Include="Highlighting\Resources\Java-Mode.xshd" />
24-
<EmbeddedResource Include="Highlighting\Resources\JavaScript-Mode.xshd" />
25-
<EmbeddedResource Include="Highlighting\Resources\MarkDown-Mode.xshd" />
26-
<EmbeddedResource Include="Highlighting\Resources\ModeV1.xsd" />
27-
<EmbeddedResource Include="Highlighting\Resources\ModeV2.xsd" />
28-
<EmbeddedResource Include="Highlighting\Resources\Patch-Mode.xshd" />
29-
<EmbeddedResource Include="Highlighting\Resources\PHP-Mode.xshd" />
30-
<EmbeddedResource Include="Highlighting\Resources\PowerShell.xshd" />
31-
<EmbeddedResource Include="Highlighting\Resources\Tex-Mode.xshd" />
32-
<EmbeddedResource Include="Highlighting\Resources\VB-Mode.xshd" />
33-
<EmbeddedResource Include="Highlighting\Resources\XML-Mode.xshd" />
34-
<EmbeddedResource Include="Highlighting\Resources\XmlDoc.xshd" />
8+
<EmbeddedResource Include="**\*.xshd;**\*.resx;**\*.xaml;Assets\*;**\*.paml" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
359
</ItemGroup>
3610

3711
<ItemGroup>
3812
<PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
3913
<PackageReference Include="System.Xml.ReaderWriter" Version="4.3.0" />
40-
<PackageReference Include="Avalonia" Version="0.5.1-build3466-alpha" />
14+
<PackageReference Include="Avalonia" Version="0.5.1-build3595-alpha" />
4115
</ItemGroup>
4216

4317
</Project>

src/AvaloniaEdit/Document/TextLocation.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
using System;
2020
using System.Globalization;
21-
using OmniXaml.TypeConversion;
21+
using System.ComponentModel;
22+
using Portable.Xaml.ComponentModel;
2223

2324
namespace AvaloniaEdit.Document
2425
{
@@ -167,22 +168,22 @@ public int CompareTo(TextLocation other)
167168
/// <summary>
168169
/// Converts strings of the form '0+[;,]0+' to a <see cref="TextLocation"/>.
169170
/// </summary>
170-
public class TextLocationConverter : ITypeConverter
171+
public class TextLocationConverter : TypeConverter
171172
{
172173
/// <inheritdoc/>
173-
public bool CanConvertFrom(IValueContext context, Type sourceType)
174+
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
174175
{
175176
return sourceType == typeof(string);
176177
}
177178

178179
/// <inheritdoc/>
179-
public bool CanConvertTo(IValueContext context, Type destinationType)
180+
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
180181
{
181182
return destinationType == typeof(TextLocation);
182183
}
183184

184185
/// <inheritdoc/>
185-
public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
186+
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
186187
{
187188
var s = value as string;
188189
var parts = s?.Split(';', ',');
@@ -194,7 +195,7 @@ public object ConvertFrom(IValueContext context, CultureInfo culture, object val
194195
}
195196

196197
/// <inheritdoc/>
197-
public object ConvertTo(IValueContext context, CultureInfo culture, object value, Type destinationType)
198+
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
198199
{
199200
if (value is TextLocation loc && destinationType == typeof(string))
200201
{

src/AvaloniaEdit/Editing/AbstractMargin.cs

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,22 @@ namespace AvaloniaEdit.Editing
3434
/// </summary>
3535
public abstract class AbstractMargin : Control, ITextViewConnect
3636
{
37-
static AbstractMargin()
37+
private TextArea _textArea;
38+
39+
public AbstractMargin()
3840
{
39-
TextViewProperty.Changed.Subscribe(OnTextViewChanged);
41+
this.GetObservableWithHistory(TextViewProperty).Subscribe(o =>
42+
{
43+
_wasAutoAddedToTextView = false;
44+
OnTextViewChanged(o.Item1, o.Item2);
45+
});
4046
}
4147

4248
/// <summary>
4349
/// TextView property.
4450
/// </summary>
4551
public static readonly AvaloniaProperty<TextView> TextViewProperty =
46-
AvaloniaProperty.Register<AbstractMargin, TextView>("TextView");
52+
AvaloniaProperty.Register<AbstractMargin, TextView>(nameof(TextView));
4753

4854
/// <summary>
4955
/// Gets/sets the text view for which line numbers are displayed.
@@ -55,13 +61,6 @@ public TextView TextView
5561
set => SetValue(TextViewProperty, value);
5662
}
5763

58-
private static void OnTextViewChanged(AvaloniaPropertyChangedEventArgs e)
59-
{
60-
var margin = (AbstractMargin)e.Sender;
61-
margin._wasAutoAddedToTextView = false;
62-
margin.OnTextViewChanged((TextView)e.OldValue, (TextView)e.NewValue);
63-
}
64-
6564
// automatically set/unset TextView property using ITextViewConnect
6665
private bool _wasAutoAddedToTextView;
6766

@@ -110,6 +109,37 @@ protected virtual void OnTextViewChanged(TextView oldTextView, TextView newTextV
110109
}
111110

112111
TextViewDocumentChanged(null, null);
112+
113+
if (oldTextView != null)
114+
{
115+
oldTextView.VisualLinesChanged -= TextViewVisualLinesChanged;
116+
}
117+
118+
if (newTextView != null)
119+
{
120+
newTextView.VisualLinesChanged += TextViewVisualLinesChanged;
121+
122+
// find the text area belonging to the new text view
123+
_textArea = newTextView.GetService(typeof(TextArea)) as TextArea;
124+
}
125+
else
126+
{
127+
_textArea = null;
128+
}
129+
}
130+
131+
/// <summary>
132+
/// Called when the attached textviews visual lines change.
133+
/// Default behavior is to Invalidate Margins Visual.
134+
/// </summary>
135+
protected virtual void OnTextViewVisualLinesChanged()
136+
{
137+
InvalidateVisual();
138+
}
139+
140+
private void TextViewVisualLinesChanged(object sender, EventArgs e)
141+
{
142+
OnTextViewVisualLinesChanged();
113143
}
114144

115145
private void TextViewDocumentChanged(object sender, EventArgs e)

src/AvaloniaEdit/Editing/EditingCommandHandler.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using AvaloniaEdit.Document;
2525
using Avalonia.Input;
2626
using AvaloniaEdit.Utils;
27+
using System.Threading.Tasks;
2728

2829
namespace AvaloniaEdit.Editing
2930
{
@@ -469,26 +470,26 @@ private static void CanPaste(object target, CanExecuteRoutedEventArgs args)
469470
var textArea = GetTextArea(target);
470471
if (textArea?.Document != null)
471472
{
472-
args.CanExecute = textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset)
473-
&& !string.IsNullOrEmpty(Application.Current.Clipboard.GetTextAsync()
474-
.GetAwaiter()
475-
.GetResult());
473+
args.CanExecute = textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset);
476474
args.Handled = true;
477475
}
478476
}
479477

480-
private static void OnPaste(object target, ExecutedRoutedEventArgs args)
478+
private static async void OnPaste(object target, ExecutedRoutedEventArgs args)
481479
{
482480
var textArea = GetTextArea(target);
483481
if (textArea?.Document != null)
484482
{
485-
string text;
483+
textArea.Document.BeginUpdate();
484+
485+
string text = null;
486486
try
487487
{
488-
text = Application.Current.Clipboard.GetTextAsync().GetAwaiter().GetResult();
488+
text = await Application.Current.Clipboard.GetTextAsync();
489489
}
490490
catch (Exception)
491491
{
492+
textArea.Document.EndUpdate();
492493
return;
493494
}
494495

@@ -505,6 +506,8 @@ private static void OnPaste(object target, ExecutedRoutedEventArgs args)
505506

506507
textArea.Caret.BringCaretToView();
507508
args.Handled = true;
509+
510+
textArea.Document.EndUpdate();
508511
}
509512
}
510513

src/AvaloniaEdit/Editing/LineNumberMargin.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,6 @@ public override void Render(DrawingContext drawingContext)
8787
}
8888
}
8989

90-
/// <inheritdoc/>
91-
protected override void OnTextViewChanged(TextView oldTextView, TextView newTextView)
92-
{
93-
if (oldTextView != null)
94-
{
95-
oldTextView.VisualLinesChanged -= TextViewVisualLinesChanged;
96-
}
97-
base.OnTextViewChanged(oldTextView, newTextView);
98-
if (newTextView != null)
99-
{
100-
newTextView.VisualLinesChanged += TextViewVisualLinesChanged;
101-
102-
// find the text area belonging to the new text view
103-
_textArea = newTextView.GetService(typeof(TextArea)) as TextArea;
104-
}
105-
else
106-
{
107-
_textArea = null;
108-
}
109-
InvalidateVisual();
110-
}
111-
11290
/// <inheritdoc/>
11391
protected override void OnDocumentChanged(TextDocument oldDocument, TextDocument newDocument)
11492
{
@@ -151,11 +129,6 @@ private void OnDocumentLineCountChanged()
151129
}
152130
}
153131

154-
private void TextViewVisualLinesChanged(object sender, EventArgs e)
155-
{
156-
InvalidateVisual();
157-
}
158-
159132
private AnchorSegment _selectionStart;
160133
private bool _selecting;
161134

src/AvaloniaEdit/Folding/FoldingMargin.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,9 @@ protected override Size ArrangeOverride(Size finalSize)
160160
return base.ArrangeOverride(finalSize);
161161
}
162162

163-
/// <inheritdoc/>
164-
protected override void OnTextViewChanged(TextView oldTextView, TextView newTextView)
165-
{
166-
if (oldTextView != null)
167-
{
168-
oldTextView.VisualLinesChanged -= TextViewVisualLinesChanged;
169-
}
170-
base.OnTextViewChanged(oldTextView, newTextView);
171-
if (newTextView != null)
172-
{
173-
newTextView.VisualLinesChanged += TextViewVisualLinesChanged;
174-
}
175-
TextViewVisualLinesChanged(null, null);
176-
}
177-
178163
private readonly List<FoldingMarginMarker> _markers = new List<FoldingMarginMarker>();
179164

180-
private void TextViewVisualLinesChanged(object sender, EventArgs e)
165+
protected override void OnTextViewVisualLinesChanged()
181166
{
182167
foreach (var m in _markers)
183168
{

src/AvaloniaEdit/Highlighting/HighlightingDefinitionTypeConverter.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,42 @@
1717
// DEALINGS IN THE SOFTWARE.
1818

1919
using System;
20+
using System.ComponentModel;
2021
using System.Globalization;
21-
using OmniXaml.TypeConversion;
2222

2323
namespace AvaloniaEdit.Highlighting
2424
{
2525
/// <summary>
2626
/// Converts between strings and <see cref="IHighlightingDefinition"/> by treating the string as the definition name
2727
/// and calling <c>HighlightingManager.Instance.<see cref="HighlightingManager.GetDefinition">GetDefinition</see>(name)</c>.
2828
/// </summary>
29-
public sealed class HighlightingDefinitionTypeConverter : ITypeConverter
29+
public sealed class HighlightingDefinitionTypeConverter : TypeConverter
3030
{
31-
/// <inheritdoc/>
32-
public bool CanConvertFrom(IValueContext context, Type sourceType)
33-
{
34-
return sourceType == typeof(string);
35-
}
36-
37-
/// <inheritdoc/>
38-
public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
39-
{
40-
string definitionName = value as string;
41-
return definitionName != null ? HighlightingManager.Instance.GetDefinition(definitionName) : null;
42-
}
43-
44-
/// <inheritdoc/>
45-
public bool CanConvertTo(IValueContext context, Type destinationType)
46-
{
47-
return destinationType == typeof(string);
48-
}
49-
50-
/// <inheritdoc/>
51-
public object ConvertTo(IValueContext context, CultureInfo culture, object value, Type destinationType)
52-
{
31+
/// <inheritdoc/>
32+
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
33+
{
34+
return sourceType == typeof(string);
35+
}
36+
37+
/// <inheritdoc/>
38+
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
39+
{
40+
string definitionName = value as string;
41+
return definitionName != null ? HighlightingManager.Instance.GetDefinition(definitionName) : null;
42+
}
43+
44+
/// <inheritdoc/>
45+
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
46+
{
47+
return destinationType == typeof(string);
48+
}
49+
50+
/// <inheritdoc/>
51+
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
52+
{
5353
if (value is IHighlightingDefinition definition && destinationType == typeof(string))
5454
return definition.Name;
5555
return null;
56-
}
56+
}
5757
}
5858
}

src/AvaloniaEdit/Highlighting/IHighlightingDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// DEALINGS IN THE SOFTWARE.
1818

1919
using System.Collections.Generic;
20-
using OmniXaml.TypeConversion;
20+
using System.ComponentModel;
2121

2222
namespace AvaloniaEdit.Highlighting
2323
{

0 commit comments

Comments
 (0)