Package jexer
Class TTerminalWidget
- java.lang.Object
-
- jexer.TWidget
-
- jexer.TScrollableWidget
-
- jexer.TTerminalWidget
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>,EditMenuUser,Scrollable,DisplayListener
public class TTerminalWidget extends TScrollableWidget implements DisplayListener, EditMenuUser
TTerminalWidget exposes a ECMA-48 / ANSI X3.64 style terminal in a widget.
-
-
Field Summary
-
Fields inherited from class jexer.TScrollableWidget
hScroller, vScroller
-
-
Constructor Summary
Constructors Constructor Description TTerminalWidget(TWidget parent, int x, int y)Public constructor spawns a shell.TTerminalWidget(TWidget parent, int x, int y, int width, int height, java.lang.String[] command, TAction closeAction)Public constructor spawns a custom command line.TTerminalWidget(TWidget parent, int x, int y, int width, int height, TAction closeAction)Public constructor spawns a shell.TTerminalWidget(TWidget parent, int x, int y, java.lang.String commandLine)Public constructor spawns a custom command line.TTerminalWidget(TWidget parent, int x, int y, java.lang.String[] command)Public constructor spawns a custom command line.TTerminalWidget(TWidget parent, int x, int y, java.lang.String[] command, TAction closeAction)Public constructor spawns a custom command line.TTerminalWidget(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 voidbigVerticalDecrement()Perform a big step change up.voidbigVerticalIncrement()Perform a big step change down.voidclose()Handle widget close.voiddisplayChanged(boolean cursorOnly)Called by emulator when fresh data has come in.voiddraw()Draw the display buffer.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.intgetScrollBottom()Function to call to obtain the number of rows from the bottom to scroll back when sending updates via updateDisplay().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.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.voidreflowData()Resize scrollbars for a new width/height.voidsetVerticalValue(int value)Set current value of the vertical scroll.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.voidtoBottom()Go to the bottom edge of the vertical scroller.voidtoTop()Go to the top edge of the vertical scroller.voidupdateDisplay(java.util.List<DisplayLine> display)Called by emulator when fresh data has come in (push).voidverticalDecrement()Perform a small step change up.voidverticalIncrement()Perform a small step change down.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.TScrollableWidget
bigHorizontalDecrement, bigHorizontalIncrement, getBottomValue, getHorizontalBigChange, getHorizontalScroller, getHorizontalSmallChange, getHorizontalValue, getLeftValue, getRightValue, getTopValue, getVerticalBigChange, getVerticalScroller, getVerticalSmallChange, getVerticalValue, horizontalDecrement, horizontalIncrement, placeScrollbars, setBottomValue, setHorizontalBigChange, setHorizontalSmallChange, setHorizontalValue, setLeftValue, setRightValue, setTopValue, setVerticalBigChange, setVerticalSmallChange, toEnd, toHome, toLeft, toRight
-
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, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getApplication, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getCustomMousePointer, getHeight, getLayoutManager, getLocale, getMouseStyle, getParent, getScreen, getTheme, getWidgetUnderMouse, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isVisible, messageBox, messageBox, mouseWouldHit, onIdle, onMenu, onMouseDoubleClick, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, 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
-
TTerminalWidget
public TTerminalWidget(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
-
TTerminalWidget
public TTerminalWidget(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.
-
TTerminalWidget
public TTerminalWidget(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
-
TTerminalWidget
public TTerminalWidget(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
-
TTerminalWidget
public TTerminalWidget(TWidget parent, int x, int y)
Public constructor spawns a shell.- Parameters:
parent- parent widgetx- column relative to parenty- row relative to parent
-
TTerminalWidget
public TTerminalWidget(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
-
TTerminalWidget
public TTerminalWidget(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 classTScrollableWidget- 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.
-
setVerticalValue
public void setVerticalValue(int value)
Set current value of the vertical scroll.- Specified by:
setVerticalValuein interfaceScrollable- Overrides:
setVerticalValuein classTScrollableWidget- Parameters:
value- the new scroll value
-
verticalDecrement
public void verticalDecrement()
Perform a small step change up.- Specified by:
verticalDecrementin interfaceScrollable- Overrides:
verticalDecrementin classTScrollableWidget
-
verticalIncrement
public void verticalIncrement()
Perform a small step change down.- Specified by:
verticalIncrementin interfaceScrollable- Overrides:
verticalIncrementin classTScrollableWidget
-
bigVerticalDecrement
public void bigVerticalDecrement()
Perform a big step change up.- Specified by:
bigVerticalDecrementin interfaceScrollable- Overrides:
bigVerticalDecrementin classTScrollableWidget
-
bigVerticalIncrement
public void bigVerticalIncrement()
Perform a big step change down.- Specified by:
bigVerticalIncrementin interfaceScrollable- Overrides:
bigVerticalIncrementin classTScrollableWidget
-
toTop
public void toTop()
Go to the top edge of the vertical scroller.- Specified by:
toTopin interfaceScrollable- Overrides:
toTopin classTScrollableWidget
-
toBottom
public void toBottom()
Go to the bottom edge of the vertical scroller.- Specified by:
toBottomin interfaceScrollable- Overrides:
toBottomin classTScrollableWidget
-
reflowData
public void reflowData()
Resize scrollbars for a new width/height.- Overrides:
reflowDatain classTScrollableWidget
-
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
-
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
-
updateDisplay
public void updateDisplay(java.util.List<DisplayLine> display)
Called by emulator when fresh data has come in (push).- Specified by:
updateDisplayin interfaceDisplayListener- Parameters:
display- the updated display
-
displayChanged
public void displayChanged(boolean cursorOnly)
Called by emulator when fresh data has come in.- Specified by:
displayChangedin interfaceDisplayListener- Parameters:
cursorOnly- if true, the screen has not changed but the cursor may be on a different location.
-
getScrollBottom
public int getScrollBottom()
Function to call to obtain the number of rows from the bottom to scroll back when sending updates via updateDisplay().- Specified by:
getScrollBottomin interfaceDisplayListener- Returns:
- the number of rows from the bottom to scroll back
-
getDisplayWidth
public int getDisplayWidth()
Function to call to obtain the display width.- Specified by:
getDisplayWidthin interfaceDisplayListener- Returns:
- the number of columns in the display
-
getDisplayHeight
public int getDisplayHeight()
Function to call to obtain the display height.- Specified by:
getDisplayHeightin interfaceDisplayListener- Returns:
- the number of rows in the display
-
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
-
-