Esempio n. 1
0
        private void cascadeSnippetLinkRangeChange(SnippetLink oldActiveSnippetLink, SnippetLinkRange oldActiveRange)
        {
            Scintilla.ManagedRanges.Sort();

            int offset = 0;

            string newText = oldActiveRange.Text;

            Scintilla.NativeInterface.SetModEventMask(0);
            foreach (ManagedRange mr in Scintilla.ManagedRanges)
            {
                if (offset != 0)
                    mr.Change(mr.Start + offset, mr.End + offset);

                var slr = mr as SnippetLinkRange;
                if (slr == null || !oldActiveSnippetLink.Ranges.Contains(slr) || slr.Text == newText)
                    continue;

                int oldLength = slr.Length;
                slr.Text = newText;
                slr.End += newText.Length - oldLength;
                offset += newText.Length - oldLength;
            }

            Scintilla.NativeInterface.SetModEventMask(Constants.SC_MODEVENTMASKALL);
        }
Esempio n. 2
0
        private SnippetLinkRange addSnippetLink(SnippetLinkRange range)
        {
            string key = range.Key;
            SnippetLink sl = null;
            for (int i = 0; i < this._snippetLinks.Count; i++)
            {
                if (this._snippetLinks[i].Key.Equals(key, StringComparison.CurrentCultureIgnoreCase))
                {
                    sl = this._snippetLinks[i];
                    break;
                }
            }
            if (sl == null)
            {
                sl = new SnippetLink(key);
                this._snippetLinks.Add(sl);
            }

            sl.Ranges.Add(range);
            range.Parent = sl.Ranges;

            return range;
        }