示例#1
0
        void ExecuteBuffer()
        {
            if (Buffer.Output.Length == 0)
            {
                return;
            }
            var output = commandProcesser.Process(Buffer.Output).Split('\n').Where(l => l != "");

            Out.Add(new OutputLine(Buffer.Output, OutputLineType.Command));
            foreach (var line in output)
            {
                Out.Add(new OutputLine(line, OutputLineType.Output));
            }
            CommandHistory.Add(Buffer.Output);
            Buffer.Output = "";
        }
示例#2
0
        private void form_KeyPress(Object sender, KeyPressEventArgs e)
        {
            e.Handled = true;

            if (isHandled)
            {
                isHandled = false;
                return;
            }

            if (!isActive)
            {
                return;            // console is opened -> accept input
            }
            CommandHistory.Reset();


            switch (e.KeyChar)
            {
            case (char)System.Windows.Forms.Keys.Return:
                ExecuteBuffer();
                break;

            case (char)System.Windows.Forms.Keys.Back:
                if (Buffer.Output.Length > 0)
                {
                    Buffer.Output = Buffer.Output.Substring(0, Buffer.Output.Length - 1);
                }
                break;

            case (char)System.Windows.Forms.Keys.Tab:
                AutoComplete();
                break;

            default:
                if (IsPrintable(e.KeyChar))
                {
                    Buffer.Output += e.KeyChar;
                }
                break;
            }
        }
示例#3
0
        void EventInput_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.V) && Keyboard.GetState().IsKeyDown(Keys.LeftControl)) // CTRL + V
            {
                if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)                       //Thread Apartment must be in Single-Threaded for the Clipboard to work
                {
                    AddToBuffer(Clipboard.GetText());
                }
            }

            if (e.KeyValue == GameConsoleOptions.Options.ToggleKey)
            {
                ToggleConsole();
            }

            switch (e.KeyValue)
            {
            case 38: Buffer.Output = CommandHistory.Previous(); break;

            case 40: Buffer.Output = CommandHistory.Next(); break;
            }
        }