private void ArchiScript_TextChanged(object sender, EventArgs e) { if (ArchiScript.TextLength < CharCount) { CharCount = ArchiScript.TextLength; if (CharCount != 0) { if (CharCount < maxCharted) { maxCharted = 0; } currentLocation = 0; scanUntil(); } else if (CharCount == 0) { ArchiScript.Select(0, 0); ArchiScript.SelectionColor = Color.Black; currentLocation = 0; maxCharted = 0; } } else { CharCount = ArchiScript.TextLength; scanUntil(true); } }
void scanUntil(bool accumaltive = false) { int current = accumaltive? maxCharted: 0; while (current < ArchiScript.SelectionStart && !EndOfText) { string Token = getToken(); if (Colors.ContainsKey(Token.ToUpper())) { int Selection = ArchiScript.SelectionStart; ArchiScript.Select(currentLocation - Token.Length, Token.Length); ArchiScript.SelectionColor = Colors[Token.ToUpper()]; ArchiScript.Select(Selection, 0); ArchiScript.SelectionColor = Color.Black; current += Token.Length; maxCharted = current + 1; } else { int Selection = ArchiScript.SelectionStart; ArchiScript.Select(ArchiScript.SelectionStart - Token.Length, Token.Length); ArchiScript.SelectionColor = literal?Color.DarkRed: Color.Black; literal = false; ArchiScript.Select(Selection, 0); ArchiScript.SelectionColor = Color.Black; current += Token.Length; } } currentLocation = maxCharted; }