public abstract class EmulatedTerminalState
extends java.lang.Object
All output is stored in a 2-dimensional buffer of of cells, which store the character to be drawn and the attributes/color of that character.
The current cursor position is remembered and can be manipulated by the application. The cursor visibility state can be externally controlled as well.
Input is read using key events and that is kept in a FIFO buffer as if they had been sent by the remote terminal hardware.
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
cfgLock
Lock object for synchronizing configuration usage and changes.
|
protected int |
cursorX
Current X coordinate of the cursor.
|
protected int |
cursorY
Current Y coordinate of the cursor.
|
protected Cell[][] |
data
Screen contents.
|
protected java.lang.Object |
dataLock
Lock object for synchronizing data and cursor usage and changes.
|
protected TerminalOptions |
options
Terminal configuration storage.
|
protected java.lang.Object |
selLock
Lock object for synchronizing selection processing.
|
protected boolean |
showCursor
Flag that controls if the cursor is visible or not.
|
Constructor and Description |
---|
EmulatedTerminalState()
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
append(Cell[] output)
Copy the given cells into the 2-dimensional output buffer starting at
the current cursor position and writing to the "right", incrementing
the cursor X position for each cell.
|
void |
clear()
Overwrite the entire 2-dimensional output buffer with the space character
to be rendered with the
Color.NORMAL color. |
void |
configure(TerminalOptions terminalOptions)
Initialize the instance using the given configuration.
|
int |
getColumns()
Gets the number of columns on the screen.
|
int |
getCursorX()
Get the cursor's current X coordinate.
|
int |
getCursorY()
Get the cursor's current Y coordinate.
|
int |
getRows()
Gets the number of rows on the screen.
|
Cell[][] |
getScreenData()
Get screen memory array.
|
TerminalOptions |
getTerminalOptions()
Get terminal options used by client.
|
void |
replace(Cell[][] screen,
int newX,
int newY)
Completely replace the current 2-dimensional output buffer with the
content on the given
screen parameter and then set the
the cursor position to the given values. |
boolean |
setCursor(int x,
int y)
Position the cursor.
|
boolean |
setCursorStatus(boolean on)
Set the cursor visibility.
|
private boolean |
setCursorWorker(int x,
int y,
int w,
int h)
Position the cursor.
|
abstract void |
triggerRepaint(boolean full)
Cause a partial or full repaint to occur.
|
protected TerminalOptions options
protected java.lang.Object cfgLock
protected java.lang.Object selLock
protected java.lang.Object dataLock
protected boolean showCursor
protected Cell[][] data
protected int cursorX
protected int cursorY
public void append(Cell[] output)
This write operation does not cause a repaint to occur, but the next repaint that does occur will do so with the updated content.
output
- List of cells to write into the buffer.public void replace(Cell[][] screen, int newX, int newY)
screen
parameter and then set the
the cursor position to the given values. Only non-null cells are copied.
Any cells that are null are ignored and left alone in the target buffer.
This write operation DOES cause a repaint to occur.
screen
- 2-dimensional array of cells to write into the buffer. This
must have the same dimensions as the output buffer and all
rows must have column arrays of the same size.newX
- Cursor X position after the method call.newY
- Cursor Y position after the method call.public void clear()
Color.NORMAL
color. Sets the cursor
Y and X positions to 0.public boolean setCursor(int x, int y)
x
- New X cursor position.y
- New Y cursor position.true
if cursor positioning succeeded.public boolean setCursorStatus(boolean on) throws java.lang.IllegalStateException
on
- true
to make the cursor visible (subsequen repaint
operations will then cause the cursor to be drawn).java.lang.IllegalStateException
public int getCursorX()
public int getCursorY()
public int getRows()
public int getColumns()
public void configure(TerminalOptions terminalOptions)
terminalOptions
- The configuration for the terminal simulator.public abstract void triggerRepaint(boolean full)
full
is
true
or if there is no current selection operation occurring,
a repaint of the entire component ("screen") will occur. Otherwise,
a repaint of only the selection area will occur.full
- Flag to force a the entire screen to repaint.public Cell[][] getScreenData()
public TerminalOptions getTerminalOptions()
private boolean setCursorWorker(int x, int y, int w, int h)
x
- New X cursor position.y
- New Y cursor position.w
- Screen width.h
- Screen height.true
if cursor positioning succeeded.