public ProgressWriter(long expectedTargetValue, OutputDevice output) { _expectedTargetValue = expectedTargetValue; _out = output; _progressDots = 0; _startTime = DateTime.Now; _lastEtaUpdate = DateTime.MinValue; _etaWriter = new CancelWriter(_out); ScreenWidth = DefaultScreenWidth; }
public static void PrintFraction(long execTime, long number, OutputDevice output) { if (number == 0) { output.Write(" -- "); return; } long milli = execTime / number; long micro = (execTime - number * milli) * 1000 / number; PrintTime(milli, micro, output); }
protected ShellApplication() { output = new ConsoleOutputDevice(System.Console.Out, true); message = new ConsoleOutputDevice(System.Console.Error, false); input = new ConsoleInputDevice(); dispatcher = new CommandDispatcher(this); if (this is ISettingsHandler) settings = new ApplicationSettings(this); if (this is IPropertyHandler) properties = new PropertyRegistry(this as IPropertyHandler); if (this is IPluginHandler) plugins = new ApplicationPlugins(this); interruptHandler = new ApplicationInterruptionHandler(this); }
public TableRenderer(ColumnDesign[] columns, OutputDevice output, string separator, bool enableHeader, bool enableFooter) { this.columns = columns; this.output = output; this.enableHeader = enableHeader; this.enableFooter = enableFooter; // we cache the rows in order to dynamically determine the // output width of each column. cacheRows = new ArrayList(MaxCacheElements); alreadyFlushed = false; writtenRows = 0; colSeparator = " " + separator; separatorWidth = separator.Length; }
public CancelWriter(OutputDevice output) { _out = output; _doWrite = _out.IsTerminal; _writtenString = null; }
/** print time to output device */ public static void PrintTime(long execTimeInMs, long usec, OutputDevice output) { long totalTime = execTimeInMs; bool hourPrinted = false; bool minutePrinted = false; if (execTimeInMs > HourMillis) { output.Write(Convert.ToString(execTimeInMs / HourMillis)); output.Write("h "); execTimeInMs %= HourMillis; hourPrinted = true; } if (hourPrinted || execTimeInMs > MinuteMillis) { long minute = execTimeInMs / 60000; if (hourPrinted && minute < 10) { output.Write("0"); // need padding. } output.Write(minute.ToString()); output.Write("m "); execTimeInMs %= MinuteMillis; minutePrinted = true; } if (minutePrinted || execTimeInMs >= SecondMillis) { long seconds = execTimeInMs / SecondMillis; if (minutePrinted && seconds < 10) { output.Write("0"); // need padding. } output.Write(seconds.ToString()); output.Write("."); execTimeInMs %= SecondMillis; // milliseconds if (execTimeInMs < 100) { output.Write("0"); } if (execTimeInMs < 10) { output.Write("0"); } output.Write(execTimeInMs.ToString()); } else if (execTimeInMs > 0) { output.Write(execTimeInMs.ToString()); } if (usec > 0) { if (totalTime > 0) // need delimiter and padding. { output.Write("."); if (usec < 100) { output.Write("0"); } if (usec < 10) { output.Write("0"); } } output.Write(usec.ToString()); } else if (execTimeInMs == 0) { output.Write("0 "); } if (totalTime > MinuteMillis) { output.Write("s"); } else if (totalTime >= SecondMillis) { output.Write(" "); } else if (totalTime > 0 && totalTime < SecondMillis) { output.Write(" m"); } else if (totalTime == 0 && usec > 0) { output.Write(" µ"); } else { output.Write("sec"); } }
/** print time to output device */ public static void PrintTime(long execTimeInMs, OutputDevice output) { PrintTime(execTimeInMs, 0, output); }
public void SetPrompt(string text) { prompt = text; // StringBuilder tmp = new StringBuilder(); // int emptyLength = prompt.Length; // for (int i = emptyLength; i > 0; --i) { // tmp.Append(' '); // } // emptyPrompt = tmp.ToString(); if (output == null) output = new ConsoleOutputDevice(System.Console.Out, true); if (message == null) message = new ConsoleOutputDevice(System.Console.Error, false); if (input == null) input = new ConsoleInputDevice(); if (output is ConsoleOutputDevice) (output as ConsoleOutputDevice).Prompt = prompt; if (input is ConsoleInputDevice) (input as ConsoleInputDevice).Prompt = prompt; }
public void SetOutDevice(OutputDevice device) { if (device == null) throw new ArgumentNullException("device"); if (device is ConsoleOutputDevice) (device as ConsoleOutputDevice).Prompt = prompt; output = device; }
public void SetErrorDevice(OutputDevice device) { if (device == null) throw new ArgumentNullException("device"); message = device; }
public TableRenderer(ColumnDesign[] columns, OutputDevice output) : this(columns, output, "|", true, true) { }
/** print time to output device */ public static void PrintTime(long execTimeInMs, long usec, OutputDevice output) { long totalTime = execTimeInMs; bool hourPrinted = false; bool minutePrinted = false; if (execTimeInMs > HourMillis) { output.Write(Convert.ToString(execTimeInMs / HourMillis)); output.Write("h "); execTimeInMs %= HourMillis; hourPrinted = true; } if (hourPrinted || execTimeInMs > MinuteMillis) { long minute = execTimeInMs / 60000; if (hourPrinted && minute < 10) { output.Write("0"); // need padding. } output.Write(minute.ToString()); output.Write("m "); execTimeInMs %= MinuteMillis; minutePrinted = true; } if (minutePrinted || execTimeInMs >= SecondMillis) { long seconds = execTimeInMs / SecondMillis; if (minutePrinted && seconds < 10) { output.Write("0"); // need padding. } output.Write(seconds.ToString()); output.Write("."); execTimeInMs %= SecondMillis; // milliseconds if (execTimeInMs < 100) output.Write("0"); if (execTimeInMs < 10) output.Write("0"); output.Write(execTimeInMs.ToString()); } else if (execTimeInMs > 0) { output.Write(execTimeInMs.ToString()); } if (usec > 0) { if (totalTime > 0) { // need delimiter and padding. output.Write("."); if (usec < 100) output.Write("0"); if (usec < 10) output.Write("0"); } output.Write(usec.ToString()); } else if (execTimeInMs == 0) { output.Write("0 "); } if (totalTime > MinuteMillis) { output.Write("s"); } else if (totalTime >= SecondMillis) output.Write(" "); else if (totalTime > 0 && totalTime < SecondMillis) output.Write(" m"); else if (totalTime == 0 && usec > 0) output.Write(" µ"); else output.Write("sec"); }