/// <summary>
        /// Create a dialog box which can display command line output.
        /// </summary>
        /// <returns>Reference to the new window.</returns>
        public static CommandLineDialog CreateCommandLineDialog(string title)
        {
            CommandLineDialog window = (CommandLineDialog)EditorWindow.GetWindow(
                typeof(CommandLineDialog), true, title);

            window.Initialize();
            return(window);
        }
 /// <summary>
 /// Called from CommandLineDialog in the context of the main / UI thread.
 /// </summary>
 public void Update(CommandLineDialog window)
 {
     if (textQueue.Count > 0)
     {
         List <string> textList = new List <string>();
         while (textQueue.Count > 0)
         {
             textList.Add((string)textQueue.Dequeue());
         }
         string bodyText = window.bodyText + String.Join("", textList.ToArray());
         // Really weak handling of carriage returns.  Truncates to the previous
         // line for each newline detected.
         while (true)
         {
             // Really weak handling carriage returns for progress style updates.
             int carriageReturn = bodyText.LastIndexOf("\r");
             if (carriageReturn < 0 || bodyText.Substring(carriageReturn, 1) == "\n")
             {
                 break;
             }
             string bodyTextHead    = "";
             int    previousNewline = bodyText.LastIndexOf("\n", carriageReturn,
                                                           carriageReturn);
             if (previousNewline >= 0)
             {
                 bodyTextHead = bodyText.Substring(0, previousNewline + 1);
             }
             bodyText = bodyTextHead + bodyText.Substring(carriageReturn + 1);
         }
         window.bodyText = bodyText;
         if (window.autoScrollToBottom)
         {
             window.scrollPosition.y = Mathf.Infinity;
         }
         window.Repaint();
     }
     if (maxProgressLines > 0)
     {
         window.progress = (float)linesReported / (float)maxProgressLines;
     }
     if (result != null)
     {
         window.progressTitle = "";
         if (Complete != null)
         {
             Complete(result);
             Complete = null;
         }
     }
 }