public void EvaluateInput() { Expression res; TextIter insertIter = Buffer.StartIter; if (InputView.Buffer.Text.Length == 0) { Buffer.InsertWithTagsByName(ref insertIter, "No input\n", "error"); return; } Eval.Parse(InputView.Buffer.Text); res = Eval.Evaluate(); if (res is Error) { Eval.SideEffects.Add(new ErrorData(res as Error)); } else if (!(res is Null)) { Buffer.Insert(ref insertIter, "ret: " + res.ToString() + "\n"); } foreach (var data in Eval.SideEffects) { if (data is PrintData) { Buffer.Insert(ref insertIter, data.ToString() + "\n"); } else if (data is ErrorData) { Buffer.InsertWithTagsByName(ref insertIter, data.ToString() + "\n", "error"); } else if (data is DebugData && Eval.GetBool("debug")) { Buffer.InsertWithTagsByName(ref insertIter, data.ToString() + "\n", "debug"); } else if (data is PlotData) { DrawView.Plot(data as PlotData); DrawView.Show(); } else if (data is WidgetData) { WidgetView.AddWidget(data as WidgetData); WidgetView.Show(); } } }