Beispiel #1
0
        /// <summary>
        /// Insert a Snippet
        /// </summary>
        /// <param name="snippet"></param>
        public void InsertSnippet(YnoteSnippet snippet)
        {
#if DEBUG
            var watch = new Stopwatch();
            watch.Start();
#endif
            var selection = codebox.Selection.Clone();
            var content   = snippet.GetSubstitutedContent(this);
            codebox.InsertText(content);
            var nselection = codebox.Selection.Clone();
            for (int i = selection.Start.iLine; i <= nselection.Start.iLine; i++)
            {
                codebox.Selection.Start = new Place(0, i);
                codebox.DoAutoIndent(i);
            }
            codebox.Selection = nselection;
            if (snippet.Content.Contains('^'))
            {
                PositionCaretTo('^');
            }
#if DEBUG
            watch.Stop();
            Debug.WriteLine(watch.Elapsed + " ms InsertSnippet()");
#endif
        }
Beispiel #2
0
        public void InsertSnippet(YnoteSnippet snippet)
        {
            var selection = codebox.Selection.Clone();
            var content   = snippet.GetSubstitutedContent(this);

            codebox.InsertText(content);
            var nselection = codebox.Selection.Clone();

            for (int i = selection.Start.iLine; i <= nselection.Start.iLine; i++)
            {
                codebox.Selection.Start = new Place(0, i);
                codebox.DoAutoIndent(i);
            }
            codebox.Selection.Start = new Place(nselection.End.iChar, nselection.End.iLine);
            if (snippet.Content.Contains('^'))
            {
                PositionCaretTo('^');
            }
        }