示例#1
0
        public static string ReadCommand(bool debugging = false)
        {
            var    output = GetConsoleOut();
            string prompt;
            string debugText = debugging ? "> debug " : "";
            var    package   = Runtime.CurrentPackage();

            if (Console.IsInputRedirected)
            {
                prompt = "";
            }
            else
            {
                if (state.Count == 1)
                {
                    prompt = string.Format("\n{0} {1}> ", package.Name, debugText);
                }
                else
                {
                    prompt = string.Format("\n{0} {1}: {2} > ", package.Name, debugText, state.Count - 1);
                }
            }

            var data = ReplRead(prompt, true, true, true);

            if (!String.IsNullOrWhiteSpace(data))
            {
                History.Append(data);
                History.Save();
            }
            return(data);
        }
示例#2
0
        public static string ReadCommand(bool debugging = false)
        {
            var output = GetConsoleOut();
            var data   = "";

            while (string.IsNullOrWhiteSpace(data))
            {
                int    counter = History.Count + 1;
                string prompt;
                string debugText = debugging ? "> debug " : "";
                var    package   = Runtime.CurrentPackage();
                if (state.Count == 1)
                {
                    Runtime.PrintLine(output);
                    prompt = string.Format("{0} {1} {2}> ", package.Name, counter, debugText);
                }
                else
                {
                    Runtime.PrintLine(output);
                    prompt = string.Format("{0} {1} {2}: {3} > ", package.Name, counter, debugText, state.Count - 1);
                }

                Runtime.Print(output, prompt);

                while ((data = ReadFunctionImp()) == null)
                {
                }

                Runtime.PrintLine(output);

                if (string.IsNullOrWhiteSpace(data))
                {
                    // Show prompt again
                    continue;
                }
            }

            History.Append(data);

            return(data);
        }