コード例 #1
0
        int InsertLines(int offset, int start, int end, out int newStart, out int newEnd)
        {
            StringBuilder       sb    = new StringBuilder();
            StackFrame          ff    = DebuggingService.CurrentFrame;
            List <AssemblyLine> lines = new List <AssemblyLine> (ff.Disassemble(start, end - start + 1));

            int i = lines.FindIndex(al => !al.IsOutOfRange);

            if (i == -1)
            {
                newStart = int.MinValue;
                newEnd   = int.MinValue;
                return(0);
            }

            newStart = i == 0 ? start : int.MinValue;
            lines.RemoveRange(0, i);

            int j = lines.FindLastIndex(al => !al.IsOutOfRange);

            newEnd = j == lines.Count - 1 ? end : int.MinValue;
            lines.RemoveRange(j + 1, lines.Count - j - 1);

            int lineCount  = 0;
            int editorLine = editor.GetTextEditorData().OffsetToLineNumber(offset);

            foreach (AssemblyLine li in lines)
            {
                if (li.IsOutOfRange)
                {
                    continue;
                }
                InsertAssemblerLine(sb, editorLine++, li);
                lineCount++;
            }
            editor.Insert(offset, sb.ToString());
            editor.Document.CommitUpdateAll();
            if (offset == 0)
            {
                this.cachedLines.InsertRange(0, lines);
            }
            else
            {
                this.cachedLines.AddRange(lines);
            }
            return(lineCount);
        }
コード例 #2
0
        public void Insert(TextEditor editor, string text)
        {
            int offset = editor.Document.LocationToOffset(Location);

            editor.Document.BeginAtomicUndo();
            InsertNewLine(editor, LineBefore, ref offset);
            LineSegment line   = editor.Document.GetLineByOffset(offset);
            string      indent = editor.Document.GetLineIndent(line) ?? "";

            editor.Replace(line.Offset, indent.Length, text);
            offset = line.Offset + text.Length;
            InsertNewLine(editor, LineAfter, ref offset);
            if (!string.IsNullOrEmpty(indent))
            {
                editor.Insert(offset, indent);
            }
            editor.Document.EndAtomicUndo();
        }
コード例 #3
0
        public void InsertNewLine(TextEditor editor, NewLineInsertion insertion, ref int offset)
        {
            string str = null;

            switch (insertion)
            {
            case NewLineInsertion.Eol:
                str = editor.GetTextEditorData().EolMarker;
                break;

            case NewLineInsertion.BlankLine:
                str = editor.GetTextEditorData().EolMarker + editor.GetTextEditorData().EolMarker;
                break;

            default:
                return;
            }

            editor.Insert(offset, str);
            offset += str.Length;
        }
コード例 #4
0
 void EditableTextImplementor.InsertText(string str1ng, ref int position)
 {
     position += editor.Insert(position, str1ng);
 }