Class RawConsoleInput

java.lang.Object
com.marcpg.libpg.formular.RawConsoleInput

@Internal public final class RawConsoleInput extends Object
Note that this will require you to manually implement the JNA dependency (>5.14.0)!
Should not be used outside of the LibPG library, as it's not tested for other use!

All credits for this code go to source-code.biz! All I did, was reformatting the code, to be more up-to-date.

A JNA based driver for reading single characters from the console.
This class is used for console mode programs. It supports non-blocking reads of single key strokes without echo.
Since:
0.0.8
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Internal - Should not be used outside of this class!
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    read(boolean wait)
    Should not be used outside of the LibPG library, as it's not tested for other use!

    Reads a character from the console without echo.
    void
    Should not be used outside of the LibPG library, as it's not tested for other use!

    Resets console mode to normal line mode with echo.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RawConsoleInput

      public RawConsoleInput()
  • Method Details

    • read

      public int read(boolean wait) throws IOException
      Should not be used outside of the LibPG library, as it's not tested for other use!

      Reads a character from the console without echo. If the character decimal is 3, which is ^C, it will use System.exit(int).
      Parameters:
      wait - true to wait until an input character is available, false to return immediately if no character is available.
      Returns:
      -2 if wait is false and no character is available. -1 on EOF. Otherwise a Unicode/ASCII character code within the range 0 to 0xFFFF.
      Throws:
      IOException - if there was an issue while reading from the console.
    • resetConsoleMode

      public void resetConsoleMode() throws IOException
      Should not be used outside of the LibPG library, as it's not tested for other use!

      Resets console mode to normal line mode with echo.
      On Windows this method re-enables Ctrl-C processing.
      On Unix this method switches the console back to echo mode.
      read(boolean) leaves the console in non-echo mode.
      Throws:
      IOException - if there was an issue while switching to the normal console mode.