public class ECMA48
extends java.lang.Object
implements java.lang.Runnable
It currently implements VT100, VT102, VT220, and XTERM with the following caveats:
- The vttest scenario for VT220 8-bit controls (11.1.2.3) reports a failure with XTERM. This is due to vttest failing to decode the UTF-8 stream.
- Smooth scrolling, printing, keyboard locking, keyboard leds, and tests from VT100 are not supported.
- User-defined keys (DECUDK), downloadable fonts (DECDLD), and VT100/ANSI compatibility mode (DECSCL) from VT220 are not supported. (Also, because DECSCL is not supported, it will fail the last part of the vttest "Test of VT52 mode" if DeviceType is set to VT220.)
- Numeric/application keys from the number pad are not supported because they are not exposed from the TKeypress API.
- VT52 HOLD SCREEN mode is not supported.
- In VT52 graphics mode, the 3/, 5/, and 7/ characters (fraction numerators) are not rendered correctly.
- All data meant for the 'printer' (CSI Pc ? i) is discarded.
Modifier and Type | Class and Description |
---|---|
static class |
ECMA48.DeviceType
The emulator can emulate several kinds of terminals.
|
static class |
ECMA48.MouseProtocol
XTERM mouse reporting protocols.
|
Constructor and Description |
---|
ECMA48(ECMA48.DeviceType type,
java.io.InputStream inputStream,
java.io.OutputStream outputStream,
DisplayListener displayListener)
Public constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addUserEvent(TInputEvent event)
Add a keyboard and mouse event from the user to the queue.
|
void |
close()
Close the input and output streams and stop the reader thread.
|
static java.lang.String |
deviceTypeLang(ECMA48.DeviceType deviceType,
java.lang.String baseLang)
Return the proper LANG for this device type.
|
static java.lang.String |
deviceTypeTerm(ECMA48.DeviceType deviceType)
Return the proper TERM environment variable for this device type.
|
DisplayLine |
getBlankDisplayLine()
Obtain a new blank display line for an external user
(e.g.
|
int |
getCursorX()
Expose current cursor X to outside world.
|
int |
getCursorY()
Expose current cursor Y to outside world.
|
java.util.List<DisplayLine> |
getDisplayBuffer()
Get the display buffer.
|
int |
getHeight()
Get the display height.
|
ECMA48.MouseProtocol |
getMouseProtocol()
Get the mouse protocol.
|
java.lang.String |
getScreenTitle()
Get the screen title as set by the xterm OSC sequence.
|
java.util.List<DisplayLine> |
getScrollbackBuffer()
Get the scrollback buffer.
|
java.util.List<DisplayLine> |
getVisibleDisplay(int visibleHeight,
int scrollBottom)
Get the visible display + scrollback buffer, offset by a specified
number of rows from the bottom.
|
int |
getWidth()
Get the display width.
|
boolean |
hasHiddenMousePointer()
Returns true if this terminal has requested the mouse pointer be
hidden.
|
boolean |
isColumns132()
Get 132 columns value.
|
boolean |
isCursorVisible()
Get visible cursor flag.
|
boolean |
isReading()
See if the reader thread is still running.
|
void |
run()
Read function runs on a separate thread.
|
void |
setHeight(int height)
Set the display height.
|
void |
setTextHeight(int textHeight)
Set the height of a character cell in pixels.
|
void |
setTextWidth(int textWidth)
Set the width of a character cell in pixels.
|
void |
setWidth(int width)
Set the display width.
|
void |
writeRemote(java.lang.String str)
Write a string directly to the remote side.
|
public ECMA48(ECMA48.DeviceType type, java.io.InputStream inputStream, java.io.OutputStream outputStream, DisplayListener displayListener) throws java.io.UnsupportedEncodingException
type
- one of the DeviceType constants to select VT100, VT102,
VT220, or XTERMinputStream
- an InputStream connected to the remote side. For
type == XTERM, inputStream is converted to a Reader with UTF-8
encoding.outputStream
- an OutputStream connected to the remote user. For
type == XTERM, outputStream is converted to a Writer with UTF-8
encoding.displayListener
- a callback to the outer display, or null for
default VT100 behaviorjava.io.UnsupportedEncodingException
- if an exception is thrown when
creating the InputStreamReaderpublic final void run()
run
in interface java.lang.Runnable
public void addUserEvent(TInputEvent event)
event
- the input event to consumepublic static java.lang.String deviceTypeTerm(ECMA48.DeviceType deviceType)
deviceType
- DeviceType.VT100, DeviceType, XTERM, etc.public static java.lang.String deviceTypeLang(ECMA48.DeviceType deviceType, java.lang.String baseLang)
deviceType
- DeviceType.VT100, DeviceType, XTERM, etc.baseLang
- a base language without UTF-8 flag such as "C" or
"en_US"public void writeRemote(java.lang.String str)
str
- string to sendpublic final void close()
public final boolean isReading()
public final DisplayLine getBlankDisplayLine()
public final java.util.List<DisplayLine> getScrollbackBuffer()
public final java.util.List<DisplayLine> getDisplayBuffer()
public final java.util.List<DisplayLine> getVisibleDisplay(int visibleHeight, int scrollBottom)
visibleHeight
- the total height of the display to showscrollBottom
- the number of rows from the bottom to scroll backpublic final int getWidth()
public final void setWidth(int width)
width
- the new widthpublic final int getHeight()
public final void setHeight(int height)
height
- the new heightpublic final boolean isCursorVisible()
public final java.lang.String getScreenTitle()
public final boolean isColumns132()
public final int getCursorX()
public final int getCursorY()
public final boolean hasHiddenMousePointer()
public ECMA48.MouseProtocol getMouseProtocol()
public void setTextWidth(int textWidth)
textWidth
- the width in pixels of a character cellpublic void setTextHeight(int textHeight)
textHeight
- the height in pixels of a character cellCopyright © 2019 Kevin Lamonte. Licensed MIT.