Пример #1
0
        /// <summary>
        /// Gets the current interactive area where the caret is.
        /// </summary>
        public InteractiveArea CommandArea()
        {
            var r = new InteractiveArea
            {
                Caret = Editor.Caret
            };

            // head line
            for (int y = r.Caret.Y; --y >= 0;)
            {
                var text = Editor[y].Text;
                if (text == OutputMark2 || text == OutputMark3)
                {
                    r.FirstLineIndex = y + 1;
                    break;
                }

                if (text == OutputMark1)
                {
                    return(null);
                }
            }

            r.Active = true;

            // last line
            r.LastLineIndex = Editor.Count - 1;
            for (int y = r.Caret.Y; ++y <= r.LastLineIndex;)
            {
                var text = Editor[y].Text;
                if (text == OutputMark1 || text == OutputMark3)
                {
                    r.LastLineIndex = y - 1;
                    r.Active        = false;
                    break;
                }

                if (text == OutputMark2)
                {
                    return(null);
                }
            }

            // trim
            while (r.FirstLineIndex < r.LastLineIndex && Editor[r.FirstLineIndex].Length == 0)
            {
                ++r.FirstLineIndex;
            }
            while (r.FirstLineIndex < r.LastLineIndex && Editor[r.LastLineIndex].Length == 0)
            {
                --r.LastLineIndex;
            }

            return(r);
        }
Пример #2
0
 /// <summary>
 /// TODO
 /// </summary>
 protected abstract void Invoke(string code, InteractiveArea area);