Example #1
0
        void HandleLog(string message, string stackTrace, LogType type)
        {
            var line = new Shell.Line {
                value = message, stackTrace = stackTrace
            };

            switch (type)
            {
            case LogType.Error:
                line.color = 1;
                break;

            case LogType.Warning:
                line.color = 3;
                break;

            case LogType.Log:
            default:
                line.color = 7;
                break;
            }
            Shell.buffer.Add(line);
        }
Example #2
0
        void Update()
        {
            if (locked)
            {
                return;
            }

            if (Input.GetKeyDown(toggleKey))
            {
                HideCompletions();
                if (Input.GetKey(KeyCode.LeftShift))
                {
                    SwitchState(State.OpenMin);
                    return;
                }
                SwitchState(State.OpenMax);
                return;
            }

            if (state == State.Closed &&
                shakeToOpen &&
                Input.acceleration.sqrMagnitude >= shakeMagnitude &&
                lastShakeOpen >= shakeThresholdTime &&
                (!shakeRequiresTouch || Input.touchCount > 0))
            {
                SwitchState(State.Closed);
                lastShakeOpen = 0f;
                return;
            }
            lastShakeOpen += Time.deltaTime;

            if (Input.anyKeyDown)
            {
                ProcessKeyBindings();
            }

            if (state == State.Closed)
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.Return) ||
                Input.GetKeyDown(KeyCode.KeypadEnter))
            {
                HideCompletions();
                EnterCommand(input.text);
                return;
            }

            if (!input.isFocused)
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.Backspace))
            {
                HideCompletions();
                if (input.text == "")
                {
                    firstToken = true;
                }
            }

            if ((autoCompleteMode == AutoCompleteMode.Always ||
                 (autoCompleteMode == AutoCompleteMode.FirstToken && firstToken)) &&
                Input.anyKeyDown)
            {
                ShowCompletions();
            }

            if (Input.GetKeyDown(KeyCode.Tab))
            {
                ShowCompletions();
                AutoComplete();
                return;
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                HideCompletions();
                firstToken = false;
            }

            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                if (history.Count == 0)
                {
                    return;
                }
                if (--historyPosition < 0)
                {
                    historyPosition = 0;
                }
                SetInput(history[historyPosition]);
                return;
            }

            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                if (++historyPosition >= history.Count)
                {
                    historyPosition = history.Count;
                    SetInput("");
                    return;
                }
                SetInput(history[historyPosition]);
                return;
            }

            if (Shell.buffer.Count == 0)
            {
                return;
            }
            Shell.buffer.CopyTo(bufferedLogs);

            foreach (var ln in bufferedLogs)
            {
                RenderText(ln.value, ln.color);
            }

            lastStackTrace = Shell.buffer.Pop();
            Shell.buffer.Clear();
            bufferedLogs.Clear();
        }