Class TerminalWriter

java.lang.Object
java.io.Writer
java.io.PrintWriter
com.aoapps.hodgepodge.io.TerminalWriter
All Implemented Interfaces:
NoClose, Closeable, Flushable, Appendable, AutoCloseable

public class TerminalWriter extends PrintWriter implements NoClose
A writer that controls advanced features of VT/100 terminals, while silently reverting to standard behavior where the functions are not supported.
Author:
AO Industries, Inc.
  • Constructor Details

    • TerminalWriter

      public TerminalWriter(Writer out)
    • TerminalWriter

      public TerminalWriter(Writer out, boolean autoFlush)
  • Method Details

    • isSupported

      public static boolean isSupported()
    • progressOutput

      public static String progressOutput(String lastVerboseString, String newVerboseString, PrintStream out)
      (Over)writes a progress line to the given PrintStream. Any extra characters from previous output are covered with spaces. Any common prefix is not overwritten.
      Parameters:
      lastVerboseString - The last line output
      newVerboseString - The new line to display
      Returns:
      The new line (newVerboseString)
    • progressOutput

      public static String progressOutput(String lastVerboseString, String newVerboseString, Writer out) throws IOException
      (Over)writes a progress line to the given PrintStream. Any extra characters from previous output are covered with spaces. Any common prefix is not overwritten.
      Parameters:
      lastVerboseString - The last line output
      newVerboseString - The new line to display
      Returns:
      The new line (newVerboseString)
      Throws:
      IOException
    • isNoClose

      public boolean isNoClose()
      Specified by:
      isNoClose in interface NoClose
    • attributesOff

      public void attributesOff() throws IOException
      Throws:
      IOException
    • boldOn

      public void boldOn() throws IOException
      Throws:
      IOException
    • clearScreen

      public void clearScreen() throws IOException
      Throws:
      IOException
    • isEnabled

      public boolean isEnabled()
    • setEnabled

      public void setEnabled(boolean enabled)
      Enables the special features of the terminal writer.
    • progressOutput

      public String progressOutput(String lastVerboseString, String newVerboseString) throws IOException
      Throws:
      IOException
      See Also: