diff --git a/build.cake b/build.cake
index d161c82c..54d1e433 100644
--- a/build.cake
+++ b/build.cake
@@ -182,7 +182,7 @@ var nuspecNuGetBehaviors = new NuGetPackSettings()
},
Files = new []
{
- new NuSpecContent { Source = "src/AvaloniaEdit/bin/" + configuration + "/netstandard1.1/AvaloniaEdit.dll", Target = "lib/netstandard1.1" },
+ new NuSpecContent { Source = "src/AvaloniaEdit/bin/" + configuration + "/netstandard1.3/AvaloniaEdit.dll", Target = "lib/netstandard1.3" },
},
BasePath = Directory("./"),
OutputDirectory = nugetRoot
diff --git a/src/AvaloniaEdit/AvaloniaEdit.csproj b/src/AvaloniaEdit/AvaloniaEdit.csproj
index 83f47170..4e8edd77 100644
--- a/src/AvaloniaEdit/AvaloniaEdit.csproj
+++ b/src/AvaloniaEdit/AvaloniaEdit.csproj
@@ -1,43 +1,17 @@
- netstandard1.1
+ netstandard1.3
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
\ No newline at end of file
diff --git a/src/AvaloniaEdit/Document/TextLocation.cs b/src/AvaloniaEdit/Document/TextLocation.cs
index 12d34461..28ce4f50 100644
--- a/src/AvaloniaEdit/Document/TextLocation.cs
+++ b/src/AvaloniaEdit/Document/TextLocation.cs
@@ -18,7 +18,8 @@
using System;
using System.Globalization;
-using OmniXaml.TypeConversion;
+using System.ComponentModel;
+using Portable.Xaml.ComponentModel;
namespace AvaloniaEdit.Document
{
@@ -167,22 +168,22 @@ public int CompareTo(TextLocation other)
///
/// Converts strings of the form '0+[;,]0+' to a .
///
- public class TextLocationConverter : ITypeConverter
+ public class TextLocationConverter : TypeConverter
{
///
- public bool CanConvertFrom(IValueContext context, Type sourceType)
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string);
}
///
- public bool CanConvertTo(IValueContext context, Type destinationType)
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(TextLocation);
}
///
- public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var s = value as string;
var parts = s?.Split(';', ',');
@@ -194,7 +195,7 @@ public object ConvertFrom(IValueContext context, CultureInfo culture, object val
}
///
- public object ConvertTo(IValueContext context, CultureInfo culture, object value, Type destinationType)
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is TextLocation loc && destinationType == typeof(string))
{
diff --git a/src/AvaloniaEdit/Editing/AbstractMargin.cs b/src/AvaloniaEdit/Editing/AbstractMargin.cs
index b530fc82..92dfc716 100644
--- a/src/AvaloniaEdit/Editing/AbstractMargin.cs
+++ b/src/AvaloniaEdit/Editing/AbstractMargin.cs
@@ -34,16 +34,22 @@ namespace AvaloniaEdit.Editing
///
public abstract class AbstractMargin : Control, ITextViewConnect
{
- static AbstractMargin()
+ private TextArea _textArea;
+
+ public AbstractMargin()
{
- TextViewProperty.Changed.Subscribe(OnTextViewChanged);
+ this.GetObservableWithHistory(TextViewProperty).Subscribe(o =>
+ {
+ _wasAutoAddedToTextView = false;
+ OnTextViewChanged(o.Item1, o.Item2);
+ });
}
///
/// TextView property.
///
public static readonly AvaloniaProperty TextViewProperty =
- AvaloniaProperty.Register("TextView");
+ AvaloniaProperty.Register(nameof(TextView));
///
/// Gets/sets the text view for which line numbers are displayed.
@@ -55,13 +61,6 @@ public TextView TextView
set => SetValue(TextViewProperty, value);
}
- private static void OnTextViewChanged(AvaloniaPropertyChangedEventArgs e)
- {
- var margin = (AbstractMargin)e.Sender;
- margin._wasAutoAddedToTextView = false;
- margin.OnTextViewChanged((TextView)e.OldValue, (TextView)e.NewValue);
- }
-
// automatically set/unset TextView property using ITextViewConnect
private bool _wasAutoAddedToTextView;
@@ -110,6 +109,37 @@ protected virtual void OnTextViewChanged(TextView oldTextView, TextView newTextV
}
TextViewDocumentChanged(null, null);
+
+ if (oldTextView != null)
+ {
+ oldTextView.VisualLinesChanged -= TextViewVisualLinesChanged;
+ }
+
+ if (newTextView != null)
+ {
+ newTextView.VisualLinesChanged += TextViewVisualLinesChanged;
+
+ // find the text area belonging to the new text view
+ _textArea = newTextView.GetService(typeof(TextArea)) as TextArea;
+ }
+ else
+ {
+ _textArea = null;
+ }
+ }
+
+ ///
+ /// Called when the attached textviews visual lines change.
+ /// Default behavior is to Invalidate Margins Visual.
+ ///
+ protected virtual void OnTextViewVisualLinesChanged()
+ {
+ InvalidateVisual();
+ }
+
+ private void TextViewVisualLinesChanged(object sender, EventArgs e)
+ {
+ OnTextViewVisualLinesChanged();
}
private void TextViewDocumentChanged(object sender, EventArgs e)
diff --git a/src/AvaloniaEdit/Editing/EditingCommandHandler.cs b/src/AvaloniaEdit/Editing/EditingCommandHandler.cs
index b9ee0953..5c0549aa 100644
--- a/src/AvaloniaEdit/Editing/EditingCommandHandler.cs
+++ b/src/AvaloniaEdit/Editing/EditingCommandHandler.cs
@@ -24,6 +24,7 @@
using AvaloniaEdit.Document;
using Avalonia.Input;
using AvaloniaEdit.Utils;
+using System.Threading.Tasks;
namespace AvaloniaEdit.Editing
{
@@ -469,26 +470,26 @@ private static void CanPaste(object target, CanExecuteRoutedEventArgs args)
var textArea = GetTextArea(target);
if (textArea?.Document != null)
{
- args.CanExecute = textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset)
- && !string.IsNullOrEmpty(Application.Current.Clipboard.GetTextAsync()
- .GetAwaiter()
- .GetResult());
+ args.CanExecute = textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset);
args.Handled = true;
}
}
- private static void OnPaste(object target, ExecutedRoutedEventArgs args)
+ private static async void OnPaste(object target, ExecutedRoutedEventArgs args)
{
var textArea = GetTextArea(target);
if (textArea?.Document != null)
{
- string text;
+ textArea.Document.BeginUpdate();
+
+ string text = null;
try
{
- text = Application.Current.Clipboard.GetTextAsync().GetAwaiter().GetResult();
+ text = await Application.Current.Clipboard.GetTextAsync();
}
catch (Exception)
{
+ textArea.Document.EndUpdate();
return;
}
@@ -505,6 +506,8 @@ private static void OnPaste(object target, ExecutedRoutedEventArgs args)
textArea.Caret.BringCaretToView();
args.Handled = true;
+
+ textArea.Document.EndUpdate();
}
}
diff --git a/src/AvaloniaEdit/Editing/LineNumberMargin.cs b/src/AvaloniaEdit/Editing/LineNumberMargin.cs
index 54e692f5..df04bbaf 100644
--- a/src/AvaloniaEdit/Editing/LineNumberMargin.cs
+++ b/src/AvaloniaEdit/Editing/LineNumberMargin.cs
@@ -87,28 +87,6 @@ public override void Render(DrawingContext drawingContext)
}
}
- ///
- protected override void OnTextViewChanged(TextView oldTextView, TextView newTextView)
- {
- if (oldTextView != null)
- {
- oldTextView.VisualLinesChanged -= TextViewVisualLinesChanged;
- }
- base.OnTextViewChanged(oldTextView, newTextView);
- if (newTextView != null)
- {
- newTextView.VisualLinesChanged += TextViewVisualLinesChanged;
-
- // find the text area belonging to the new text view
- _textArea = newTextView.GetService(typeof(TextArea)) as TextArea;
- }
- else
- {
- _textArea = null;
- }
- InvalidateVisual();
- }
-
///
protected override void OnDocumentChanged(TextDocument oldDocument, TextDocument newDocument)
{
@@ -151,11 +129,6 @@ private void OnDocumentLineCountChanged()
}
}
- private void TextViewVisualLinesChanged(object sender, EventArgs e)
- {
- InvalidateVisual();
- }
-
private AnchorSegment _selectionStart;
private bool _selecting;
diff --git a/src/AvaloniaEdit/Folding/FoldingMargin.cs b/src/AvaloniaEdit/Folding/FoldingMargin.cs
index b15f7498..380ca84f 100644
--- a/src/AvaloniaEdit/Folding/FoldingMargin.cs
+++ b/src/AvaloniaEdit/Folding/FoldingMargin.cs
@@ -160,24 +160,9 @@ protected override Size ArrangeOverride(Size finalSize)
return base.ArrangeOverride(finalSize);
}
- ///
- protected override void OnTextViewChanged(TextView oldTextView, TextView newTextView)
- {
- if (oldTextView != null)
- {
- oldTextView.VisualLinesChanged -= TextViewVisualLinesChanged;
- }
- base.OnTextViewChanged(oldTextView, newTextView);
- if (newTextView != null)
- {
- newTextView.VisualLinesChanged += TextViewVisualLinesChanged;
- }
- TextViewVisualLinesChanged(null, null);
- }
-
private readonly List _markers = new List();
- private void TextViewVisualLinesChanged(object sender, EventArgs e)
+ protected override void OnTextViewVisualLinesChanged()
{
foreach (var m in _markers)
{
diff --git a/src/AvaloniaEdit/Highlighting/HighlightingDefinitionTypeConverter.cs b/src/AvaloniaEdit/Highlighting/HighlightingDefinitionTypeConverter.cs
index 3c9a9471..8a91ce09 100644
--- a/src/AvaloniaEdit/Highlighting/HighlightingDefinitionTypeConverter.cs
+++ b/src/AvaloniaEdit/Highlighting/HighlightingDefinitionTypeConverter.cs
@@ -17,8 +17,8 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.ComponentModel;
using System.Globalization;
-using OmniXaml.TypeConversion;
namespace AvaloniaEdit.Highlighting
{
@@ -26,33 +26,33 @@ namespace AvaloniaEdit.Highlighting
/// Converts between strings and by treating the string as the definition name
/// and calling HighlightingManager.Instance.GetDefinition(name).
///
- public sealed class HighlightingDefinitionTypeConverter : ITypeConverter
+ public sealed class HighlightingDefinitionTypeConverter : TypeConverter
{
- ///
- public bool CanConvertFrom(IValueContext context, Type sourceType)
- {
- return sourceType == typeof(string);
- }
-
- ///
- public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
- {
- string definitionName = value as string;
- return definitionName != null ? HighlightingManager.Instance.GetDefinition(definitionName) : null;
- }
-
- ///
- public bool CanConvertTo(IValueContext context, Type destinationType)
- {
- return destinationType == typeof(string);
- }
-
- ///
- public object ConvertTo(IValueContext context, CultureInfo culture, object value, Type destinationType)
- {
+ ///
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ return sourceType == typeof(string);
+ }
+
+ ///
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ string definitionName = value as string;
+ return definitionName != null ? HighlightingManager.Instance.GetDefinition(definitionName) : null;
+ }
+
+ ///
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
+ {
+ return destinationType == typeof(string);
+ }
+
+ ///
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
if (value is IHighlightingDefinition definition && destinationType == typeof(string))
return definition.Name;
return null;
- }
+ }
}
}
diff --git a/src/AvaloniaEdit/Highlighting/IHighlightingDefinition.cs b/src/AvaloniaEdit/Highlighting/IHighlightingDefinition.cs
index 6dd0f017..576000f1 100644
--- a/src/AvaloniaEdit/Highlighting/IHighlightingDefinition.cs
+++ b/src/AvaloniaEdit/Highlighting/IHighlightingDefinition.cs
@@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
-using OmniXaml.TypeConversion;
+using System.ComponentModel;
namespace AvaloniaEdit.Highlighting
{