Stop output wrapping in SuperConsoleEventBusListener.
Summary:
There is an ANSI control code that lets us turn off terminal wrapping.
Use this code to stop pretty output from spewing in narrow terminals.
diff --git a/src/com/facebook/buck/event/listener/SuperConsoleEventBusListener.java b/src/com/facebook/buck/event/listener/SuperConsoleEventBusListener.java
index ead0fa2..414b3d2 100644
--- a/src/com/facebook/buck/event/listener/SuperConsoleEventBusListener.java
+++ b/src/com/facebook/buck/event/listener/SuperConsoleEventBusListener.java
@@ -97,6 +97,7 @@
synchronized void render() {
ImmutableList<String> lines = createRenderLinesAtTime(clock.currentTimeMillis());
String nextFrame = clearLastRender() + Joiner.on("\n").join(lines);
+ nextFrame = ansi.asNoWrap(nextFrame);
lastNumLinesPrinted = lines.size();
// Synchronize on the DirtyPrintStreamDecorator to prevent interlacing of output.
diff --git a/src/com/facebook/buck/util/Ansi.java b/src/com/facebook/buck/util/Ansi.java
index 01c5f18..0adc0db 100644
--- a/src/com/facebook/buck/util/Ansi.java
+++ b/src/com/facebook/buck/util/Ansi.java
@@ -51,6 +51,9 @@
private static final String ERASE_IN_LINE = "\u001B[%dK";
+ private static final String STOP_WRAPPING = "\u001B[?7l";
+ private static final String RESUME_WRAPPING = "\u001B[?7h";
+
private final boolean isAnsiTerminal;
private static final Ansi noTtyAnsi = new Ansi(false /* isAnsiTerminal */);
@@ -133,6 +136,14 @@
}
}
+ public String asNoWrap(String text) {
+ if (isAnsiTerminal) {
+ return STOP_WRAPPING + text + RESUME_WRAPPING;
+ } else {
+ return text;
+ }
+ }
+
public void printHighlightedFailureText(PrintStream stream, String text) {
stream.print(asHighlightedFailureText(text));
}