// 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;
using System.Linq;
using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Editing
{
///
/// that has no read-only sections; all text is editable.
///
sealed class NoReadOnlySections : IReadOnlySectionProvider
{
public static readonly NoReadOnlySections Instance = new NoReadOnlySections();
public bool CanInsert(int offset)
{
return true;
}
public IEnumerable GetDeletableSegments(ISegment segment)
{
if (segment == null)
throw new ArgumentNullException("segment");
// the segment is always deletable
return ExtensionMethods.Sequence(segment);
}
}
///
/// that completely disables editing.
///
sealed class ReadOnlyDocument : IReadOnlySectionProvider
{
public static readonly ReadOnlyDocument Instance = new ReadOnlyDocument();
public bool CanInsert(int offset)
{
return false;
}
public IEnumerable GetDeletableSegments(ISegment segment)
{
return Enumerable.Empty();
}
}
}