void SetText(string text) { WritingBuffer.Length = 0; LineBuffer.Length = 0; WritingBuffer.AppendLine("Dear Journal, "); var words = text.Split(null); foreach (var word in words) { if (LineBuffer.Length > 0) { LineBuffer.Append(' '); } LineBuffer.Append(word); if (LineBuffer.Length >= maxLineLength) { WritingBuffer.AppendLine(LineBuffer.ToString()); LineBuffer.Length = 0; } } TextMesh.text = WritingBuffer.ToString(); }
/// <summary> /// Implements IDebugOutputCallbacks2::Output2 /// </summary> public int Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, UInt64 Arg, string Text) { var mask = (DEBUG_OUTPUT)Arg; if (Which == DEBUG_OUTCB.EXPLICIT_FLUSH) { //Flush(); return(S_OK); } if (string.IsNullOrEmpty(Text)) { return(S_OK); } bool textIsDml = (Which == DEBUG_OUTCB.DML); if (OutputActive) { lock (this) { OutputActive = false; PreviousTextWasDml = textIsDml; PreviousDmlFlags = Flags; DbgStringBuilder LineBuffer; LineBuffers.TryGetValue(mask, out LineBuffer); int LineInputPos = 0; LineInputPositions.TryGetValue(mask, out LineInputPos); bool waitForClosingDML = false; if (LineBuffer == null) { LineBuffer = new DbgStringBuilder(ExecutionUtilities, 1024); LineBuffers[mask] = LineBuffer; } for (int i = 0; i < Text.Length; ++i) { char c = Text[i]; if (c == '<') { waitForClosingDML = true; } if (waitForClosingDML) { if (c == '>') { waitForClosingDML = false; } } if (c == '\n' && waitForClosingDML == false) { LineBuffer.AppendLine(); ProcessLine(mask, LineBuffer.ToString(), textIsDml, Flags); LineBuffer.Clear(); LineInputPos = 0; } else if (c == '\r') { LineInputPos = 0; } else { if (LineInputPos >= LineBuffer.Length) { LineBuffer.Append(c); } else { LineBuffer[LineInputPos] = c; } ++LineInputPos; } } LineInputPositions[mask] = LineInputPos; OutputActive = true; } } return(S_OK); }