private void update()

in common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalOutput.java [488:559]


    private void update() {
        if (noBuffering || dumb) {
            try {
                log.flush();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return;
        }
        // no need to refresh the display at every single step
        final Size size = terminal.getSize();
        final int rows = size.getRows();
        final int cols = size.getColumns();
        display.resize(rows, size.getColumns());
        if (rows <= 0) {
            clearDisplay();
            return;
        }
        final List<AttributedString> lines = new ArrayList<>(rows);
        final int projectsCount = projects.size();

        int dispLines = rows;
        // status line
        dispLines--;
        // there's a bug which sometimes make the cursor goes one line below,
        // so keep one more line empty at the end
        dispLines--;

        addStatusLine(lines, dispLines, projectsCount);

        AttributedString globalFailure = formatFailures();
        if (globalFailure != null) {
            lines.add(globalFailure);
            dispLines--;
        }

        AttributedString globalTransfer = formatTransfers("");
        if (globalTransfer != null) {
            lines.add(globalTransfer);
            dispLines--;
        }

        if (projectsCount <= dispLines) {
            int remLogLines = dispLines - projectsCount;
            for (Project prj : projects.values()) {
                addProjectLine(lines, prj);
                // get the last lines of the project log, taking multi-line logs into account
                int nb = Math.min(remLogLines, linesPerProject);
                List<AttributedString> logs = lastN(prj.log, nb).stream()
                        .flatMap(s -> AttributedString.fromAnsi(s).columnSplitLength(Integer.MAX_VALUE).stream())
                        .map(s -> concat("   ", s))
                        .collect(lastN(nb));
                lines.addAll(logs);
                remLogLines -= logs.size();
            }
            while (remLogLines-- > 0 && lines.size() <= maxThreads + 1) {
                lines.add(AttributedString.EMPTY);
            }
        } else {
            int skipProjects = projectsCount - dispLines;
            for (Project prj : projects.values()) {
                if (skipProjects == 0) {
                    addProjectLine(lines, prj);
                } else {
                    skipProjects--;
                }
            }
        }
        List<AttributedString> trimmed =
                lines.stream().map(s -> s.columnSubSequence(0, cols)).collect(Collectors.toList());
        display.update(trimmed, -1);
    }