DETERMINING SCHEME STATE AT POSITION X/Y

I'd like to find out which syntax state the current position is at.
IStringItem line = edit.Lines.GetItem(edit1.Position.Y);
StringItemInfo info = line.TextData[edit.Position.X];
info.Data seems to be syntax related, but I can't figure out how that relates to my syntax states
edit.Source.Lexer.Scheme.States[info.Data]
does not return the correct state.
How can I find the scheme state at position X/Y ?
Hi,
We do not store lexical state for every symbol in the text, as this information is not really used during syntax highlighting.
StringIteminfo.Data is a 1-based lexical style (number, resword, etc.).
We do store however lexical state at the start of the line (IStringItem.LexState property), so every time user types in the editor we need to only re-parse this particular line (and following lines if state changes)
So it's possible to work out state at (x, y) by using this code:
using Alternet.Syntax;
using Alternet.Syntax.Lexer;
private void button1_Click(object sender, EventArgs e)
{
int x = syntaxEdit1.Position.X;
int y = syntaxEdit1.Position.Y;
IStringItem item = syntaxEdit1.Lines.GetItem(y);
StringItemInfo[] data = item.TextData;
int state = parser1.ParseText(item.LexState, y, item.String.Substring(0, x), ref data);
ILexState lexState = (state >= 0) && (state < parser1.Scheme.States.Count) ? parser1.Scheme.States[state] : null;
}
regards,
Andrew