Example #1
0
 internal void ReplaceSelectionWithText(string newText)
 {
     if (newText == null)
     {
         throw new ArgumentNullException("newText");
     }
     if (this.Document == null)
     {
         throw ThrowUtil.NoDocumentAssigned();
     }
     selection.ReplaceSelectionWithText(newText);
 }
Example #2
0
        internal void ReplaceSelectionWithText(string newText)
        {
            if (newText == null)
            {
                throw new ArgumentNullException("newText");
            }
            if (this.Document == null)
            {
                throw ThrowUtil.NoDocumentAssigned();
            }
            selection.ReplaceSelectionWithText(newText);

            DocumentLine line = this.Document.GetLineByNumber(this.Caret.Line);

            this.IndentationStrategy.OnLineChanged(this.Document, line, newText);
        }
Example #3
0
        internal void RemoveSelectedText()
        {
            if (this.Document == null)
            {
                throw ThrowUtil.NoDocumentAssigned();
            }
            selection.ReplaceSelectionWithText(string.Empty);

            if (!selection.IsEmpty)
            {
                foreach (ISegment s in selection.Segments)
                {
                    Debug.Assert(this.ReadOnlySectionProvider.GetDeletableSegments(s).Count() == 0);
                }
            }
        }
Example #4
0
 internal void RemoveSelectedText()
 {
     if (this.Document == null)
     {
         throw ThrowUtil.NoDocumentAssigned();
     }
     selection.RemoveSelectedText(this);
                 #if DEBUG
     if (!selection.IsEmpty)
     {
         foreach (ISegment s in selection.Segments)
         {
             Debug.Assert(ReadOnlySectionProvider.GetDeletableSegments(s).Count() == 0);
         }
     }
                 #endif
 }
Example #5
0
 internal void ReplaceSelectionWithText(string newText)
 {
     if (newText == null)
     {
         throw new ArgumentNullException("newText");
     }
     if (this.Document == null)
     {
         throw ThrowUtil.NoDocumentAssigned();
     }
     using (this.Document.RunUpdate()) {
         RemoveSelectedText();
         if (newText.Length > 0)
         {
             if (ReadOnlySectionProvider.CanInsert(Caret.Offset))
             {
                 this.Document.Insert(Caret.Offset, newText);
             }
         }
     }
 }
Example #6
0
        /// <summary>
        /// Gets the selected text.
        /// </summary>
        public virtual string GetText()
        {
            var document = textArea.Document;

            if (document == null)
            {
                throw ThrowUtil.NoDocumentAssigned();
            }
            StringBuilder b    = null;
            string        text = null;

            foreach (ISegment s in Segments)
            {
                if (text != null)
                {
                    if (b == null)
                    {
                        b = new StringBuilder(text);
                    }
                    else
                    {
                        b.Append(text);
                    }
                }
                text = document.GetText(s);
            }
            if (b != null)
            {
                if (text != null)
                {
                    b.Append(text);
                }
                return(b.ToString());
            }
            else
            {
                return(text ?? string.Empty);
            }
        }