Example #1
0
        void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
        {
            if (e.Text == ".")
            {
                // open code completion after the user has pressed dot:
                completionWindow = new CompletionWindow(textEditor.TextArea);
                // provide AvalonEdit with the data:
                IList <ICompletionData> data = completionWindow.CompletionList.CompletionData;
                data.Add(new MyCompletionData("Item1"));
                data.Add(new MyCompletionData("Item2"));
                data.Add(new MyCompletionData("Item3"));
                data.Add(new MyCompletionData("Another item"));
                completionWindow.Show();
                completionWindow.Closed += delegate {
                    completionWindow = null;
                };
            }


            if (e.Text == "\n")
            {
                int offset = textEditor.Document.GetOffset(textEditor.TextArea.Caret.Line, 1);
                textEditor.Document.Insert(offset, state.Output);
                if (state.LastValue != null)
                {
                    OutputLog.AddToLog(state.LastValue);
                }
            }
        }