Пример #1
0
        private static void OnSelectResults(RuntimeTable <ResultRow> result)
        {
            lock (ConsoleAppender.ConsoleWriteLock)
            {
                ConsoleAppender.SetCursor(ConsoleAppender.StartCursorTop + 3);

                var lengths = Measure(result);

                //+--+-------------------+------------+
                //|  |  (No column name) | .content a |
                //+--+-------------------+------------+

                var border = Border(lengths);
                Console.WriteLine(border);
                var values = result.Columns().ToList();
                values.Insert(0, "");
                Console.WriteLine(Values(lengths, values.ToArray()));
                Console.WriteLine(border.ToString());

                for (int row = 0; row < result.RowCount; row++)
                {
                    var valueList = new List <string>();
                    for (int col = 0; col < lengths.Count - 1; col++)
                    {
                        valueList.Add(result[row][col].ToString());
                    }

                    valueList.Insert(0, (row + 1).ToString());
                    Console.WriteLine(Values(lengths, valueList.ToArray()));
                }
                Console.WriteLine(border.ToString());

                ConsoleAppender.StartCursorTop = Console.CursorTop;
            }
        }
Пример #2
0
        private static void OnProgress(ProgressArgs e)
        {
            lock (ConsoleAppender.ConsoleWriteLock)
            {
                ConsoleAppender.SetCursor(ConsoleAppender.StartCursorTop + 1);
                ConsoleAppender.ClearConsoleLine(Console.CursorTop);

                Console.WriteLine(RenderProgress(e));
                PrintRunning();
            }
        }
Пример #3
0
        private static void Compile(string[] source, string[] args)
        {
            ConsoleAppender.StartCursorTop = Console.CursorTop + 1;
            ConsoleAppender.SetCursor(ConsoleAppender.StartCursorTop);

            var compiler          = new Compiler(source);
            var generatedAssembly = compiler.ToAssembly();

            if (compiler.Errors.Any())
            {
                ListErrors(compiler.Errors.Select(x => x.Message).ToArray());
            }

            if (!compiler.Errors.Any())
            {
                var runable = new Runable(generatedAssembly, args);
                runable.Select   += OnSelectResults;
                runable.Progress += OnProgress;

                try
                {
                    PrintRunning();
                    runable.Run();
                    Console.WriteLine("Finished.");
                    ConsoleAppender.StartCursorTop = Console.CursorTop;
                }
                catch (ThreadAbortException)
                {
                    Log.Info("Program aborted");
                }
                catch (Exception e)
                {
                    Log.Fatal("Unexpected Exception", e);
                }
            }
        }
Пример #4
0
 private static void PrintRunning()
 {
     ConsoleAppender.SetCursor(ConsoleAppender.StartCursorTop + 2);
     ConsoleAppender.ClearConsoleLine(Console.CursorTop);
     Console.WriteLine("Running...");
 }