private void _AutoIndentNeeded(object sender, AutoIndentEventArgs e) { Match isOtherwiseRegex = Regex.Match(e.LineText.Trim(), ",* otherwise"); int currentIndent = e.LineText.TakeWhile(q => q == ' ').Count(); //shouldn't be too inefficient int at = e.LineText.IndexOf('='); AmandaTagParser tagParser = new AmandaTagParser(); tagParser.Parse(textBox.Text); /* * All these todo's might not be neccessary, it's pretty good right now */ //If the line contains a where, we want the next lines to be indented by a tab if (Regex.IsMatch(e.LineText, "where")) { e.ShiftNextLines = e.TabLength; } //if the line is a condition, we want to find the '=' and indent to there, that's how youre supposed to do conditions in amanda else if (Regex.IsMatch(e.LineText.Trim(), ",* if")) { e.ShiftNextLines = at - currentIndent; } //If line is empty | prev line is empty | contains otherwise (which indicates the end of an if/else statement) else if (e.LineText.Trim() == "" || e.PrevLineText.Trim().Count() == 0 || Regex.IsMatch(e.LineText.Trim(), ",* otherwise") == true) { //Get the tag based on our current line, if we are at line 3, and there is a big function going from line 1-5, it will return that. AmandaTag tag = tagParser.GetTag(e.iLine); if (tag != null) { e.ShiftNextLines = tag.BeginLocation.X - at; } //No function found? No problem, resort to a tab else { e.ShiftNextLines = -e.TabLength; } } }