use of com.google.devtools.build.lib.util.io.AnsiTerminalWriter in project bazel by bazelbuild.
the class FancyTerminalEventHandler method progress.
/**
* Displays a progress message that may be erased by subsequent messages.
*
* @param prefix a short string such as "[99%] " or "INFO: ", which will be highlighted
* @param rest the remainder of the message; may be multiple lines
*/
private void progress(String prefix, String rest) throws IOException {
previousLineErasable = true;
if (progressInTermTitle) {
int newlinePos = rest.indexOf('\n');
if (newlinePos == -1) {
terminal.setTitle(prefix + rest);
} else {
terminal.setTitle(prefix + rest.substring(0, newlinePos));
}
}
LineCountingAnsiTerminalWriter countingWriter = new LineCountingAnsiTerminalWriter(terminal);
AnsiTerminalWriter terminalWriter = countingWriter;
if (useCursorControls) {
terminalWriter = new LineWrappingAnsiTerminalWriter(terminalWriter, terminalWidth - 1);
}
if (useColor) {
terminalWriter.okStatus();
}
terminalWriter.append(prefix);
terminalWriter.normal();
if (showTimestamp) {
String timestamp = timestamp();
terminalWriter.append(timestamp);
}
Iterator<String> lines = LINEBREAK_SPLITTER.split(rest).iterator();
String firstLine = lines.next();
terminalWriter.append(firstLine);
terminalWriter.newline();
while (lines.hasNext()) {
String line = lines.next();
terminalWriter.append(line);
terminalWriter.newline();
}
numLinesPreviousErasable = countingWriter.getWrittenLines();
}
use of com.google.devtools.build.lib.util.io.AnsiTerminalWriter in project bazel by bazelbuild.
the class ExperimentalEventHandler method addProgressBar.
private synchronized void addProgressBar() throws IOException {
LineCountingAnsiTerminalWriter countingTerminalWriter = new LineCountingAnsiTerminalWriter(terminal);
AnsiTerminalWriter terminalWriter = countingTerminalWriter;
lastRefreshMillis = clock.currentTimeMillis();
if (cursorControl) {
terminalWriter = new LineWrappingAnsiTerminalWriter(terminalWriter, terminalWidth - 1);
}
stateTracker.writeProgressBar(terminalWriter, /* shortVersion=*/
!cursorControl);
terminalWriter.newline();
numLinesProgressBar = countingTerminalWriter.getWrittenLines();
if (progressInTermTitle) {
LoggingTerminalWriter stringWriter = new LoggingTerminalWriter(true);
stateTracker.writeProgressBar(stringWriter, true);
terminal.setTitle(stringWriter.getTranscript());
}
}
Aggregations