Пример #1
0
        private void consoleTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (this.consoleTextBox.SelectionStart < writeStartIndex)
            {
                this.consoleTextBox.SelectionStart = writeStartIndex;
                e.Handled          = false;
                e.SuppressKeyPress = true;
            }
            if (e.KeyCode == Keys.Enter)
            {
                InputPort ins = new InputPort(new StringReader(getInput()));
                try
                {
                    Object x = null;
                    for (; ;)
                    {
                        if (InputPort.isEOF(x = ins.read()))
                        {
                            break;
                        }
                        var result = s.eval(x);
                        if (result is char[])
                        {
                            result = new String((char[])result);
                        }
                        this.consoleTextBox.AppendText(result.ToString());
                    }
                    this.consoleTextBox.AppendText(System.Environment.NewLine);
                    this.consoleTextBox.AppendText(">");
                    writeStartIndex = this.consoleTextBox.Text.Length;
                    this.consoleTextBox.SelectionStart = writeStartIndex;
                }
                catch (Exception ex) {
                    this.consoleTextBox.AppendText(ex.Message.ToString());
                    this.consoleTextBox.AppendText(System.Environment.NewLine);
                    this.consoleTextBox.AppendText(">");
                    writeStartIndex = this.consoleTextBox.Text.Length;
                    this.consoleTextBox.SelectionStart = writeStartIndex;
                }
            }

            /*
             * else if (e.Modifiers.CompareTo(Keys.Control)==0 && e.KeyCode == Keys.C) {
             * this.consoleTextBox.AppendText(System.Environment.NewLine);
             * this.consoleTextBox.AppendText(">");
             * writeStartIndex = this.consoleTextBox.Text.Length;
             * this.consoleTextBox.SelectionStart = writeStartIndex;
             * }
             */
        }