static void IndentCode(ITextDocument data, string lineIndent) { for (int i = 1; i < data.LineCount; i++) { var line = data.GetLine(i + 1); if (line.Length > 0) { data.InsertText(line.Offset, lineIndent); } } }
public void InsertNewLine (ITextDocument editor, NewLineInsertion insertion, ref int offset) { string str = null; switch (insertion) { case NewLineInsertion.Eol: str = editor.GetEolMarker (); break; case NewLineInsertion.BlankLine: str = editor.GetEolMarker () + editor.GetEolMarker (); break; default: return; } editor.InsertText (offset, str); offset += str.Length; }
public int Insert(ITextDocument editor, string text) { int offset = editor.LocationToOffset(Location); using (var undo = editor.OpenUndoGroup()) { // TODO: Run formatter !!! // text = editor.FormatString (Location, text); var line = editor.GetLineByOffset(offset); int insertionOffset = line.Offset + Location.Column - 1; offset = insertionOffset; InsertNewLine(editor, LineBefore, ref offset); int result = offset - insertionOffset; editor.InsertText(offset, text); offset += text.Length; InsertNewLine(editor, LineAfter, ref offset); return(result); } }
public void InsertNewLine(ITextDocument editor, NewLineInsertion insertion, ref int offset) { string str = null; switch (insertion) { case NewLineInsertion.Eol: str = editor.GetEolMarker(); break; case NewLineInsertion.BlankLine: str = editor.GetEolMarker() + editor.GetEolMarker(); break; default: return; } editor.InsertText(offset, str); offset += str.Length; }
static void IndentCode (ITextDocument data, string lineIndent) { for (int i = 1; i < data.LineCount; i++) { var line = data.GetLine (i + 1); if (line.Length > 0) data.InsertText (line.Offset, lineIndent); } }
public int Insert (ITextDocument editor, string text) { int offset = editor.LocationToOffset (Location); using (var undo = editor.OpenUndoGroup ()) { // TODO: Run formatter !!! // text = editor.FormatString (Location, text); var line = editor.GetLineByOffset (offset); int insertionOffset = line.Offset + Location.Column - 1; offset = insertionOffset; InsertNewLine (editor, LineBefore, ref offset); int result = offset - insertionOffset; editor.InsertText (offset, text); offset += text.Length; InsertNewLine (editor, LineAfter, ref offset); return result; } }