Scrollable
, InputProvider
, ExtendedTerminal
, Terminal
, Closeable
, AutoCloseable
UnixLikeTTYTerminal
public abstract class UnixLikeTerminal extends ANSITerminal
Modifier and Type | Class | Description |
---|---|---|
static class |
UnixLikeTerminal.CtrlCBehaviour |
This enum lets you control how Lanterna will handle a ctrl+c keystroke from the user.
|
Modifier | Constructor | Description |
---|---|---|
protected |
UnixLikeTerminal(InputStream terminalInput,
OutputStream terminalOutput,
Charset terminalCharset,
UnixLikeTerminal.CtrlCBehaviour terminalCtrlCBehaviour) |
Modifier and Type | Method | Description |
---|---|---|
protected void |
acquire() |
Effectively taking over the terminal and enabling it for Lanterna to use, by turning off echo and canonical mode,
adding resize listeners and optionally trap unix signals.
|
protected abstract void |
canonicalMode(boolean enabled) |
In canonical mode, data are accumulated in a line editing buffer, and do not become "available for reading" until
line editing has been terminated by the user sending a line delimiter character.
|
void |
close() |
Closes the terminal, if applicable.
|
protected UnixLikeTerminal.CtrlCBehaviour |
getTerminalCtrlCBehaviour() |
|
protected abstract void |
keyEchoEnabled(boolean enabled) |
Enables or disable key echo mode, which means when the user press a key, the terminal will immediately print that
key to the terminal.
|
protected abstract void |
keyStrokeSignalsEnabled(boolean enabled) |
This method causes certain keystrokes (at the moment only ctrl+c) to be passed in to the program as a regular
KeyStroke instead of as a signal to the JVM process. |
KeyStroke |
pollInput() |
Returns the next
Key off the input queue or null if there is no more input events available. |
KeyStroke |
readInput() |
Returns the next
Key off the input queue or blocks until one is available. |
protected abstract void |
registerTerminalResizeListener(Runnable onResize) |
|
protected abstract void |
restoreTerminalSettings() |
Restores the terminal settings from last time
saveTerminalSettings() was called |
protected abstract void |
saveTerminalSettings() |
Stores the current terminal device settings (the ones that are modified through this interface) so that they can
be restored later using
restoreTerminalSettings() |
addResizeListener, newTextGraphics, onResized, onResized, removeResizeListener
clearScreen, deiconify, disableSGR, enableSGR, enterPrivateMode, exitPrivateMode, findTerminalSize, getCursorPosition, getDefaultKeyDecodingProfile, getTerminalSize, iconify, maximize, popTitle, pushTitle, resetColorAndSGR, scrollLines, setBackgroundColor, setCursorPosition, setCursorPosition, setCursorVisible, setForegroundColor, setMouseCaptureMode, setTerminalSize, setTitle, unmaximize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addKeyDecodingProfile, bell, enquireTerminal, flush, getCharset, getInputDecoder, putCharacter, translateCharacter, writeToTerminal
addResizeListener, bell, enquireTerminal, flush, newTextGraphics, putCharacter, removeResizeListener
protected UnixLikeTerminal(InputStream terminalInput, OutputStream terminalOutput, Charset terminalCharset, UnixLikeTerminal.CtrlCBehaviour terminalCtrlCBehaviour) throws IOException
IOException
protected void acquire() throws IOException
UnixLikeTerminal
IOException
- If there was an I/O errorpublic void close() throws IOException
Terminal
close
in interface AutoCloseable
close
in interface Closeable
close
in interface Terminal
close
in class ANSITerminal
IOException
- If there was an underlying I/O errorpublic KeyStroke pollInput() throws IOException
InputProvider
Key
off the input queue or null if there is no more input events available. Note, this
method call is not blocking, it returns null immediately if there is nothing on the input stream.pollInput
in interface InputProvider
pollInput
in class ANSITerminal
IOException
- Propagated error if the underlying stream gave errorspublic KeyStroke readInput() throws IOException
InputProvider
Key
off the input queue or blocks until one is available. NOTE: In previous
versions of Lanterna, this method was not blocking. From lanterna 3, it is blocking and you can call
pollInput()
for the non-blocking version.readInput
in interface InputProvider
readInput
in class ANSITerminal
IOException
- Propagated error if the underlying stream gave errorsprotected UnixLikeTerminal.CtrlCBehaviour getTerminalCtrlCBehaviour()
protected abstract void registerTerminalResizeListener(Runnable onResize) throws IOException
IOException
protected abstract void saveTerminalSettings() throws IOException
restoreTerminalSettings()
IOException
- If there was an I/O error when altering the terminal environmentprotected abstract void restoreTerminalSettings() throws IOException
saveTerminalSettings()
was calledIOException
- If there was an I/O error when altering the terminal environmentprotected abstract void keyEchoEnabled(boolean enabled) throws IOException
enabled
- true
if key echo should be enabled, false
otherwiseIOException
- If there was an I/O error when altering the terminal environmentprotected abstract void canonicalMode(boolean enabled) throws IOException
enabled
- true
if canonical input mode should be enabled, false
otherwiseIOException
- If there was an I/O error when altering the terminal environmentprotected abstract void keyStrokeSignalsEnabled(boolean enabled) throws IOException
KeyStroke
instead of as a signal to the JVM process. For example,
ctrl+c will normally send an interrupt that causes the JVM to shut down, but this method will make it pass
in ctrl+c as a regular KeyStroke
instead. You can of course still
make ctrl+c kill the application through your own input handling if you like.
Please note that this method is called automatically by lanterna to disable signals unless you define a system property "com.googlecode.lanterna.terminal.UnixTerminal.catchSpecialCharacters" and set it to the string "false".
enabled
- Pass in true
if you want keystrokes to generate system signals (like process interrupt),
false
if you want lanterna to catch and interpret these keystrokes are regular keystrokesIOException
- If there was an I/O error when attempting to disable special charactersUnixLikeTerminal.CtrlCBehaviour
Copyright © 2020. All rights reserved.