Exemplo n.º 1
0
        /// <summary>
        /// 任意の位置に文字列を挿入
        /// </summary>
        /// <param name="nLine">Line number. 0 origin</param>
        /// <param name="pos"></param>
        /// <param name="str"></param>
        public Task Insert(int nLine, int pos, string str)
        {
            //nLineがまだ存在しない行番号だった場合に備えて、その行までの存在しない行を全て作成
            // 例えば、現在0-4行目が存在、8行目に文字を挿入する場合、
            // 5-8行目を作成する。
            for (int i = list.Count; i < nLine + 1; i++)
            {
                MyLine newLine = new MyLine();
                list.Add(newLine);
            }

            MyLine line = list[nLine];
            line.Insert(pos, str);
            // 任意の位置に挿入するのだから、キャレットとは違う位置に行を増やさないように挿入した時にはキャレットに影響は無い。従って、現状ではバグがある。
            CurrentPhysicalPosition = new PhysicalPosition(CurrentPhysicalPosition.Line, CurrentPhysicalPosition.Pos + str.Length);
            Task task = new Insert();
            task.fromLine = nLine;
            task.fromPos = pos;
            task.length = str.Length;
            task.str = str;
            history.Add(task);
            if (MyTaskEvent != null)
            {
                TaskEventArgs args = new TaskEventArgs();
                args.task = task;
                MyTaskEvent(this, args);
            }

            return task;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 任意の位置に文字列を挿入
        /// </summary>
        /// <param name="nLine">Line number. 0 origin</param>
        /// <param name="pos"></param>
        /// <param name="str"></param>
        public Task Insert(int nLine, int pos, string str)
        {
            //nLineがまだ存在しない行番号だった場合に備えて、その行までの存在しない行を全て作成
            // 例えば、現在0-4行目が存在、8行目に文字を挿入する場合、
            // 5-8行目を作成する。
            for (int i = list.Count; i < nLine + 1; i++)
            {
                MyLine newLine = new MyLine();
                list.Add(newLine);
            }

            MyLine line = list[nLine];
            line.Insert(pos, str);
            CurrentPos = new Position(CurrentPos.Line, CurrentPos.Pos + str.Length);
            Task task = new Insert();
            task.fromLine = nLine;
            task.fromPos = pos;
            task.length = str.Length;
            task.str = str;
            history.Add(task);
            if (MyTaskEvent != null)
            {
                TaskEventArgs args = new TaskEventArgs();
                args.task = task;
                MyTaskEvent(this, args);
            }

            return task;
        }