Inheritance: TextChangeEventArgs
Example #1
0
 public void ChangeComplete(DocumentChangeEventArgs e)
 {
     foreach (var lt in lineTrackers)
     {
         lt.ChangeComplete(e);
     }
 }
		void ILineTracker.ChangeComplete(DocumentChangeEventArgs e)
		{
			var targetTracker = targetObject.Target as ILineTracker;
			if (targetTracker != null)
				targetTracker.ChangeComplete(e);
			else
				Deregister();
		}
Example #3
0
        void ILineTracker.ChangeComplete(DocumentChangeEventArgs e)
        {
            var targetTracker = targetObject.Target as ILineTracker;

            if (targetTracker != null)
            {
                targetTracker.ChangeComplete(e);
            }
            else
            {
                Deregister();
            }
        }
 /// <summary>
 ///     Updates the start and end offsets of all segments stored in this collection.
 /// </summary>
 /// <param name="e">DocumentChangeEventArgs instance describing the change to the document.</param>
 public void UpdateOffsets(DocumentChangeEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     if (isConnectedToDocument)
     {
         throw new InvalidOperationException(
                   "This TextSegmentCollection will automatically update offsets; do not call UpdateOffsets manually!");
     }
     OnDocumentChanged(e);
     CheckProperties();
 }
Example #5
0
 internal void Push(TextDocument document, DocumentChangeEventArgs e)
 {
     if (state == StatePlayback)
     {
         throw new InvalidOperationException("Document changes during undo/redo operations are not allowed.");
     }
     if (state == StatePlaybackModifyDocument)
     {
         state = StatePlayback;                 // allow only 1 change per expected modification
     }
     else
     {
         Push(new DocumentChangeOperation(document, e));
     }
 }
        private void OnDocumentChanged(DocumentChangeEventArgs e)
        {
            var map = e.OffsetChangeMapOrNull;

            if (map != null)
            {
                foreach (var entry in map)
                {
                    UpdateOffsetsInternal(entry);
                }
            }
            else
            {
                UpdateOffsetsInternal(e.CreateSingleChangeMapEntry());
            }
        }
 public void OnEvent(object sender, DocumentChangeEventArgs ev)
 {
     OnDocumentChanged(ev);
 }
		public void UpdateOffsets(DocumentChangeEventArgs e)
		{
			if (TextTransformations != null)
			{
				TextTransformations.UpdateOffsets(e);
			}
		}
		public DocumentChangeOperation(TextDocument document, DocumentChangeEventArgs change)
		{
			this.document = document;
			this.change = change;
		}
Example #10
0
		internal void Push(TextDocument document, DocumentChangeEventArgs e)
		{
			if (state == StatePlayback)
				throw new InvalidOperationException("Document changes during undo/redo operations are not allowed.");
			if (state == StatePlaybackModifyDocument)
				state = StatePlayback; // allow only 1 change per expected modification
			else
				Push(new DocumentChangeOperation(document, e));
		}
 public DocumentChangeOperation(TextDocument document, DocumentChangeEventArgs change)
 {
     this.document = document;
     this.change   = change;
 }
Example #12
0
        private void DoReplace(int offset, int length, ITextSource newText, OffsetChangeMap offsetChangeMap)
        {
            if (length == 0 && newText.TextLength == 0)
            {
                return;
            }

            // trying to replace a single character in 'Normal' mode?
            // for single characters, 'CharacterReplace' mode is equivalent, but more performant
            // (we don't have to touch the anchorTree at all in 'CharacterReplace' mode)
            if (length == 1 && newText.TextLength == 1 && offsetChangeMap == null)
            {
                offsetChangeMap = OffsetChangeMap.Empty;
            }

            ITextSource removedText;

            if (length == 0)
            {
                removedText = StringTextSource.Empty;
            }
            else if (length < 100)
            {
                removedText = new StringTextSource(rope.ToString(offset, length));
            }
            else
            {
                // use a rope if the removed string is long
                removedText = new RopeTextSource(rope.GetRange(offset, length));
            }
            var args = new DocumentChangeEventArgs(offset, removedText, newText, offsetChangeMap);

            // fire DocumentChanging event
            if (Changing != null)
            {
                Changing(this, args);
            }
            if (textChanging != null)
            {
                textChanging(this, args);
            }

            undoStack.Push(this, args);

            cachedText      = null; // reset cache of complete document text
            fireTextChanged = true;
            var delayedEvents = new DelayedEvents();

            lock (lockObject)
            {
                // create linked list of checkpoints
                versionProvider.AppendChange(args);

                // now update the textBuffer and lineTree
                if (offset == 0 && length == rope.Length)
                {
                    // optimize replacing the whole document
                    rope.Clear();
                    var newRopeTextSource = newText as RopeTextSource;
                    if (newRopeTextSource != null)
                    {
                        rope.InsertRange(0, newRopeTextSource.GetRope());
                    }
                    else
                    {
                        rope.InsertText(0, newText.Text);
                    }
                    lineManager.Rebuild();
                }
                else
                {
                    rope.RemoveRange(offset, length);
                    lineManager.Remove(offset, length);
#if DEBUG
                    lineTree.CheckProperties();
#endif
                    var newRopeTextSource = newText as RopeTextSource;
                    if (newRopeTextSource != null)
                    {
                        rope.InsertRange(offset, newRopeTextSource.GetRope());
                    }
                    else
                    {
                        rope.InsertText(offset, newText.Text);
                    }
                    lineManager.Insert(offset, newText);
#if DEBUG
                    lineTree.CheckProperties();
#endif
                }
            }

            // update text anchors
            if (offsetChangeMap == null)
            {
                anchorTree.HandleTextChange(args.CreateSingleChangeMapEntry(), delayedEvents);
            }
            else
            {
                foreach (var entry in offsetChangeMap)
                {
                    anchorTree.HandleTextChange(entry, delayedEvents);
                }
            }

            lineManager.ChangeComplete(args);

            // raise delayed events after our data structures are consistent again
            delayedEvents.RaiseEvents();

            // fire DocumentChanged event
            if (Changed != null)
            {
                Changed(this, args);
            }
            if (textChanged != null)
            {
                textChanged(this, args);
            }
        }
Example #13
0
		private void DoReplace(int offset, int length, ITextSource newText, OffsetChangeMap offsetChangeMap)
		{
			if (length == 0 && newText.TextLength == 0)
				return;

			// trying to replace a single character in 'Normal' mode?
			// for single characters, 'CharacterReplace' mode is equivalent, but more performant
			// (we don't have to touch the anchorTree at all in 'CharacterReplace' mode)
			if (length == 1 && newText.TextLength == 1 && offsetChangeMap == null)
				offsetChangeMap = OffsetChangeMap.Empty;

			ITextSource removedText;
			if (length == 0)
			{
				removedText = StringTextSource.Empty;
			}
			else if (length < 100)
			{
				removedText = new StringTextSource(rope.ToString(offset, length));
			}
			else
			{
				// use a rope if the removed string is long
				removedText = new RopeTextSource(rope.GetRange(offset, length));
			}
			var args = new DocumentChangeEventArgs(offset, removedText, newText, offsetChangeMap);

			// fire DocumentChanging event
			if (Changing != null)
				Changing(this, args);
			if (textChanging != null)
				textChanging(this, args);

			undoStack.Push(this, args);

			cachedText = null; // reset cache of complete document text
			fireTextChanged = true;
			var delayedEvents = new DelayedEvents();

			lock (lockObject)
			{
				// create linked list of checkpoints
				versionProvider.AppendChange(args);

				// now update the textBuffer and lineTree
				if (offset == 0 && length == rope.Length)
				{
					// optimize replacing the whole document
					rope.Clear();
					var newRopeTextSource = newText as RopeTextSource;
					if (newRopeTextSource != null)
						rope.InsertRange(0, newRopeTextSource.GetRope());
					else
						rope.InsertText(0, newText.Text);
					lineManager.Rebuild();
				}
				else
				{
					rope.RemoveRange(offset, length);
					lineManager.Remove(offset, length);
#if DEBUG
					lineTree.CheckProperties();
#endif
					var newRopeTextSource = newText as RopeTextSource;
					if (newRopeTextSource != null)
						rope.InsertRange(offset, newRopeTextSource.GetRope());
					else
						rope.InsertText(offset, newText.Text);
					lineManager.Insert(offset, newText);
#if DEBUG
					lineTree.CheckProperties();
#endif
				}
			}

			// update text anchors
			if (offsetChangeMap == null)
			{
				anchorTree.HandleTextChange(args.CreateSingleChangeMapEntry(), delayedEvents);
			}
			else
			{
				foreach (var entry in offsetChangeMap)
				{
					anchorTree.HandleTextChange(entry, delayedEvents);
				}
			}

			lineManager.ChangeComplete(args);

			// raise delayed events after our data structures are consistent again
			delayedEvents.RaiseEvents();

			// fire DocumentChanged event
			if (Changed != null)
				Changed(this, args);
			if (textChanged != null)
				textChanged(this, args);
		}
Example #14
0
		public void ChangeComplete(DocumentChangeEventArgs e)
		{
			foreach (var lt in lineTrackers)
			{
				lt.ChangeComplete(e);
			}
		}