public void BeginUpdate()
{
VerifyAccess();
if (inDocumentChanging)
throw new InvalidOperationException("Cannot change document within another document change.");
beginUpdateCount++;
if (beginUpdateCount == 1) {
undoStack.StartUndoGroup();
if (UpdateStarted != null)
UpdateStarted(this, EventArgs.Empty);
}
}
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(); }