public void RawlyIndentLine(string indentString, ICSharpCode.AvalonEdit.Document.TextDocument document, DocumentLine line) { if (!_doBeginUpdateManually) { document.BeginUpdate(); } // 1) int prevInd = 0; int curOff = line.Offset; if (curOff < document.TextLength) { char curChar = '\0'; while (curOff < document.TextLength && ((curChar = document.GetCharAt(curOff)) == ' ' || curChar == '\t')) { prevInd++; curOff++; } document.Remove(line.Offset, prevInd); } document.Insert(line.Offset, indentString); if (!_doBeginUpdateManually) { document.EndUpdate(); } }
public void IndentLines(TextDocument document, int beginLine, int endLine) { _doBeginUpdateManually = true; document.BeginUpdate(); while (beginLine <= endLine) { IndentLine(document, document.GetLineByNumber(beginLine)); beginLine++; } document.EndUpdate(); _doBeginUpdateManually = false; }
public void RawlyIndentLine(int tabsToInsert, ICSharpCode.AvalonEdit.Document.TextDocument document, DocumentLine line) { if (!_doBeginUpdateManually) { document.BeginUpdate(); } /* * 1) Remove old indentation * 2) Insert new one */ // 1) int prevInd = 0; int curOff = line.Offset; if (curOff < document.TextLength) { char curChar = '\0'; while (curOff < document.TextLength && ((curChar = document.GetCharAt(curOff)) == ' ' || curChar == '\t')) { prevInd++; curOff++; } document.Remove(line.Offset, prevInd); } // 2) string indentString = ""; for (int i = 0; i < tabsToInsert; i++) { indentString += dEditor.Editor.Options.IndentationString; } document.Insert(line.Offset, indentString); if (!_doBeginUpdateManually) { document.EndUpdate(); } }
public void RawlyIndentLine(int tabsToInsert, TextDocument document, DocumentLine line) { if (!_doBeginUpdateManually) document.BeginUpdate(); /* * 1) Remove old indentation * 2) Insert new one */ // 1) int prevInd = 0; int curOff = line.Offset; if (curOff < document.TextLength) { char curChar = '\0'; while (curOff < document.TextLength && ((curChar = document.GetCharAt(curOff)) == ' ' || curChar == '\t')) { prevInd++; curOff++; } document.Remove(line.Offset, prevInd); } // 2) string indentString = ""; for (int i = 0; i < tabsToInsert; i++) indentString += dEditor.Editor.Options.IndentationString; document.Insert(line.Offset, indentString); if (!_doBeginUpdateManually) document.EndUpdate(); }