Exemplo n.º 1
0
        void OnBufferTextDataChanged(object sender, TextDataChangedEventArgs e)
        {
            bool updatedAtLeastOnce = false;

            while (this.change.NextChange != null)
            {
                bool updated;

                this.Range  = this.change.NextChange.ApplyTo(this.Range, out updated);
                this.change = this.change.NextChange;
                if (updated)
                {
                    updatedAtLeastOnce = true;
                }
            }

            if (updatedAtLeastOnce)
            {
                var handler = this.RangeChanged;
                if (handler != null)
                {
                    handler(this, EventArgs.Empty);
                }
            }
        }
Exemplo n.º 2
0
        void OnPencilDisposed(Pencil pencil, TextDataChangedEventArgs args)
        {
            Debug.Assert(pencil == this.activePencil, "Disposing a pencil that isn't the active one.");

            if (args != null)
            {
                if (this.LastChange != null)
                {
                    this.LastChange.NextChange = args.Change;
                }

                TextChange finalChange = args.Change;

                while (finalChange.NextChange != null)
                {
                    finalChange = finalChange.NextChange;
                }

                this.TextData   = finalChange.NewTextData;
                this.LastChange = finalChange;

                var handler = this.TextDataChanged;
                if (handler != null)
                {
                    handler(this, args);
                }

                if (pencil.UndoUnit != null)
                {
                    var  now    = DateTime.Now;
                    bool merged = false;

                    if (((now - this.timeOfLastEdit).TotalMilliseconds < MinimumMillisecondsTimeBetweenUndoUnits) && (this.undoStack.Count > 0))
                    {
                        // If possible, merge this unit with the one on the stack.
                        TextUndoUnit existingUnit = this.undoStack.Peek();
                        TextUndoUnit incomingUnit = pencil.UndoUnit;

                        if (incomingUnit.Metadata != null && incomingUnit.Metadata.TryMerge(existingUnit.Metadata))
                        {
                            // Successful merge
                            existingUnit.Metadata = incomingUnit.Metadata;
                            existingUnit.Merge(pencil.UndoUnit);
                            merged = true;
                        }
                    }

                    if (!merged)
                    {
                        this.undoStack.Push(pencil.UndoUnit);
                    }

                    this.redoStack.Clear();
                    this.timeOfLastEdit = now;
                }
            }

            this.activePencil = null;
            this.pencilEvent.Set();
        }
        protected override void OnBufferTextDataChanged(object sender, TextDataChangedEventArgs e)
        {
            var change = e.Change;

            while (change.NextChange != null)
            {
                // We actually need the last change; we're "as of" that change.
                change = change.NextChange;
            }

            StartNewParse(change);
        }
Exemplo n.º 4
0
 protected virtual void OnBufferTextDataChanged(object sender, TextDataChangedEventArgs e)
 {
 }