com.mindbright.terminal
public final class TerminalWin extends java.awt.event.WindowAdapter implements TerminalWindow, java.awt.event.KeyListener
Modifier and Type | Field and Description |
---|---|
static int |
LEFT_BUTTON |
static int |
MIDDLE_BUTTON |
static int |
RIGHT_BUTTON |
static java.lang.String[] |
termColorNames
The names of the predefined colors
|
static java.awt.Color[] |
termColors
Predefined colors
|
static int |
UNKNOWN_BUTTON |
Constructor and Description |
---|
TerminalWin(java.awt.Container container,
java.util.Properties initProps,
boolean setAsDefault)
Create a new terminal window with the given properties.
|
TerminalWin(javax.swing.JFrame ownerFrame)
Create a new terminal window with the default values of all
properties.
|
TerminalWin(javax.swing.JFrame ownerFrame,
java.util.Properties initProps)
Create a new terminal window with the given properties.
|
TerminalWin(javax.swing.JFrame ownerFrame,
java.util.Properties initProps,
boolean setAsDefault)
Create a new terminal window with the given properties.
|
Modifier and Type | Method and Description |
---|---|
void |
addInputListener(TerminalInputListener inListener)
Add a input listener which listens to data from the user.
|
void |
addOutputListener(TerminalOutputListener outListener)
Add a output listener which listens to data from the server.
|
void |
attachPrinter(TerminalPrinter printer)
Attach a printer to this terminal.
|
void |
clearLine()
This shortcut method clears the current line.
|
void |
clearSaveLines()
Forgets any saved lines in the scrollback buffer.
|
void |
clearScreen()
This shortcut method clears the screen.
|
void |
clearSelection()
Removes the selection if there is one.
|
int |
cols()
Get the number of columns shown.
|
void |
detachPrinter()
Detach the previously attached printer.
|
void |
displayDragResize(int newRows,
int newCols)
Resize the terminal during a drag operation.
|
void |
displayResized(int newRows,
int newCols,
int vpixels,
int hpixels)
Called when the terminal window has been resized.
|
void |
doCopy()
Store a copy of the selection in the clipboard.
|
void |
doPaste()
Paset the contents of the clipboard.
|
TerminalClipboardHandler |
getClipboard()
Get the clipboard used.
|
java.lang.String |
getDefaultProperty(java.lang.String key)
Get the default value of the given property.
|
DisplayView |
getDisplay()
Return the current display view object which handles the actual
displaying of data in the terminal window.
|
java.awt.Image |
getLogo()
Get the logo image.
|
TerminalMenuHandler |
getMenus()
Return the menu handler which is responsible for the menus
attached to this terminal window.
|
TerminalOption[] |
getOptions()
Get the terminal options.
|
java.awt.Container |
getPanelWithScrollbar()
Return the panel containing the actual terminal window,
including the scrollbar.
|
java.util.Properties |
getProperties()
Get the current terminal properties
|
java.lang.String |
getProperty(java.lang.String key)
Get the value of a single property.
|
static java.lang.String[] |
getPropertyNames()
Get the name of all properties the terminal emulator cares
about.
|
boolean |
getPropsChanged()
Check if any properties have changed.
|
java.lang.String |
getSelection()
Get the current selection.
|
static java.awt.Color |
getTermColor(java.lang.String name)
Get a predefined terminal color.
|
static java.lang.String[] |
getTerminalTypes()
Get a list of terminal types this terminal can emulate.
|
static java.awt.Color |
getTermRGBColor(java.lang.String value)
Get a color as specified by an R,G,B tuple.
|
java.lang.String |
getTitle()
Get the title
|
void |
hideLogo()
Hide the logo, that is do not show it.
|
int |
hpixels()
Get the number of horizontal pixels used to represent the terminal.
|
static boolean |
isProperty(java.lang.String key)
Check if the passed property name is a valid property for this
terminal window.
|
void |
keyPressed(java.awt.event.KeyEvent e) |
void |
keyReleased(java.awt.event.KeyEvent e) |
void |
keyTyped(java.awt.event.KeyEvent e) |
void |
mouseClicked(int visTop,
int row,
int col,
int modifier,
int which)
Handle a mouse click event
|
void |
mouseDragged(int visTop,
int mouseRow,
int mouseCol,
int modifier,
int which,
int delta)
Handle a mouse dragged event
|
void |
mousePressed(int visTop,
int mouseRow,
int mouseCol,
int modifier,
int which,
int x,
int y)
Handle a mouse press event
|
void |
mouseReleased(int visTop,
int mouseRow,
int mouseCol,
int modifier,
int which)
Handle a mouse release event
|
void |
printScreen()
Dump the current screen to the attached printer.
|
void |
removeInputListener(TerminalInputListener inListener)
Removes a previously added input listener
|
void |
removeOutputListener(TerminalOutputListener outListener)
Removes a previously added output listener
|
void |
requestFocus()
Causes the terminal emulator to request the focus.
|
void |
reset()
Reset the terminal emulator to the default state.
|
void |
resetProperty(java.lang.String key)
Reset a property back to its default value.
|
void |
resetToDefaults()
Reset all properties to their default values.
|
void |
ringBell()
This shortcut method rings the terminal bell.
|
int |
rows()
Get the number of rows shown.
|
void |
scrollDown() |
void |
scrollUp() |
SearchContext |
search(SearchContext lastContext,
java.lang.String key,
boolean reverse,
boolean caseSens)
Search for a string in the terminal window
|
void |
selectAll()
Select all text
|
void |
sendBreak()
Send a break singal to the server.
|
void |
sendBytes(byte[] b)
May be called when the user pastes data.
|
void |
sendBytesDirect(byte[] b)
Send some bytes directly to the host.
|
void |
sendBytesInt(byte[] b,
boolean direct) |
void |
sendString(java.lang.String s)
Simulate key events, just send the specified charascters
|
void |
setAttributeBold(boolean set)
This shortcut menthod is used to enable/disable bold
characters.
|
void |
setClipboard(TerminalClipboardHandler clipboard)
Set the clipboard handler to use in this terminal window.
|
void |
setCursorPos(int row,
int col)
This shortcut method moves the cursor to the given position.
|
void |
setDumbMode(boolean dumb)
Enable/disable dumb mode.
|
void |
setFont(java.awt.Font font)
Set the font to use.
|
void |
setFont(java.lang.String name,
int size)
Set the font to use.
|
void |
setGeometry(java.lang.String geometry)
Set the geometry to use, The geometry is a string which looks
something like
80x24+23+42 which creates a window
which is 80 columns with 24 rows and which is placed at
x=23,y=24. |
void |
setIgnoreClose()
Set the frame to ignore window close events.
|
void |
setInputCharset(java.lang.String charset)
Set the charset used to input text.
|
void |
setLogo(java.awt.Image logoImg,
int x,
int y,
int w,
int h)
Set the logo to show on the login screen.
|
void |
setMenus(TerminalMenuHandler menus)
Set the menu handler
|
void |
setPopupButton(int buttonNum)
Set which mouse button should cause the popup menu to appear.
|
void |
setProperties(java.util.Properties newProps,
boolean merge)
Set a bunch of terminal properties
|
void |
setProperty(java.lang.String key,
java.lang.String value)
Set a single terminal property.
|
void |
setProperty(java.lang.String key,
java.lang.String value,
boolean forceSet)
Set a property.
|
void |
setPropsChanged(boolean value)
Change the properties changed flag.
|
void |
setTitle(java.lang.String title)
Set title of terminal window.
|
boolean |
showLogo()
Show the logo on the terminal.
|
void |
signalWindowChanged(int rows,
int cols,
int vpixels,
int hpixels)
Tell all our input listeners that the terminal size has changed.
|
void |
startPrinter()
Start dumping a log of everything which is printed on the
terminal to the attached printer.
|
void |
stopPrinter()
Stop printing.
|
java.lang.String |
terminalType()
Get the terminal type which the window currently emulates.
|
void |
typedChar(char c)
Called whn the user tpyes a character
|
void |
typedCharInt(byte[] b) |
void |
typedCharInt(char c) |
void |
updateMenus()
Called when the menus should be updated.
|
int |
vpixels()
Get the number of vertical pixels used to represent the terminal.
|
void |
windowClosed(java.awt.event.WindowEvent e)
This is notified when the window is closed and is used to tell
the display class to kill the repainter thread.
|
void |
write(byte b)
Write a byte to the terminal.
|
void |
write(byte[] c,
int off,
int len)
Write a bunch of bytes to the terminal.
|
void |
write(char c)
Write a character to the terminal.
|
void |
write(char[] c,
int off,
int len)
Write a bunch of characters to the terminal.
|
void |
write(java.lang.String s)
Write a string to the terminal.
|
public static final java.awt.Color[] termColors
public static final java.lang.String[] termColorNames
public static final int LEFT_BUTTON
public static final int MIDDLE_BUTTON
public static final int RIGHT_BUTTON
public static final int UNKNOWN_BUTTON
public TerminalWin(javax.swing.JFrame ownerFrame) throws java.lang.IllegalArgumentException, java.util.NoSuchElementException
ownerFrame
- frame used to get the content pane to usejava.lang.IllegalArgumentException
java.util.NoSuchElementException
public TerminalWin(javax.swing.JFrame ownerFrame, java.util.Properties initProps) throws java.lang.IllegalArgumentException
ownerFrame
- frame used to get the content pane to useinitProps
- initial propertiesjava.lang.IllegalArgumentException
public TerminalWin(javax.swing.JFrame ownerFrame, java.util.Properties initProps, boolean setAsDefault) throws java.lang.IllegalArgumentException
ownerFrame
- frame used to get the content pane to useinitProps
- initial propertiessetAsDefault
- mark these properties as default and use
them if no others are specified in the future.java.lang.IllegalArgumentException
public TerminalWin(java.awt.Container container, java.util.Properties initProps, boolean setAsDefault) throws java.lang.IllegalArgumentException
container
- content pane to put the terminal window ininitProps
- initial propertiessetAsDefault
- mark these properties as default and use
them if no others are specified in the future.java.lang.IllegalArgumentException
public static java.lang.String[] getTerminalTypes()
public void requestFocus()
public void setMenus(TerminalMenuHandler menus)
public TerminalMenuHandler getMenus()
public DisplayView getDisplay()
public void updateMenus()
public void setLogo(java.awt.Image logoImg, int x, int y, int w, int h)
logoImg
- the actual logox
- x position to show it aty
- y position to show it onw
- width of logo when shownh
- height of logo when shownpublic java.awt.Image getLogo()
public boolean showLogo()
public void hideLogo()
public void setProperties(java.util.Properties newProps, boolean merge) throws java.lang.IllegalArgumentException
TerminalWindow
setProperties
in interface TerminalWindow
newProps
- new propertiesmerge
- if true the new properties are merged with any
previous properties. If false all old properties are deleted.java.lang.IllegalArgumentException
public java.util.Properties getProperties()
TerminalWindow
getProperties
in interface TerminalWindow
public boolean getPropsChanged()
TerminalWindow
getPropsChanged
in interface TerminalWindow
public void setPropsChanged(boolean value)
TerminalWindow
setPropsChanged
in interface TerminalWindow
value
- new value.public static boolean isProperty(java.lang.String key)
key
- a property namepublic void resetToDefaults()
TerminalWindow
resetToDefaults
in interface TerminalWindow
public static java.lang.String[] getPropertyNames()
public java.lang.String getProperty(java.lang.String key)
TerminalWindow
getProperty
in interface TerminalWindow
key
- name of perty to get value ofpublic java.lang.String getDefaultProperty(java.lang.String key)
key
- name of peropertypublic void resetProperty(java.lang.String key)
key
- name of property to resetpublic void setProperty(java.lang.String key, java.lang.String value) throws java.lang.IllegalArgumentException, java.util.NoSuchElementException
TerminalWindow
setProperty
in interface TerminalWindow
key
- property to setvalue
- value to set it tojava.lang.IllegalArgumentException
java.util.NoSuchElementException
public TerminalOption[] getOptions()
TerminalWindow
getOptions
in interface TerminalWindow
public void setProperty(java.lang.String key, java.lang.String value, boolean forceSet) throws java.lang.IllegalArgumentException, java.util.NoSuchElementException
key
- name of propertyvalue
- value of propertyforceSet
- if true then the property os set event if the
key is not a valid terminal property namejava.lang.IllegalArgumentException
java.util.NoSuchElementException
public static java.awt.Color getTermRGBColor(java.lang.String value) throws java.lang.NumberFormatException
value
- a string with the R,G,B value of the form
0,0,0. Legal values for each element are 0-255.java.lang.NumberFormatException
public static java.awt.Color getTermColor(java.lang.String name) throws java.lang.IllegalArgumentException
name
- name of desired colorjava.lang.IllegalArgumentException
public void setGeometry(java.lang.String geometry) throws java.lang.IllegalArgumentException
80x24+23+42
which creates a window
which is 80 columns with 24 rows and which is placed at
x=23,y=24. It is also possible to just specify the size or the
position and any of the position values can be preceded by a minus
sign in which case it is countyed from the right/bottom edge
instead.geometry
- string representing the geometryjava.lang.IllegalArgumentException
public void setFont(java.lang.String name, int size)
name
- name of fontsize
- size of fontpublic void setFont(java.awt.Font font)
font
- font to usepublic void setTitle(java.lang.String title)
TerminalWindow
setTitle
in interface TerminalWindow
title
- the titlepublic java.lang.String getTitle()
TerminalWindow
getTitle
in interface TerminalWindow
public void setPopupButton(int buttonNum)
buttonNum
- button number. One of InputEvent.BUTTON1_MASK,
InputEvent.BUTTON2_MASK or InputEvent.BUTTON3_MASKpublic java.awt.Container getPanelWithScrollbar()
public void clearSaveLines()
public void setInputCharset(java.lang.String charset) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public java.lang.String terminalType()
TerminalWindow
terminalType
in interface TerminalWindow
public int rows()
TerminalWindow
rows
in interface TerminalWindow
public int cols()
TerminalWindow
cols
in interface TerminalWindow
public int vpixels()
TerminalWindow
vpixels
in interface TerminalWindow
public int hpixels()
TerminalWindow
hpixels
in interface TerminalWindow
public void write(byte b)
TerminalWindow
write
in interface TerminalWindow
b
- byte to writepublic void write(char c)
TerminalWindow
The character is assumed to be in the java internal encoding.
write
in interface TerminalWindow
c
- character to writepublic void write(char[] c, int off, int len)
TerminalWindow
The characters are assumed to be in the java internal encoding.
write
in interface TerminalWindow
c
- array containg the characters to writeoff
- index in array of first character to writelen
- number of characters to writepublic void write(byte[] c, int off, int len)
TerminalWindow
write
in interface TerminalWindow
c
- array containg the characters to writeoff
- index in array of first character to writelen
- number of characters to writepublic void write(java.lang.String s)
TerminalWindow
write
in interface TerminalWindow
s
- string to writepublic void addInputListener(TerminalInputListener inListener)
TerminalWindow
addInputListener
in interface TerminalWindow
inListener
- input listener to addpublic void removeInputListener(TerminalInputListener inListener)
TerminalWindow
removeInputListener
in interface TerminalWindow
inListener
- input listener to removepublic void addOutputListener(TerminalOutputListener outListener)
TerminalWindow
addOutputListener
in interface TerminalWindow
outListener
- output listener to addpublic void removeOutputListener(TerminalOutputListener outListener)
TerminalWindow
removeOutputListener
in interface TerminalWindow
outListener
- output listener to removepublic void attachPrinter(TerminalPrinter printer)
TerminalWindow
attachPrinter
in interface TerminalWindow
printer
- printer to attachpublic void detachPrinter()
TerminalWindow
detachPrinter
in interface TerminalWindow
public void setClipboard(TerminalClipboardHandler clipboard)
clipboard
- clipboard handler to usepublic TerminalClipboardHandler getClipboard()
public void typedChar(char c)
TerminalWindow
typedChar
in interface TerminalWindow
c
- typed characterpublic void typedCharInt(char c)
public void typedCharInt(byte[] b)
public final void sendBytes(byte[] b)
TerminalWindow
sendBytes
in interface TerminalWindow
b
- array of bytes representing characters to inputpublic final void sendBytesDirect(byte[] b)
TerminalWindow
sendBytesDirect
in interface TerminalWindow
b
- array of bytes representing characters to sendpublic final void sendBytesInt(byte[] b, boolean direct)
public final void sendBreak()
TerminalWindow
sendBreak
in interface TerminalWindow
public void signalWindowChanged(int rows, int cols, int vpixels, int hpixels)
rows
- new number of rowscols
- new number of columnsvpixels
- new number of vertical pixelshpixels
- new number of horizontal pixelspublic void reset()
TerminalWindow
reset
in interface TerminalWindow
public void printScreen()
TerminalWindow
printScreen
in interface TerminalWindow
public void startPrinter()
TerminalWindow
startPrinter
in interface TerminalWindow
public void stopPrinter()
TerminalWindow
stopPrinter
in interface TerminalWindow
public SearchContext search(SearchContext lastContext, java.lang.String key, boolean reverse, boolean caseSens)
TerminalWindow
search
in interface TerminalWindow
lastContext
- used as a starying point, if not null, so
tha the search may continue from the last positionkey
- string to search forreverse
- if true the search is performed backwardscaseSens
- if true the key is case sensitivenull
if the key was not found.public void displayDragResize(int newRows, int newCols)
newRows
- new number of rowsnewCols
- new number of columnspublic void displayResized(int newRows, int newCols, int vpixels, int hpixels)
newRows
- new number of rowsnewCols
- new number of columnsvpixels
- vertical pixeslhpixels
- horizontal pixeslpublic void selectAll()
public void clearSelection()
public java.lang.String getSelection()
public void doCopy()
public void doPaste()
public void setDumbMode(boolean dumb)
dumb
- true if dumb mode should be enabled.public void setIgnoreClose()
public void mouseClicked(int visTop, int row, int col, int modifier, int which)
visTop
- index of top visual linerow
- row of character the mouse was pointing atcol
- column of character the mouse was pointing atmodifier
- modifiers activepublic void mousePressed(int visTop, int mouseRow, int mouseCol, int modifier, int which, int x, int y)
visTop
- index of top visual linemouseRow
- row of character the mouse was pointing atmouseCol
- column of character the mouse was pointing atmodifier
- modifiers activex
- x coordinate of mousey
- y coordinate of mousepublic void mouseReleased(int visTop, int mouseRow, int mouseCol, int modifier, int which)
visTop
- index of top visual linemouseRow
- row of character the mouse was pointing atmouseCol
- column of character the mouse was pointing atmodifier
- modifiers activepublic void mouseDragged(int visTop, int mouseRow, int mouseCol, int modifier, int which, int delta)
visTop
- index of top visual linemouseRow
- row of character the mouse was pointing atmouseCol
- column of character the mouse was pointing atmodifier
- modifiers activepublic void scrollUp()
public void scrollDown()
public void sendString(java.lang.String s)
public void setAttributeBold(boolean set)
TerminalWindow
The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.
setAttributeBold
in interface TerminalWindow
set
- if true turn on bold for subsequent characters.public void clearScreen()
TerminalWindow
The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.
clearScreen
in interface TerminalWindow
public void ringBell()
TerminalWindow
The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.
ringBell
in interface TerminalWindow
public void setCursorPos(int row, int col)
TerminalWindow
The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.
setCursorPos
in interface TerminalWindow
row
- row to place cursor oncol
- column to place cursor onpublic void clearLine()
TerminalWindow
The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.
clearLine
in interface TerminalWindow
public void windowClosed(java.awt.event.WindowEvent e)
windowClosed
in interface java.awt.event.WindowListener
windowClosed
in class java.awt.event.WindowAdapter
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener