Module AM37

Class RawConsoleInput

java.lang.Object
it.polimi.ingsw.view.cli.console.RawConsoleInput

public class RawConsoleInput
extends java.lang.Object
Console input utilities
  • Constructor Details

  • Method Details

    • listenForRawInput

      protected void listenForRawInput()
      Constantly listens for keystrokes
    • listenForStandardInput

      protected void listenForStandardInput()
    • getMaxBufferSize

      public int getMaxBufferSize()
      maxBufferSize getter
      Returns:
      the input buffer maximum size
    • getCurrentBuffer

      public java.lang.String getCurrentBuffer()
    • flushBuffer

      public void flushBuffer()
    • nextLine

      public java.lang.String nextLine()
      Returns the last line read and empties the buffer
      Returns:
      the next line
    • hasNext

      public boolean hasNext()
      Returns true if this scanner has another token in its input.
      Returns:
      true if and only if this scanner has another token
    • currentInputSize

      public int currentInputSize()
      Provides the number of printable characters in the buffer
      Returns:
      the number of characters in the buffer
    • addKeyEventListener

      public void addKeyEventListener​(KeyEventListener listener)
      Adds a new key event listener
      If the listener already was in the listeners list, nothing happens
      Parameters:
      listener - the listener to add
    • removeKeyEventListener

      public void removeKeyEventListener​(KeyEventListener listener)
      Removes a key event listener
      If the listener was not in the listeners list, nothing happens
      Parameters:
      listener - the listener to remove
    • currentBufferSize

      protected int currentBufferSize()
      Provides the current size of the input string stored in the buffer
      Returns:
      the input length
    • isConsoleInputEnabled

      public boolean isConsoleInputEnabled()
      Determines if the console input is enabled

      ling or disabling the console input does not affect the listenForRawInput() method in any way;

      • Input enabled: the console works as usual, registering all keystrokes and adding new characters in the buffer
      • Input disabled: no echo is provided, "locking" the cursor in place; the console just ignores the keystrokes, not filling the buffer.
      Escape sequences are always evaluated.
      Returns:
      true if the input is enabled, false otherwise
    • enableConsoleInput

      public void enableConsoleInput()
      Enables the console input
      See Also:
      isConsoleInputEnabled()
    • disableConsoleInput

      public void disableConsoleInput()
      Disables the console input
      See Also:
      isConsoleInputEnabled()