Exemple #1
0
        public void AcceptInput()
        {
            InputField = InputField.Trim();

            if (InputField == "")
            {
                return;
            }

            _history.Add(InputField);
            if (_history.Count > HistoryLimit)
            {
                _history.RemoveRange(0, _history.Count - HistoryLimit);
            }
            _historyPosition = 0;

            if (InputField.Contains("geti()"))
            {
                try
                {
                    var val = REPL.geti();
                    if (val != null)
                    {
                        InputField = InputField.Replace("geti()", $"geti<{val.GetType().GetSourceCodeRepresentation()}>()");
                    }
                }
                catch (SystemException) { }
            }

            _sb.AppendLine($"> {InputField}");
            var result = Evaluate(InputField);

            if (result != null && !Equals(result, VoidType.Value))
            {
                _sb.AppendLine(result.ToString());
            }

            ScrollToBottom();

            InputField = string.Empty;
            ClearSuggestions();
        }