public void flush(PrintWriter output) {
    StringBuilder sb = new StringBuilder();

    sb.append(normal());
    Attributes attributes = new Attributes();
    for (int row = 0; row < rows; row++) {
      flushRow(row, sb, attributes);
    }

    if (
      cursorVisible && cursorRow >= 0 && cursorColumn >= 0 && cursorRow < rows
        && cursorColumn < columns
    ) {
      sb.append(cursor(true));
      sb.append(moveCursor(cursorColumn, cursorRow));
    } else {
      sb.append(cursor(false));
    }

    output.write(sb.toString());
    output.flush();
  }
Represents a buffer of the terminal screen for double-buffering.
hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/terminal/impl/ScreenBuffer.java