AutoCloseable
, Closeable
, InputProvider
, IOSafeTerminal
, Terminal
DefaultVirtualTerminal
public interface VirtualTerminal extends IOSafeTerminal
VirtualTerminal
interface extends this interface and
allows you to query and modify its internals in a way you can not do with a regular terminal. The AWT and Swing
terminal implementations in Lanterna uses the DefaultVirtualTerminal
class internally for keeping its state
and doing most of the terminal operations.Modifier and Type | Interface | Description |
---|---|---|
static interface |
VirtualTerminal.BufferLine |
Interface used by
VirtualTerminal.BufferWalker to repressent a line in the text buffer when iterating over a range of
lines |
static interface |
VirtualTerminal.BufferWalker |
Callback interface that is used by
forEachLine(int, int, BufferWalker) as a way to iterate over a range
of lines in the text buffer |
Modifier and Type | Method | Description |
---|---|---|
void |
addInput(KeyStroke keyStroke) |
Adds a
KeyStroke to the input queue of this virtual terminal. |
void |
addVirtualTerminalListener(VirtualTerminalListener listener) |
Adds a listener to receive notifications when certain events happens on the virtual terminal.
|
void |
forEachLine(int startRow,
int endRow,
VirtualTerminal.BufferWalker bufferWalker) |
Iterates over a range of lines in the text buffer
|
TextCharacter |
getBufferCharacter(int column,
int row) |
Returns a character from this virtual terminal, relative to the top-left position of the text buffer including
any backlog.
|
TextCharacter |
getBufferCharacter(TerminalPosition position) |
Returns a character from this virtual terminal, relative to the top-left position of the text buffer including
any backlog.
|
int |
getBufferLineCount() |
Returns the number of lines in the entire text buffer, including any backlog
|
TextCharacter |
getCharacter(int column,
int row) |
Returns a character from the viewport at the specified coordinates.
|
TextCharacter |
getCharacter(TerminalPosition position) |
Returns a character from the viewport at the specified coordinates.
|
TerminalPosition |
getCursorBufferPosition() |
Returns the position of the terminal cursor where the row index is counted from the top of the text buffer,
including all backlog.
|
boolean |
isCursorVisible() |
Checks if the terminal cursor is visible or not
|
void |
removeVirtualTerminalListener(VirtualTerminalListener listener) |
Removes a listener from this virtual terminal so it will no longer receive events.
|
void |
setBacklogSize(int backlogSize) |
Sets the number of rows to allow in the non-private buffer above the viewport.
|
void |
setTerminalSize(TerminalSize newSize) |
Changes the "visible size" of the virtual terminal.
|
bell, clearScreen, close, disableSGR, enableSGR, enquireTerminal, enterPrivateMode, exitPrivateMode, flush, getCursorPosition, getTerminalSize, pollInput, putCharacter, readInput, resetColorAndSGR, setBackgroundColor, setCursorPosition, setCursorPosition, setCursorVisible, setForegroundColor
addResizeListener, newTextGraphics, removeResizeListener
void setTerminalSize(TerminalSize newSize)
newSize
- New size of the virtual terminalvoid addVirtualTerminalListener(VirtualTerminalListener listener)
TerminalResizeListener
, but as the
VirtualTerminalListener
also allows you to listen on size changes, it can be used for the same purpose.listener
- Listener to receive events from this virtual terminalvoid removeVirtualTerminalListener(VirtualTerminalListener listener)
TerminalResizeListener
.listener
- Listener to remove from this virtual terminalvoid setBacklogSize(int backlogSize)
backlogSize + terminalSize.getRows()
. If set to 0, there is no scrollback. Please note that
private mode is unaffected by this and will always have no backlog.backlogSize
- Number of rows of backlogboolean isCursorVisible()
true
if the terminal cursor is visible, false
otherwisevoid addInput(KeyStroke keyStroke)
KeyStroke
to the input queue of this virtual terminal. This even will be read the next time either
IOSafeTerminal.pollInput()
or IOSafeTerminal.readInput()
is called, assuming there are no other events before it in the queue.keyStroke
- KeyStroke
to add to the input queue of this virtual terminalTerminalPosition getCursorBufferPosition()
IOSafeTerminal.getCursorPosition()
instead.TextCharacter getBufferCharacter(TerminalPosition position)
getCharacter(TerminalPosition)
instead.position
- Position to get the character fromTextCharacter getBufferCharacter(int column, int row)
getCharacter(int, int)
instead.column
- Column to get the character fromrow
- Row, counting from the first line in the backlog, to get the character fromTextCharacter getCharacter(TerminalPosition position)
getBufferCharacter(TerminalPosition)
instead.position
- Position of the character to returnTextCharacter getCharacter(int column, int row)
getBufferCharacter(int,int)
instead.column
- Column in the viewport to get the character fromrow
- Row in the viewport to get the character formint getBufferLineCount()
void forEachLine(int startRow, int endRow, VirtualTerminal.BufferWalker bufferWalker)
startRow
- Index of the first row of the iteration, counting 0 as the first row in the backlogendRow
- Index of the last row of the iteration (inclusive), counting 0 as the first row in the backlogbufferWalker
- Callback to invoke on each row in the iterationCopyright © 2020. All rights reserved.