Class TerminalUtils

java.lang.Object
me.tongfei.progressbar.TerminalUtils

public class TerminalUtils extends Object
Since:
0.9.0
  • Field Details

    • CARRIAGE_RETURN

      static final char CARRIAGE_RETURN
      See Also:
    • ESCAPE_CHAR

      static final char ESCAPE_CHAR
      See Also:
    • DEFAULT_TERMINAL_WIDTH

      static final int DEFAULT_TERMINAL_WIDTH
      See Also:
    • terminal

      private static org.jline.terminal.Terminal terminal
    • cursorMovementSupported

      private static boolean cursorMovementSupported
    • activeConsumers

      static Queue<ProgressBarConsumer> activeConsumers
  • Constructor Details

    • TerminalUtils

      public TerminalUtils()
  • Method Details

    • getTerminalWidth

      static int getTerminalWidth()
    • hasCursorMovementSupport

      static boolean hasCursorMovementSupport()
    • closeTerminal

      static void closeTerminal()
    • filterActiveConsumers

      static <T extends ProgressBarConsumer> Stream<T> filterActiveConsumers(Class<T> clazz)
    • moveCursorUp

      static String moveCursorUp(int count)
    • moveCursorDown

      static String moveCursorDown(int count)
    • getTerminal

      static org.jline.terminal.Terminal getTerminal()
      • Creating terminal is relatively expensive, usually takes between 5-10ms.
        • If updateInterval is set under 10ms creating new terminal for on every re-render of progress bar could be a problem.
        • Especially when multiple progress bars are running in parallel.
      • Another problem with Terminal is that once created you can create another instance (say from different thread), but this instance will be "dumb". Until previously created terminal will be closed.