Package com.marcpg.libpg.formular
Class RawConsoleInput
java.lang.Object
com.marcpg.libpg.formular.RawConsoleInput
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.
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
Modifier and TypeClassDescriptionprotected static class
Internal - Should not be used outside of this class! -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
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.
-
Constructor Details
-
RawConsoleInput
public RawConsoleInput()
-
-
Method Details
-
read
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 useSystem.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
isfalse
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
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.
-