Max out display update rate at every 10 ms
@@ -139,6 +139,7 @@ public class Client {
Display display = new Display(terminal, false);
boolean exit = false;
BuildException error = null;
+ long lastUpdate = 0;
while (!exit) {
Message m = daemon.receive();
if (m instanceof BuildException) {
@@ -160,21 +161,26 @@ public class Client {
case ProjectStopped:
projects.remove(be.projectId);
}
+ // no need to refresh the display at every single step
+ long curTime = System.currentTimeMillis();
+ if (curTime - lastUpdate >= 10) {
Size size = terminal.getSize();
display.resize(size.getRows(), size.getColumns());
List<AttributedString> lines = new ArrayList<>();
projects.values().stream()
.map(AttributedString::fromAnsi)
- .map(s -> s.columnSubSequence(0, size.getColumns()))
+ .map(s -> s.columnSubSequence(0, size.getColumns() - 1))
.forEachOrdered(lines::add);
// Make sure we don't try to display more lines than the terminal height
- boolean rem = false;
+ int rem = 0;
while (lines.size() >= terminal.getHeight()) {
lines.remove(0);
- rem = true;
+ rem++;
}
- lines.add(0, new AttributedString(rem ? "Building... (trimmed)" : "Building..."));
+ lines.add(0, new AttributedString("Building..." + (rem > 0 ? " (" + rem + " more)" : "")));
display.update(lines, -1);
+ lastUpdate = curTime;
+ }
} else if (m instanceof BuildMessage) {
BuildMessage bm = (BuildMessage) m;
log.add(bm.getMessage());
