java.lang.Object
com.googlecode.lanterna.terminal.AbstractTerminal
- All Implemented Interfaces:
InputProvider
,Terminal
,Closeable
,AutoCloseable
- Direct Known Subclasses:
DefaultVirtualTerminal
,StreamBasedTerminal
Containing a some very fundamental functionality that should be common (and usable) to all terminal implementations.
All the Terminal implementers within Lanterna extends from this class.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addResizeListener
(TerminalResizeListener listener) Adds aTerminalResizeListener
to be called when the terminal has changed size.Creates a new TextGraphics object that uses this Terminal directly when outputting.protected void
onResized
(int columns, int rows) Call this method when the terminal has been resized or the initial size of the terminal has been discovered.protected void
onResized
(TerminalSize newSize) Call this method when the terminal has been resized or the initial size of the terminal has been discovered.void
removeResizeListener
(TerminalResizeListener listener) Removes aTerminalResizeListener
from the list of listeners to be notified when the terminal has changed sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.googlecode.lanterna.input.InputProvider
pollInput, readInput
Methods inherited from interface com.googlecode.lanterna.terminal.Terminal
bell, clearScreen, close, disableSGR, enableSGR, enquireTerminal, enterPrivateMode, exitPrivateMode, flush, getCursorPosition, getTerminalSize, putCharacter, putString, resetColorAndSGR, setBackgroundColor, setCursorPosition, setCursorPosition, setCursorVisible, setForegroundColor
-
Field Details
-
resizeListeners
-
lastKnownSize
-
-
Constructor Details
-
AbstractTerminal
protected AbstractTerminal()
-
-
Method Details
-
addResizeListener
Description copied from interface:Terminal
Adds aTerminalResizeListener
to be called when the terminal has changed size. There is no guarantee that this listener will really be invoked when the terminal has changed size, at all depends on the terminal emulator implementation. Normally on Unix systems the WINCH signal will be sent to the process and lanterna can intercept this.There are no guarantees on what thread the call will be made on, so please be careful with what kind of operation you perform in this callback. You should probably not take too long to return.
- Specified by:
addResizeListener
in interfaceTerminal
- Parameters:
listener
- Listener object to be called when the terminal has been changed- See Also:
-
removeResizeListener
Description copied from interface:Terminal
Removes aTerminalResizeListener
from the list of listeners to be notified when the terminal has changed size- Specified by:
removeResizeListener
in interfaceTerminal
- Parameters:
listener
- Listener object to remove- See Also:
-
onResized
protected void onResized(int columns, int rows) Call this method when the terminal has been resized or the initial size of the terminal has been discovered. It will trigger all resize listeners, but only if the size has changed from before.- Parameters:
columns
- Number of columns in the new sizerows
- Number of rows in the new size
-
onResized
Call this method when the terminal has been resized or the initial size of the terminal has been discovered. It will trigger all resize listeners, but only if the size has changed from before.- Parameters:
newSize
- Last discovered terminal size
-
newTextGraphics
Description copied from interface:Terminal
Creates a new TextGraphics object that uses this Terminal directly when outputting. Keep in mind that you are probably better off to switch to a Screen to make advanced text graphics more efficient. Also, this TextGraphics implementation will not call.flush()
after any operation, so you'll need to do that on your own.- Specified by:
newTextGraphics
in interfaceTerminal
- Returns:
- TextGraphics implementation that draws directly using this Terminal interface
- Throws:
IOException
- If there was an I/O error when setting up theTextGraphics
object
-