Package jexer
Class TTerminal
- java.lang.Object
-
- jexer.TWidget
-
- jexer.TScrollable
-
- jexer.TTerminal
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>,EditMenuUser,Scrollable,TerminalListener
public class TTerminal extends TScrollable implements TerminalListener, EditMenuUser
TTerminal exposes a ECMA-48 / ANSI X3.64 style terminal in a widget.
-
-
Field Summary
-
Fields inherited from class jexer.TScrollable
hScroller, vScroller
-
-
Constructor Summary
Constructors Constructor Description TTerminal(TWidget parent, int x, int y)Public constructor spawns a shell.TTerminal(TWidget parent, int x, int y, int width, int height, java.lang.String[] command, TAction closeAction)Public constructor spawns a custom command line.TTerminal(TWidget parent, int x, int y, int width, int height, TAction closeAction)Public constructor spawns a shell.TTerminal(TWidget parent, int x, int y, java.lang.String commandLine)Public constructor spawns a custom command line.TTerminal(TWidget parent, int x, int y, java.lang.String[] command)Public constructor spawns a custom command line.TTerminal(TWidget parent, int x, int y, java.lang.String[] command, TAction closeAction)Public constructor spawns a custom command line.TTerminal(TWidget parent, int x, int y, TAction closeAction)Public constructor spawns a shell.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Handle widget close.voiddraw()Draw the display buffer.ClipboardgetClipboard()Get the system clipboard to use for OSC 52.java.lang.String[]getCommandLine()Get the full command line that spawned the shell.intgetDisplayHeight()Function to call to obtain the display height.intgetDisplayWidth()Function to call to obtain the display width.intgetExitValue()Get the exit value for the emulator.longgetPid()Get the PID of the child process.java.lang.StringgetTitle()Get the desired window title.booleanhasHiddenMouse()Returns true if this widget does not want the application-wide mouse cursor drawn over it.booleanisEditMenuClear()Check if the clear menu item should be enabled.booleanisEditMenuCopy()Check if the copy menu item should be enabled.booleanisEditMenuCut()Check if the cut menu item should be enabled.booleanisEditMenuPaste()Check if the paste menu item should be enabled.booleanisPixelMouse()Check if per-pixel mouse events are requested.booleanisReading()See if the terminal is still running.voidonCommand(TCommandEvent command)Handle posted command events.voidonFocus()Let the remote application know this terminal gained focus.voidonKeypress(TKeypressEvent keypress)Handle keystrokes.voidonMouseDown(TMouseEvent mouse)Handle mouse press events.voidonMouseMotion(TMouseEvent mouse)Handle mouse motion events.voidonMouseUp(TMouseEvent mouse)Handle mouse release events.voidonResize(TResizeEvent resize)Handle window/screen resize events.voidonShellExit()Hook for subclasses to be notified of the shell termination.voidonUnfocus()Let the remote application know this terminal lost focus.voidpostUpdate(TerminalState terminalState)Called by emulator when fresh data has come in.voidreflowData()Resize scrollbars for a new width/height.voidsignalShellChildProcess(int signal)Send a signal to the the child of the 'script' or 'ptypipe' process used on POSIX.voidsignalShellChildProcess(java.lang.String signal)Send a signal to the the child of the 'script' or 'ptypipe' process used on POSIX.booleanwaitForOutput(int millis)Wait for a period of time to get output from the launched process.voidwriteSessionAsHtml(java.io.Writer writer)Write the entire session (scrollback and display buffers) as colorized HTML to a writer.voidwriteSessionAsText(java.io.Writer writer)Write the entire session (scrollback and display buffers) as plain text to a writer.-
Methods inherited from class jexer.TScrollable
bigHorizontalDecrement, bigHorizontalIncrement, bigVerticalDecrement, bigVerticalIncrement, getBottomValue, getHorizontalBigChange, getHorizontalScroller, getHorizontalSmallChange, getHorizontalValue, getLeftValue, getRightValue, getTopValue, getVerticalBigChange, getVerticalScroller, getVerticalSmallChange, getVerticalValue, horizontalDecrement, horizontalIncrement, placeScrollbars, setBottomValue, setHorizontalBigChange, setHorizontalSmallChange, setHorizontalValue, setLeftValue, setRightValue, setTopValue, setVerticalBigChange, setVerticalSmallChange, setVerticalValue, toBottom, toEnd, toHome, toLeft, toRight, toTop, verticalDecrement, verticalIncrement
-
Methods inherited from class jexer.TWidget
activate, activate, activate, activateAll, addButton, addCalendar, addCheckBox, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addField, addImage, addImage, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addProgressBar, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, applyCellTransform, applyCellTransform, compareTo, doRepaint, drawBox, drawBoxShadow, drawChildren, drawForegroundBox, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getApplication, getAttrXY, getAttrXY, getChildren, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getCustomMousePointer, getHeight, getLayoutManager, getLocale, getMouseStyle, getParent, getScreen, getTheme, getWidgetUnderMouse, getWidth, getWindow, getX, getY, handleEvent, hasChild, hForegroundLineXY, hLineXY, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isVisible, messageBox, messageBox, mouseWouldHit, onIdle, onMenu, onMouseDoubleClick, putAll, putAttrXY, putAttrXY, putBackgroundAttrBox, putBackgroundAttrXY, putBackgroundAttrXY, putCharXY, putCharXY, putCharXY, putForegroundCharXY, putForegroundStringXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setCustomMousePointer, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setLocale, setMouseStyle, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, vLineXY, vLineXY
-
-
-
-
Constructor Detail
-
TTerminal
public TTerminal(TWidget parent, int x, int y, java.lang.String commandLine)
Public constructor spawns a custom command line.- Parameters:
parent- parent widgetx- column relative to parenty- row relative to parentcommandLine- the command line to execute
-
TTerminal
public TTerminal(TWidget parent, int x, int y, java.lang.String[] command)
Public constructor spawns a custom command line.- Parameters:
parent- parent widgetx- column relative to parenty- row relative to parentcommand- the command line to execute, as an array of strings which signifies the external program file to be invoked (command[0]) and its arguments, if any (command[1], command[2], ...). Refer also to java.lang.ProcessBuilder for further operating-system specific details.
-
TTerminal
public TTerminal(TWidget parent, int x, int y, java.lang.String[] command, TAction closeAction)
Public constructor spawns a custom command line.- Parameters:
parent- parent widgetx- column relative to parenty- row relative to parentcommand- the command line to execute, as an array of strings which signifies the external program file to be invoked (command[0]) and its arguments, if any (command[1], command[2], ...). Refer also to java.lang.ProcessBuilder for further operating-system specific details.closeAction- action to perform when the shell exits
-
TTerminal
public TTerminal(TWidget parent, int x, int y, int width, int height, java.lang.String[] command, TAction closeAction)
Public constructor spawns a custom command line.- Parameters:
parent- parent widgetx- column relative to parenty- row relative to parentwidth- width of widgetheight- height of widgetcommand- the command line to execute, as an array of strings which signifies the external program file to be invoked (command[0]) and its arguments, if any (command[1], command[2], ...). Refer also to java.lang.ProcessBuilder for further operating-system specific details.closeAction- action to perform when the shell exits
-
TTerminal
public TTerminal(TWidget parent, int x, int y)
Public constructor spawns a shell.- Parameters:
parent- parent widgetx- column relative to parenty- row relative to parent
-
TTerminal
public TTerminal(TWidget parent, int x, int y, TAction closeAction)
Public constructor spawns a shell.- Parameters:
parent- parent widgetx- column relative to parenty- row relative to parentcloseAction- action to perform when the shell exits
-
TTerminal
public TTerminal(TWidget parent, int x, int y, int width, int height, TAction closeAction)
Public constructor spawns a shell.- Parameters:
parent- parent widgetx- column relative to parenty- row relative to parentwidth- width of widgetheight- height of widgetcloseAction- action to perform when the shell exits
-
-
Method Detail
-
onResize
public void onResize(TResizeEvent resize)
Handle window/screen resize events.- Overrides:
onResizein classTScrollable- Parameters:
resize- resize event
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypressin classTWidget- Parameters:
keypress- keystroke event
-
onMouseDown
public void onMouseDown(TMouseEvent mouse)
Handle mouse press events.- Overrides:
onMouseDownin classTWidget- Parameters:
mouse- mouse button press event
-
onMouseUp
public void onMouseUp(TMouseEvent mouse)
Handle mouse release events.
-
onMouseMotion
public void onMouseMotion(TMouseEvent mouse)
Handle mouse motion events.- Overrides:
onMouseMotionin classTWidget- Parameters:
mouse- mouse motion event
-
onCommand
public void onCommand(TCommandEvent command)
Handle posted command events.
-
reflowData
public void reflowData()
Resize scrollbars for a new width/height.- Overrides:
reflowDatain classTScrollable
-
getTitle
public java.lang.String getTitle()
Get the desired window title.- Returns:
- the title
-
getCommandLine
public java.lang.String[] getCommandLine()
Get the full command line that spawned the shell.- Returns:
- the command line
-
hasHiddenMouse
public boolean hasHiddenMouse()
Returns true if this widget does not want the application-wide mouse cursor drawn over it.- Returns:
- true if this widget does not want the application-wide mouse cursor drawn over it
-
isPixelMouse
public boolean isPixelMouse()
Check if per-pixel mouse events are requested.- Overrides:
isPixelMousein classTWidget- Returns:
- true if per-pixel mouse events are requested
-
isReading
public boolean isReading()
See if the terminal is still running.- Returns:
- if true, we are still connected to / reading from the remote side
-
onFocus
public void onFocus()
Let the remote application know this terminal gained focus.
-
onUnfocus
public void onUnfocus()
Let the remote application know this terminal lost focus.
-
getPid
public long getPid()
Get the PID of the child process.- Returns:
- the pid, or -1 if it cannot be determined
-
signalShellChildProcess
public void signalShellChildProcess(int signal)
Send a signal to the the child of the 'script' or 'ptypipe' process used on POSIX. This may or may not work.- Parameters:
signal- the signal number
-
signalShellChildProcess
public void signalShellChildProcess(java.lang.String signal)
Send a signal to the the child of the 'script' or 'ptypipe' process used on POSIX. This may or may not work.- Parameters:
signal- the signal name
-
onShellExit
public void onShellExit()
Hook for subclasses to be notified of the shell termination.
-
waitForOutput
public boolean waitForOutput(int millis)
Wait for a period of time to get output from the launched process.- Parameters:
millis- millis to wait for, or 0 to wait forever- Returns:
- true if the launched process has emitted something
-
getExitValue
public int getExitValue()
Get the exit value for the emulator.- Returns:
- exit value
-
writeSessionAsText
public void writeSessionAsText(java.io.Writer writer) throws java.io.IOExceptionWrite the entire session (scrollback and display buffers) as plain text to a writer.- Parameters:
writer- the output writer- Throws:
java.io.IOException- of a java.io operation throws
-
writeSessionAsHtml
public void writeSessionAsHtml(java.io.Writer writer) throws java.io.IOExceptionWrite the entire session (scrollback and display buffers) as colorized HTML to a writer. This method does not write the HTML header/body tags.- Parameters:
writer- the output writer- Throws:
java.io.IOException- of a java.io operation throws
-
postUpdate
public void postUpdate(TerminalState terminalState)
Called by emulator when fresh data has come in.- Specified by:
postUpdatein interfaceTerminalListener- Parameters:
terminalState- the new terminal state
-
getDisplayWidth
public int getDisplayWidth()
Function to call to obtain the display width.- Specified by:
getDisplayWidthin interfaceTerminalListener- Returns:
- the number of columns in the display
-
getDisplayHeight
public int getDisplayHeight()
Function to call to obtain the display height.- Specified by:
getDisplayHeightin interfaceTerminalListener- Returns:
- the number of rows in the display
-
getClipboard
public Clipboard getClipboard()
Get the system clipboard to use for OSC 52.- Specified by:
getClipboardin interfaceTerminalListener- Overrides:
getClipboardin classTWidget- Returns:
- the clipboard
-
isEditMenuCut
public boolean isEditMenuCut()
Check if the cut menu item should be enabled.- Specified by:
isEditMenuCutin interfaceEditMenuUser- Returns:
- true if the cut menu item should be enabled
-
isEditMenuCopy
public boolean isEditMenuCopy()
Check if the copy menu item should be enabled.- Specified by:
isEditMenuCopyin interfaceEditMenuUser- Returns:
- true if the copy menu item should be enabled
-
isEditMenuPaste
public boolean isEditMenuPaste()
Check if the paste menu item should be enabled.- Specified by:
isEditMenuPastein interfaceEditMenuUser- Returns:
- true if the paste menu item should be enabled
-
isEditMenuClear
public boolean isEditMenuClear()
Check if the clear menu item should be enabled.- Specified by:
isEditMenuClearin interfaceEditMenuUser- Returns:
- true if the clear menu item should be enabled
-
-