Browse Source

Fixed ArgumentOutOfRangeException in Caret when closing a folding section.

Added IsReadOnly property to AvalonEdit.TextEditor.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4839 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
c7173845cf
  1. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
  2. 19
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/NoReadOnlySections.cs
  3. 28
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs
  4. 2
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs

@ -46,6 +46,10 @@ namespace ICSharpCode.AvalonEdit.Editing
if (visible) { if (visible) {
Show(); Show();
} }
// required because the visual columns might have changed if the
// element generators did something differently than on the last run
// (e.g. a FoldingSection was collapsed)
InvalidateVisualColumn();
} }
void TextView_ScrollOffsetChanged(object sender, EventArgs e) void TextView_ScrollOffsetChanged(object sender, EventArgs e)

19
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/NoReadOnlySections.cs

@ -6,6 +6,7 @@
// </file> // </file>
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
@ -32,4 +33,22 @@ namespace ICSharpCode.AvalonEdit.Editing
return ExtensionMethods.Sequence(segment); return ExtensionMethods.Sequence(segment);
} }
} }
/// <summary>
/// <see cref="IReadOnlySectionProvider"/> that completely disables editing.
/// </summary>
sealed class ReadOnlyDocument : IReadOnlySectionProvider
{
public static readonly ReadOnlyDocument Instance = new ReadOnlyDocument();
public bool CanInsert(int offset)
{
return false;
}
public IEnumerable<ISegment> GetDeletableSegments(ISegment segment)
{
return Enumerable.Empty<ISegment>();
}
}
} }

28
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs

@ -326,6 +326,34 @@ namespace ICSharpCode.AvalonEdit
} }
#endregion #endregion
#region IsReadOnly
/// <summary>
/// IsReadOnly dependency property.
/// </summary>
public static readonly DependencyProperty IsReadOnlyProperty =
DependencyProperty.Register("IsReadOnly", typeof(bool), typeof(TextEditor),
new FrameworkPropertyMetadata(Boxes.False, OnIsReadOnlyChanged));
/// <summary>
/// Specifies whether the user can change the text editor content.
/// Setting this property will replace the
/// <see cref="Editing.TextArea.ReadOnlySectionProvider">TextArea.ReadOnlySectionProvider</see>.
/// </summary>
public bool IsReadOnly {
get { return (bool)GetValue(IsReadOnlyProperty); }
set { SetValue(IsReadOnlyProperty, Boxes.Box(value)); }
}
static void OnIsReadOnlyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TextEditor editor = (TextEditor)d;
if ((bool)e.NewValue)
editor.TextArea.ReadOnlySectionProvider = NoReadOnlySections.Instance;
else
editor.TextArea.ReadOnlySectionProvider = NoReadOnlySections.Instance;
}
#endregion
#region TextBoxBase-like methods #region TextBoxBase-like methods
/// <summary> /// <summary>
/// Appends text to the end of the document. /// Appends text to the end of the document.

2
src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs

@ -218,7 +218,7 @@ namespace ICSharpCode.SharpDevelop.Sda
if (MessageBox.Show(StringParser.Parse("${res:ICSharpCode.SharpDevelop.ExceptionBox.QuitWarning}"), MessageService.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly) if (MessageBox.Show(StringParser.Parse("${res:ICSharpCode.SharpDevelop.ExceptionBox.QuitWarning}"), MessageService.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly)
== DialogResult.Yes) == DialogResult.Yes)
{ {
Application.Exit(); Process.GetCurrentProcess().Kill();
} }
} }

Loading…
Cancel
Save