Beispiel #1
0
        public void Clear()
        {
            List <ManagedRange> rageList = new List <ManagedRange>();

            foreach (SnippetLink sl in _snippetLinks)
            {
                foreach (Range r in sl.Ranges)
                {
                    ManagedRange mr = r as ManagedRange;
                    rageList.Add(mr);
                }
            }

            _snippetLinks.Clear();

            foreach (ManagedRange mr in rageList)
            {
                mr.Dispose();
            }
        }
Beispiel #2
0
        private void Scintilla_BeforeTextDelete(object sender, TextModifiedEventArgs e)
        {
            if (!_isEnabled)
            {
                return;
            }

            if (_snippetLinks.IsActive && !_pendingUndo && !(e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo))
            {
                _pendingUndo = true;
                Scintilla.UndoRedo.BeginUndoAction();
                _snippetLinkTimer.Enabled = true;
            }

            ManagedRange undoneSnippetLinkRange = null;

            if (e.UndoRedoFlags.IsUndo && _snippetLinks.IsActive)
            {
                foreach (ManagedRange mr in Scintilla.ManagedRanges)
                {
                    if (mr.Start == e.Position && mr.Length == e.Length && mr.Length > 1)
                    {
                        undoneSnippetLinkRange = mr;

                        //	Expanding the range So that it won't get marked for deletion
                        mr.End++;
                    }
                }
            }

            //	It's possible that the _end point may have been deleted. The endpoint
            //	is an ultra persistent marker that cannot be deleted until the Snippet
            //	Link mode is deactivated. Place a new EndPoint at the begining of the
            //	deleted range.
            if (_snippetLinks.IsActive && _snippetLinks.EndPoint != null && _snippetLinks.EndPoint.Scintilla == null)
            {
                SnippetLinkEnd eci = new SnippetLinkEnd(e.Position, Scintilla);
                Scintilla.ManagedRanges.Add(eci);
                _snippetLinks.EndPoint = eci;
            }

            //	Now collapse the Undone range in preparation for the
            //	newly inserted text that will be put in here
            if (undoneSnippetLinkRange != null)
            {
                undoneSnippetLinkRange.End = undoneSnippetLinkRange.Start;
            }

            //	Check to see if all SnippetLink ranges have been deleted.
            //	If this is the case we need to turn Deactivate SnippetLink
            //	mode.

            bool deactivate = true;

            foreach (SnippetLink sl in _snippetLinks.Values)
            {
                if (sl.Ranges.Count > 0)
                {
                    foreach (SnippetLinkRange slr in sl.Ranges)
                    {
                        if (slr.Scintilla != null)
                        {
                            deactivate = false;
                            break;
                        }
                    }
                }
                if (!deactivate)
                {
                    break;
                }
            }

            if (deactivate && IsActive)
            {
                IsActive = false;
            }
        }