
I have 2 Intelliprompt questions that I haven't been able to figure out. For context, this is using lua as the language.
First, I want to show a list of globals when the user starts typing a new word. I though using e.IsTypedWordStart would be the correct thing to do. This is true when starting in whitespace but it is also true if the user types a non-global token, a '.' and then types a character. If user types a global token ( like math ), when they hit '.' I then display the math Session ( which is working correctly ). But if the first token is not a global I don't display anything and then I end up displaying my global when the character after the '.' is typed.
Here's my DocumentTextChanged function. _SessionDict is a Dictionary<string,CompletionSession>.My second question is a little more involved. There are some custom tables we place in the lua environment. The easiest way to describe them is probably as classes
So the user can type
Assuming I can solve my first question, showing 'Controls' as a choice when the user starts typing a new token is trivial. If they type 'Controls.', I can then display either 'Inputs' or 'Outputs' the same way I am displaying the math table methods ( this is assuming that the above way is the correct way to do that ). The final thing I need to do is to detected 'Controls.Inputs[<somenumber>].' and display 'Value' and 'Position'. Is there a built in mechanism that would allow me to accomplish this?
First, I want to show a list of globals when the user starts typing a new word. I though using e.IsTypedWordStart would be the correct thing to do. This is true when starting in whitespace but it is also true if the user types a non-global token, a '.' and then types a character. If user types a global token ( like math ), when they hit '.' I then display the math Session ( which is working correctly ). But if the first token is not a global I don't display anything and then I end up displaying my global when the character after the '.' is typed.
Here's my DocumentTextChanged function. _SessionDict is a Dictionary<string,CompletionSession>.
void _Code_DocumentTextChanged(object sender, EditorSnapshotChangedEventArgs e)
{
if (_Code.IntelliPrompt.Sessions.Any(s => s.IsOpen)) return;
ITextSnapshotReader reader = _Code.ActiveView.GetReader();
IMergableToken im = reader.ReadTokenReverse() as IMergableToken;
// don't show popup when typing a string or a comment
if (im != null && im.ClassificationType != null)
{
if (im.ClassificationType.Key == "String" || im.ClassificationType.Key == "Comment")
{
return;
}
}
switch (e.TypedText)
{
case ".":
{
if (im != null)
{
reader.ReadCharacterReverseThrough('.');
string tok = reader.TokenText;
CompletionSession session;
if (_SessionDict.TryGetValue(reader.TokenText, out session))
{
session.Open(_Code.ActiveView);
}
}
return;
}
}
if (e.IsTypedWordStart)
{
_GlobalSession.Open(_Code.ActiveView);
}
}
class Control
{
public double Value { get; set; }
public double Position { get; set; }
}
static class Controls
{
public Control[] Inputs;
public Control[] Outputs;
}
Controls.Inputs[2].Value = 3