Fix display when more concurrent threads than the terminal height, fixes #17

This commit is contained in:
Guillaume Nodet
2020-02-17 12:00:15 +01:00
parent 9154e78c27
commit 7002f127a0

View File

@@ -163,11 +163,17 @@ public class Client {
Size size = terminal.getSize(); Size size = terminal.getSize();
display.resize(size.getRows(), size.getColumns()); display.resize(size.getRows(), size.getColumns());
List<AttributedString> lines = new ArrayList<>(); List<AttributedString> lines = new ArrayList<>();
lines.add(new AttributedString("Building..."));
projects.values().stream() projects.values().stream()
.map(AttributedString::fromAnsi) .map(AttributedString::fromAnsi)
.map(s -> s.columnSubSequence(0, size.getColumns())) .map(s -> s.columnSubSequence(0, size.getColumns()))
.forEachOrdered(lines::add); .forEachOrdered(lines::add);
// Make sure we don't try to display more lines than the terminal height
boolean rem = false;
while (lines.size() >= terminal.getHeight()) {
lines.remove(0);
rem = true;
}
lines.add(0, new AttributedString(rem ? "Building... (trimmed)" : "Building..."));
display.update(lines, -1); display.update(lines, -1);
} else if (m instanceof BuildMessage) { } else if (m instanceof BuildMessage) {
BuildMessage bm = (BuildMessage) m; BuildMessage bm = (BuildMessage) m;