diff options
author | Klaus Aehlig <aehlig@google.com> | 2016-02-29 10:21:13 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2016-02-29 17:40:09 +0000 |
commit | a39d6f84e106a80bd63d8ec89e86d65c2c70aede (patch) | |
tree | ccaae2f4a03972c93e7ffb9b83d85f68a27bf043 | |
parent | 05c7d11baba6eca78cd9b440a6453fdab366c2c8 (diff) |
ExperimentalEventHandler: break lines explicitly
In order to correctly erase the current progress bar, we
need to know how many lines it is long. Instead of trying
to compute it, enforce explicit breaks shorter than the terminal
width.
--
Change-Id: Ifac16b351e1390f553d0ceac2b647b1178b58d0b
Reviewed-on: https://bazel-review.googlesource.com/#/c/3024
MOS_MIGRATED_REVID=115829390
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java index 5d4918e268..3d7b82fe39 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java @@ -24,6 +24,7 @@ import com.google.devtools.build.lib.events.EventKind; import com.google.devtools.build.lib.pkgcache.LoadingPhaseCompleteEvent; import com.google.devtools.build.lib.util.io.AnsiTerminal; import com.google.devtools.build.lib.util.io.AnsiTerminalWriter; +import com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter; import com.google.devtools.build.lib.util.io.OutErr; import java.io.IOException; @@ -189,7 +190,8 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler { private void addProgressBar() throws IOException { LineCountingAnsiTerminalWriter terminalWriter = new LineCountingAnsiTerminalWriter(terminal); - stateTracker.writeProgressBar(terminalWriter); + stateTracker.writeProgressBar( + new LineWrappingAnsiTerminalWriter(terminalWriter, terminalWidth - 1)); terminalWriter.newline(); numLinesProgressBar = terminalWriter.getWrittenLines(); } @@ -198,7 +200,6 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler { private final AnsiTerminal terminal; private int lineCount; - private int currentLineLength; LineCountingAnsiTerminalWriter(AnsiTerminal terminal) { this.terminal = terminal; @@ -208,7 +209,6 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler { @Override public AnsiTerminalWriter append(String text) throws IOException { terminal.writeString(text); - currentLineLength += text.length(); return this; } @@ -216,11 +216,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler { public AnsiTerminalWriter newline() throws IOException { terminal.cr(); terminal.writeString("\n"); - // Besides the line ended by the newline() command, a line-shift can also happen - // by a string longer than the terminal width being wrapped around; account for - // this as well. - lineCount += 1 + currentLineLength / terminalWidth; - currentLineLength = 0; + lineCount++; return this; } |