private void RemoveEmptySpaces() { int numSpaces = IndentNewLines(); int startIndex = Editor_TextBox.GetFirstCharIndexOfCurrentLine(); int currentIndex = Editor_TextBox.SelectionStart; //if(currentIndex <= (startIndex + numSpaces)) if (currentIndex <= (startIndex + numSpaces)) { if (numSpaces > 5) { Editor_TextBox.SelectionLength = 5; Editor_TextBox.SelectionStart = currentIndex - 5; Editor_TextBox.SelectedText = ""; } } }
private int IndentNewLines() { int index = Editor_TextBox.GetFirstCharIndexOfCurrentLine(); string text = Editor_TextBox.Text.Remove(0, index); int numSpace = 0; foreach (char c in text) { if (c != ' ') { break; } else { numSpace++; } } return(numSpace); }