Package jexer.backend
Class ECMA48Terminal
- java.lang.Object
-
- jexer.backend.LogicalScreen
-
- jexer.backend.ECMA48Terminal
-
- All Implemented Interfaces:
java.lang.Runnable
,Screen
,TerminalReader
public class ECMA48Terminal extends LogicalScreen implements TerminalReader, java.lang.Runnable
This class reads keystrokes and mouse events and emits output to ANSI X3.64 / ECMA-48 type terminals e.g. xterm, linux, vt100, ansi.sys, etc.
-
-
Field Summary
-
Fields inherited from class jexer.backend.LogicalScreen
cursorVisible, cursorX, cursorY, height, logical, physical, reallyCleared, width
-
-
Constructor Summary
Constructors Constructor Description ECMA48Terminal(Backend backend, java.lang.Object listener, java.io.InputStream input, java.io.OutputStream output)
Constructor sets up state for getEvent().ECMA48Terminal(Backend backend, java.lang.Object listener, java.io.InputStream input, java.io.OutputStream output, int windowWidth, int windowHeight)
Constructor sets up state for getEvent().ECMA48Terminal(Backend backend, java.lang.Object listener, java.io.InputStream input, java.io.Reader reader, java.io.PrintWriter writer)
Constructor sets up state for getEvent().ECMA48Terminal(Backend backend, java.lang.Object listener, java.io.InputStream input, java.io.Reader reader, java.io.PrintWriter writer, boolean setRawMode)
Constructor sets up state for getEvent().
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeTerminal()
Restore terminal to normal state.void
flush()
Flush output.void
flushPhysical()
Push the logical screen to the physical device.void
getEvents(java.util.List<TInputEvent> queue)
Return any events in the IO queue.java.io.PrintWriter
getOutput()
Get the output writer.SessionInfo
getSessionInfo()
Getter for sessionInfo.int
getSixelPaletteSize()
Get the number of colors in the sixel palette.int
getTextHeight()
Get the height of a character cell in pixels.int
getTextWidth()
Get the width of a character cell in pixels.boolean
hasEvents()
Check if there are events in the queue.boolean
hasIterm2Images()
Get the iTerm2 images support flag.boolean
hasJexerImages()
Get the Jexer images support flag.boolean
hasSixel()
Get the sixel support flag.boolean
hasSixelSharedPalette()
Get the sixel shared palette option.boolean
isImagesOverText()
Check if screen will support incomplete image fragments over text display.boolean
isPixelMouse()
Check if terminal is reporting pixel-based mouse position.boolean
isRgbColor()
Get the rgbColor flag.boolean
isWideCharImages()
Get the wideCharImages flag.void
reloadOptions()
Reload options from System properties.void
resizeToScreen()
Resize the physical screen to match the logical screen dimensions.void
run()
Read function runs on a separate thread.void
setHasSixel(boolean sixel)
Set sixel output support flag.void
setListener(java.lang.Object listener)
Set listener to a different Object.void
setMouseStyle(java.lang.String mouseStyle)
Set the mouse pointer (cursor) style.void
setPixelMouse(boolean pixelMouse)
Set request for terminal to report pixel-based mouse position.void
setRgbColor(boolean rgbColor)
Set the rgbColor flag.void
setSixelPaletteSize(int paletteSize)
Set the number of colors in the sixel palette.void
setSixelSharedPalette(boolean sharedPalette)
Set the sixel shared palette option.void
setTitle(java.lang.String title)
Set the window title.void
setWideCharImages(boolean wideCharImages)
Set the wideCharImages flag.-
Methods inherited from class jexer.backend.LogicalScreen
clear, clearPhysical, copySelection, drawBox, drawBox, drawBoxShadow, getAttrXY, getCharXY, getCharXY, getClipBottom, getClipLeft, getClipRight, getClipTop, getCursorX, getCursorY, getHeight, getOffsetX, getOffsetY, getWidth, hideCursor, hLineXY, invertCell, invertCell, isCursorVisible, isDirty, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putCursor, putFullwidthCharXY, putFullwidthCharXY, putFullwidthCharXY, putStringXY, putStringXY, reset, resetClipping, setClipBottom, setClipLeft, setClipRight, setClipTop, setDimensions, setHeight, setOffsetX, setOffsetY, setSelection, setWidth, snapshot, unsetImageRow, vLineXY
-
-
-
-
Constructor Detail
-
ECMA48Terminal
public ECMA48Terminal(Backend backend, java.lang.Object listener, java.io.InputStream input, java.io.OutputStream output, int windowWidth, int windowHeight) throws java.io.UnsupportedEncodingException
Constructor sets up state for getEvent(). If either windowWidth or windowHeight are less than 1, the terminal is not resized.- Parameters:
backend
- the backend that will read from this terminallistener
- the object this backend needs to wake up when new input comes ininput
- an InputStream connected to the remote user, or null for System.in. If System.in is used, then on non-Windows systems it will be put in raw mode; closeTerminal() will (blindly!) put System.in in cooked mode. input is always converted to a Reader with UTF-8 encoding.output
- an OutputStream connected to the remote user, or null for System.out. output is always converted to a Writer with UTF-8 encoding.windowWidth
- the number of text columns to start withwindowHeight
- the number of text rows to start with- Throws:
java.io.UnsupportedEncodingException
- if an exception is thrown when creating the InputStreamReader
-
ECMA48Terminal
public ECMA48Terminal(Backend backend, java.lang.Object listener, java.io.InputStream input, java.io.OutputStream output) throws java.io.UnsupportedEncodingException
Constructor sets up state for getEvent().- Parameters:
backend
- the backend that will read from this terminallistener
- the object this backend needs to wake up when new input comes ininput
- an InputStream connected to the remote user, or null for System.in. If System.in is used, then on non-Windows systems it will be put in raw mode; closeTerminal() will (blindly!) put System.in in cooked mode. input is always converted to a Reader with UTF-8 encoding.output
- an OutputStream connected to the remote user, or null for System.out. output is always converted to a Writer with UTF-8 encoding.- Throws:
java.io.UnsupportedEncodingException
- if an exception is thrown when creating the InputStreamReader
-
ECMA48Terminal
public ECMA48Terminal(Backend backend, java.lang.Object listener, java.io.InputStream input, java.io.Reader reader, java.io.PrintWriter writer, boolean setRawMode)
Constructor sets up state for getEvent().- Parameters:
backend
- the backend that will read from this terminallistener
- the object this backend needs to wake up when new input comes ininput
- the InputStream underlying 'reader'. Its available() method is used to determine if reader.read() will block or not.reader
- a Reader connected to the remote user.writer
- a PrintWriter connected to the remote user.setRawMode
- if true, set System.in into raw mode with stty. This should in general not be used. It is here solely for Demo3, which uses System.in.- Throws:
java.lang.IllegalArgumentException
- if input, reader, or writer are null.
-
ECMA48Terminal
public ECMA48Terminal(Backend backend, java.lang.Object listener, java.io.InputStream input, java.io.Reader reader, java.io.PrintWriter writer)
Constructor sets up state for getEvent().- Parameters:
backend
- the backend that will read from this terminallistener
- the object this backend needs to wake up when new input comes ininput
- the InputStream underlying 'reader'. Its available() method is used to determine if reader.read() will block or not.reader
- a Reader connected to the remote user.writer
- a PrintWriter connected to the remote user.- Throws:
java.lang.IllegalArgumentException
- if input, reader, or writer are null.
-
-
Method Detail
-
setTitle
public void setTitle(java.lang.String title)
Set the window title.- Specified by:
setTitle
in interfaceScreen
- Overrides:
setTitle
in classLogicalScreen
- Parameters:
title
- the new title
-
flushPhysical
public void flushPhysical()
Push the logical screen to the physical device.- Specified by:
flushPhysical
in interfaceScreen
- Overrides:
flushPhysical
in classLogicalScreen
-
resizeToScreen
public void resizeToScreen()
Resize the physical screen to match the logical screen dimensions.- Overrides:
resizeToScreen
in classLogicalScreen
-
hasEvents
public boolean hasEvents()
Check if there are events in the queue.- Specified by:
hasEvents
in interfaceTerminalReader
- Returns:
- if true, getEvents() has something to return to the backend
-
getEvents
public void getEvents(java.util.List<TInputEvent> queue)
Return any events in the IO queue.- Specified by:
getEvents
in interfaceTerminalReader
- Parameters:
queue
- list to append new events to
-
closeTerminal
public void closeTerminal()
Restore terminal to normal state.- Specified by:
closeTerminal
in interfaceTerminalReader
-
setListener
public void setListener(java.lang.Object listener)
Set listener to a different Object.- Specified by:
setListener
in interfaceTerminalReader
- Parameters:
listener
- the new listening object that run() wakes up on new input
-
reloadOptions
public void reloadOptions()
Reload options from System properties.- Specified by:
reloadOptions
in interfaceTerminalReader
-
run
public void run()
Read function runs on a separate thread.- Specified by:
run
in interfacejava.lang.Runnable
-
getTextWidth
public int getTextWidth()
Get the width of a character cell in pixels.- Specified by:
getTextWidth
in interfaceScreen
- Overrides:
getTextWidth
in classLogicalScreen
- Returns:
- the width in pixels of a character cell
-
getTextHeight
public int getTextHeight()
Get the height of a character cell in pixels.- Specified by:
getTextHeight
in interfaceScreen
- Overrides:
getTextHeight
in classLogicalScreen
- Returns:
- the height in pixels of a character cell
-
getSessionInfo
public SessionInfo getSessionInfo()
Getter for sessionInfo.- Returns:
- the SessionInfo
-
getOutput
public java.io.PrintWriter getOutput()
Get the output writer.- Returns:
- the Writer
-
flush
public void flush()
Flush output.
-
isImagesOverText
public boolean isImagesOverText()
Check if screen will support incomplete image fragments over text display.- Returns:
- true if images can partially obscure text
-
isPixelMouse
public boolean isPixelMouse()
Check if terminal is reporting pixel-based mouse position.- Returns:
- true if single-pixel mouse movements are reported
-
setPixelMouse
public void setPixelMouse(boolean pixelMouse)
Set request for terminal to report pixel-based mouse position.- Parameters:
pixelMouse
- if true, single-pixel mouse movements will be reported
-
setMouseStyle
public void setMouseStyle(java.lang.String mouseStyle)
Set the mouse pointer (cursor) style.- Parameters:
mouseStyle
- the pointer style string, one of: "default", "none", "hand", "text", "move", or "crosshair"
-
isWideCharImages
public boolean isWideCharImages()
Get the wideCharImages flag.- Returns:
- true if fullwidth characters (e.g. CJK) are being drawn as images
-
setWideCharImages
public void setWideCharImages(boolean wideCharImages)
Set the wideCharImages flag.- Parameters:
wideCharImages
- if true, draw fullwidth characters (e.g. CJK) as images
-
isRgbColor
public boolean isRgbColor()
Get the rgbColor flag.- Returns:
- true if the standard system colors will be emitted as 24-bit RGB
-
setRgbColor
public void setRgbColor(boolean rgbColor)
Set the rgbColor flag.- Parameters:
rgbColor
- if true, the standard system colors will be emitted as 24-bit RGB images
-
setHasSixel
public void setHasSixel(boolean sixel)
Set sixel output support flag.- Parameters:
sixel
- if true, then images will be emitted as sixel
-
hasSixelSharedPalette
public boolean hasSixelSharedPalette()
Get the sixel shared palette option.- Returns:
- true if all sixel output is using the same palette that is set in one DCS sequence and used in later sequences
-
setSixelSharedPalette
public void setSixelSharedPalette(boolean sharedPalette)
Set the sixel shared palette option.- Parameters:
sharedPalette
- if true, then all sixel output will use the same palette that is set in one DCS sequence and used in later sequences
-
getSixelPaletteSize
public int getSixelPaletteSize()
Get the number of colors in the sixel palette.- Returns:
- the palette size
-
setSixelPaletteSize
public void setSixelPaletteSize(int paletteSize)
Set the number of colors in the sixel palette.- Parameters:
paletteSize
- the new palette size
-
hasSixel
public boolean hasSixel()
Get the sixel support flag.- Returns:
- true if this terminal is emitting sixel
-
hasIterm2Images
public boolean hasIterm2Images()
Get the iTerm2 images support flag.- Returns:
- true if this terminal is emitting iTerm2 images
-
hasJexerImages
public boolean hasJexerImages()
Get the Jexer images support flag.- Returns:
- true if this terminal is emitting Jexer images
-
-