// Pass null to progress mark to eliminate static void writePrettyProseWithProgressMark(ProseRuntime runtime, PNode start, PNode progressMark, int maxNodesToProcess) { writeStackDepthMarker(runtime); //Stack<ProseObject> parenStack = new Stack<ProseObject>(); int parenCount = 0; int bracketCount = 0; int quadQuoteCount = 0; int periodCount = 0; int nodesProcessed = 0; PNode p = start; do { nodesProcessed++; while (p != null && p.value == null) { p = p.next; } if (p.value == null) { p = p.next; continue; } p = runtime.filterIncomingPNode(p); if (p == null) { break; } // PROGRESS MARK if (p == progressMark) { Console.BackgroundColor = ConsoleColor.Black; Console.Write(" "); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Write(" "); Console.BackgroundColor = ConsoleColor.Black; Console.Write(" "); } // Write a leading space Console.BackgroundColor = ConsoleColor.Black; Console.Write(" "); // OBJECTS if (p.value is ProseAction) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Green; } else if (p.value == runtime.Comma || p.value == runtime.Semicolon || p.value == runtime.Period) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Magenta; } else if (p.value is RawWordObject) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Red; } // else if ( p.value == runtime.LefetParenthesis // || p.value == runtime.LeftSquareBracket // || p.value == runtime.LeftCurlyBracket // || p.value == runtime.RightParenthesis // || p.value == r else if (p.value == runtime.Colon || p.value == runtime.LeftArrow || p.value == runtime.PlusColon || p.value == runtime.MinusColon || p.value == runtime.RightArrow || p.value == runtime.ColonPlus || p.value == runtime.ColonMinus || p.value == runtime.Quadquote) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Cyan; } else if (p.value is AssemblyNameWord || p.value is TypeNameWord || p.value is MethodNameWord) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Yellow; } else { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Gray; } // Inside a text block everything is forced to white unless its in brackets // Deal with different highighting inside of text expressions if (quadQuoteCount % 2 == 1) { if (p.value == runtime.LeftSquareBracket) { bracketCount++; } // Neutralize colors of words that behave as text if (bracketCount == 0) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Cyan; } if (p.value == runtime.RightSquareBracket) { bracketCount--; } } if (p.value == runtime.@break || p.value is BreakPointObject) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; } // Prewrite logic // Write the output // Console.Write(p.value.getReadableString()); // Just so nothing too ugly can go wrong Console.BackgroundColor = ConsoleColor.Black; // Postwrite logic if (p.value == runtime.RightArrow || p.value == runtime.ColonPlus || p.value == runtime.ColonMinus) { if (Console.CursorLeft > 60 || Console.CursorLeft + 40 > Console.BufferWidth) { restoreConsoleColor(); Console.WriteLine(); Console.Write(" "); writeStackDepthMarker(runtime); restoreConsoleColor(); Console.Write("\t\t"); } } // // Other exits // if (nodesProcessed == maxNodesToProcess) { break; } // // Keep track of parentheticals to know if we can quit // if (p.value == runtime.LeftParenthesis || p.value == runtime.LeftCurlyBracket || p.value == runtime.LeftSquareBracket) { parenCount++; //parenStack.Push(p.value); } else if (p.value == runtime.RightParenthesis || p.value == runtime.RightCurlyBracket || p.value == runtime.RightSquareBracket) { parenCount--; } else if (p.value == runtime.Quadquote) { quadQuoteCount++; } else if (p.value == runtime.Period && parenCount == 0 && quadQuoteCount % 2 == 0) { periodCount++; // If parens and quadquotes are done and we have period then bail if (periodCount == 2) { break; } } // Update p = p.next; } while (p != null); //outStr.Remove(outStr.Length - 1, 1); //return outStr.ToString(); Console.WriteLine(); }