Class Terminal<T>

java.lang.Object
pretty.Terminal<T>
Type Parameters:
T - T - type of the keys

public class Terminal<T> extends Object
Manage terminal input and output
  • Method Details

    • build

      public static Terminal<Key> build()
      Build a terminal with the default key translator
      Returns:
      terminal instance
    • build

      public static <K> Terminal<K> build(KeyTranslator<K> translator)
      Build a terminal with a custom key translator
      Type Parameters:
      K - K - type of the keys
      Parameters:
      translator - - custom key translator
      Returns:
      terminal instance
    • start

      public void start()
      Start the terminal, called by default in Menu
    • clear

      public void clear()
      Clear the terminal screen
    • nextLine

      public String nextLine(String prompt)
      Print a prompt to the terminal and return the next line as Scanner's method
      Parameters:
      prompt - - prompt to print
      Returns:
      the next line
    • key

      public T key()
      Return the next key pressed and translated by KeyTranslator
      Returns:
      the key
    • setTranslator

      public void setTranslator(KeyTranslator<T> translator)
      Set the key translator
      Parameters:
      translator - - key translator