Esempio n. 1
0
    private void HandleLog(string logString, string stackTrace, LogType type)
    {
        switch (type)
        {
        case LogType.Error:
            Console.ResetColor();
            Console.WriteLine("ERRO " + logString);
            break;

        case LogType.Assert:
            Console.SetColor(Color.red);
            Console.WriteLine("ASRT " + logString);
            break;

        case LogType.Warning:
            Console.WriteLine("WARN " + logString);
            break;

        case LogType.Log:
            Console.SetColor(Color.yellow);
            Console.WriteLine("INFO " + logString);
            break;

        case LogType.Exception:
            Console.SetColor(Color.red);
            Console.WriteLine("ERRO " + logString);
            break;

        default:
            throw new ArgumentOutOfRangeException("type", type, null);
        }
        Console.ResetColor();
    }
Esempio n. 2
0
 private void Update()
 {
     if (setVerticalNormalizedPosition)
     {
         setVerticalNormalizedPosition         = false;
         scrollRect.verticalNormalizedPosition = VerticalNormalizedPosition;
     }
     if (Input.GetKeyDown(KeyCode.BackQuote))
     {
         IsVisible = !IsVisible;
     }
     else if (Input.GetKeyDown(KeyCode.Tab))
     {
         if (inputField.isFocused)
         {
             inputField.text = Console.OnAutocomplete(inputField.text, inputField.caretPosition);
         }
     }
     else if (Input.GetKeyDown(KeyCode.Return))
     {
         Console.OnReadLine(inputField.text);
         inputField.text = "";
         inputField.Select();
         inputField.ActivateInputField();
     }
 }
Esempio n. 3
0
    public object Evaluate(string text)
    {
        object result = null;
        var    args   = text.Split(' ');
        var    cmd    = args[0];
        var    fun    = NativeFunction.TryLockup(cmd);

        if (fun != null && fun.function != null)
        {
            result = fun.Call(args);
        }
        else
        {
            Console.WriteLine(string.Format("The command '{0}' is not exists", text));
        }
        ReadLine.Instance.Read(prompt, Evaluate);
        return(result);
    }
Esempio n. 4
0
 private bool CatFileToConsole(string fileName)
 {
     try
     {
         var theReader = new StreamReader(fileName, Encoding.Default);
         using (theReader)
         {
             var line = theReader.ReadLine();
             while (line != null)
             {
                 Console.WriteLine(line);
                 line = theReader.ReadLine();
             }
             theReader.Close();
             return(true);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("{0}\n", e.Message);
         return(false);
     }
 }
Esempio n. 5
0
    private object Man([NotNull] params object[] args)
    {
        if (args == null)
        {
            throw new ArgumentNullException("args");
        }
        Console.WriteLine("Optionaly: Type `info name' or `info shell' to see extended documentation.");
        if (args.Length >= 2)
        {
            var arg = args[1] as string;
            if (arg == null)
            {
                throw new NullReferenceException("arg");
            }

            var fun = NativeFunction.TryLockup(arg);
            if (fun != null)
            {
                var filename = Path.Combine(Application.streamingAssetsPath, "info");
                filename = Path.Combine(filename, arg);
                if (File.Exists(filename))
                {
                    CatFileToConsole(filename);
                }
                else
                {
                    Console.WriteLine(string.Format("Command '{0}' does not have manual", arg));
                }
            }
            else
            {
                Console.WriteLine(string.Format("Command '{0}' does not exists", fun.name));
            }
        }
        return(null);
    }
Esempio n. 6
0
    private object Help([NotNull] params object[] args)
    {
        if (args == null)
        {
            throw new ArgumentNullException("args");
        }
        if (args.Length == 1)
        {
            Console.WriteLine("These shell commands are defined internally.");
            Console.WriteLine("Type `help' to see this list.");
            Console.WriteLine("Type `help name' to find out more about the function `name'.");
            Console.WriteLine("Type `help shell' to find out more about the shell in general.");
            Console.WriteLine("Optionaly: Type `man name' or `man shell' to see extended documentation.");
            Console.WriteLine();

            // Generic help
            var funcs = NativeFunction.GetNames();
            var lines = TerminalTableBuilder.BuildTable(funcs, Console.BufferWidth, 2);
            foreach (var line in lines)
            {
                Console.WriteLine(line);
            }
        }
        else if (args.Length >= 2)
        {
            var arg = args[1] as string;
            if (arg == null)
            {
                throw new NullReferenceException("arg");
            }

            // Help for exact function
            if (string.Equals(arg, "shell"))
            {
                Console.WriteLine("Short shell information.");
                Console.WriteLine("Use 'left' and right' arrow to change caret position.");
                Console.WriteLine("Use 'up' and 'down' arrow to navigate in the hostory.");
                Console.WriteLine("Use 'tab' to complete current word. Or press 'tab tab' to see the list of commands which starts with curent word");
                Console.WriteLine("Use 'enter' to execute whole expression.");
            }
            else
            {
                var fun = NativeFunction.TryLockup(arg);
                if (fun != null)
                {
                    if (fun.help != null)
                    {
                        Console.WriteLine(fun.help);
                    }
                    else
                    {
                        Console.WriteLine(string.Format("Command '{0}' does not have help", fun.name));
                    }
                }
                else
                {
                    Console.WriteLine(string.Format("Command '{0}' does not exists", arg));
                }
            }
        }
        return(null);
    }