/// <inheritdoc />
            public override TextCaret FromBlockCaret(BlockCaret caret)
            {
                if (caret.Mover != Instance)
                {
                    throw new ArgumentException("Caret does not represent the content of a TextCaret", nameof(caret));
                }

                var offset = new TextOffset(caret.InstanceOffset1, caret.InstanceOffset2, caret.InstanceOffset3);

                return(new TextCaret((TextBlockContent)caret.InstanceDatum, offset));
            }
Ejemplo n.º 2
0
        /// <summary> Removes the given number of characters. </summary>
        public void DeleteText(TextOffset start, TextOffset end)
        {
            var numberOfCharactersToRemove = end.CharOffset - start.CharOffset;

            if (numberOfCharactersToRemove == 0)
            {
                return;
            }

            _buffer.DeleteText(start, end);
            NotifyChanged();
        }
 private TextCaret(TextBlockContent content, TextOffset offset)
 {
     Content = content;
     Offset  = offset;
 }
 // <summary> Gets a cursor that is looking at the grapheme at the given index. </summary>
 public static TextCaret FromOffset(TextBlockContent span, TextOffset offset)
 {
     // TODO validate
     return(new TextCaret(span, offset));
 }
        /// <summary> Removes the given number of characters. </summary>
        /// <param name="start"> The location at which deletion should start. </param>
        /// <param name="end"> The location where deletion should end, exclusive. </param>
        public void DeleteText(TextOffset start, TextOffset end)
        {
            _text = _text.Remove(start.CharOffset, end.CharOffset - start.CharOffset);

            Recalculate();
        }