Search in sources :

Example 1 with AnsiTerminalWriter

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();
}
Also used : LineCountingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineCountingAnsiTerminalWriter) LineWrappingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter) LineCountingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineCountingAnsiTerminalWriter) AnsiTerminalWriter(com.google.devtools.build.lib.util.io.AnsiTerminalWriter) LineWrappingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter)

Example 2 with AnsiTerminalWriter

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());
    }
}
Also used : LineCountingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineCountingAnsiTerminalWriter) LineWrappingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter) LineCountingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineCountingAnsiTerminalWriter) AnsiTerminalWriter(com.google.devtools.build.lib.util.io.AnsiTerminalWriter) LineWrappingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter) LoggingTerminalWriter(com.google.devtools.build.lib.util.io.LoggingTerminalWriter)

Aggregations

AnsiTerminalWriter (com.google.devtools.build.lib.util.io.AnsiTerminalWriter)2 LineCountingAnsiTerminalWriter (com.google.devtools.build.lib.util.io.LineCountingAnsiTerminalWriter)2 LineWrappingAnsiTerminalWriter (com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter)2 LoggingTerminalWriter (com.google.devtools.build.lib.util.io.LoggingTerminalWriter)1