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