Package com.iizigo.term.internal
Class Terminal
- java.lang.Object
- com.iizigo.term.internal.Terminal
- All Implemented Interfaces:
TerminalWindowListener
public class Terminal extends java.lang.Object implements TerminalWindowListener
The Terminal class displays the window of the emulator. All keystrokes are sent to the host and all changes of the screen is mapped back into the terminal window.
Constructor Summary
Constructors Constructor Description Terminal(EditorActiveTerminalSession session, HostSessionProps props)
Constructor for a remote session to a server.Terminal(HostSession hostSession, EditorTerminalProps terminalProps)
Creates a new terminal session for a local connection inside the Designer.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(ITerminalListener listener)
Adds a terminal listener.void
clear()
Clears the entire screen.void
createTerminal(org.eclipse.swt.widgets.Canvas canvas, TerminalStatusBar statusBar, IScreenDesigner designer)
Creates an instance of the terminal window.void
dispose()
Disposes of the instance.int[]
getAttributes()
Gets the attributes for direct manipulation of underlines.int
getCursorX()
Gets the cursor X.int
getCursorY()
Gets the cursor X.HostSession
getHostSession()
Gets the HostSession.boolean
getInsertMode()
Gets the insert mode.org.eclipse.swt.graphics.Rectangle[]
getMarks()
Gets the rectangle presently marked.TerminalSettings
getSettings()
Gets the Settings container.TerminalWindow
getTerminalWindow()
Gets the AWT TerminalWindow container.boolean
hasMark()
Checks if a rectangle is presently marked.boolean
inInsertMode()
The insert mode can be read using this method.boolean
isDisconnected()
Checks if disconnected, used e.g.boolean
isLocked()
Checks if the terminal session is locked.boolean
isMarkAllowed()
Checks if marking is allowed, i.e.boolean
onActivateMenu(boolean isPopup)
Handles display of the pop-up window or activation of the menu bar.void
onMarkChange()
Called when the mark changes.boolean
onPopup(int x, int y)
Handles display of the pop-up window.void
removeListener(ITerminalListener listener)
Removes a terminal listener.void
removeMarks()
Removes the rectangle mark.void
selectAll()
Selects all in terminal window.void
sendCharacter(char ch)
Sends a character string to the terminal.void
sendHostKey(int key)
Sends a host key to the host.void
sendKey(HostKeyEvent e)
Sends a key to the terminal.boolean
setCursor(int x, int y)
Sets the cursor position to X/Y.void
soundAlarm(boolean isHostAlarm)
Sounds the Alarm.void
switchProperties(HostSession hostSession, EditorTerminalProps terminalProps)
Switches properties.void
updateCursor(int x, int y)
The cursor position has changed from Local terminal.void
updateScreenData(int begin, int end)
The screen has changed between two points in a wrapping fashion.void
updateScreenSize()
Sets the screen size from Local terminal.
Constructor Detail
Terminal
public Terminal(EditorActiveTerminalSession session, HostSessionProps props)
Constructor for a remote session to a server.
Terminal
public Terminal(HostSession hostSession, EditorTerminalProps terminalProps)
Creates a new terminal session for a local connection inside the Designer.
Method Detail
addListener
public void addListener(ITerminalListener listener)
Adds a terminal listener.
removeListener
public void removeListener(ITerminalListener listener)
Removes a terminal listener.
switchProperties
public void switchProperties(HostSession hostSession, EditorTerminalProps terminalProps)
Switches properties.
getHostSession
public HostSession getHostSession()
Gets the HostSession.
getSettings
public TerminalSettings getSettings()
Gets the Settings container.
createTerminal
public void createTerminal(org.eclipse.swt.widgets.Canvas canvas, TerminalStatusBar statusBar, IScreenDesigner designer)
Creates an instance of the terminal window.
onActivateMenu
public boolean onActivateMenu(boolean isPopup)
Handles display of the pop-up window or activation of the menu bar.- Specified by:
onActivateMenu
in interfaceTerminalWindowListener
- Parameters:
isPopup
- Flag indicating it's a pop-up that should be activated, as opposed to the menu bar.- Returns:
- true if handled (i.e. menu is displayed).
onPopup
public boolean onPopup(int x, int y)
Handles display of the pop-up window.- Specified by:
onPopup
in interfaceTerminalWindowListener
- Parameters:
x
- The mouse position in X relative the terminal container.y
- The mouse position in Y relative the terminal container.- Returns:
- true if handled (i.e. menu is displayed).
clear
public void clear()
Clears the entire screen.
sendKey
public void sendKey(HostKeyEvent e)
Sends a key to the terminal.- Specified by:
sendKey
in interfaceTerminalWindowListener
- Parameters:
e
- The Host Key Event.
sendHostKey
public void sendHostKey(int key)
Sends a host key to the host. This method is only called from the "block mode" terminal emulation (HScreen, HField's or "this"), and doesn't take keyboard type-ahead into account.- Specified by:
sendHostKey
in interfaceTerminalWindowListener
- Parameters:
key
- The key to send.
sendCharacter
public void sendCharacter(char ch)
Sends a character string to the terminal.- Specified by:
sendCharacter
in interfaceTerminalWindowListener
- Parameters:
ch
- The character to send.
setCursor
public boolean setCursor(int x, int y)
Sets the cursor position to X/Y.- Specified by:
setCursor
in interfaceTerminalWindowListener
- Parameters:
x
- The X position.y
- The Y position.- Returns:
- false for failure (or not supported).
isLocked
public boolean isLocked()
Checks if the terminal session is locked.- Specified by:
isLocked
in interfaceTerminalWindowListener
- Returns:
- true if locked.
inInsertMode
public boolean inInsertMode()
The insert mode can be read using this method.- Specified by:
inInsertMode
in interfaceTerminalWindowListener
- Returns:
- true if insert mode, false = overwrite.
soundAlarm
public void soundAlarm(boolean isHostAlarm)
Sounds the Alarm.
updateScreenData
public void updateScreenData(int begin, int end)
The screen has changed between two points in a wrapping fashion.- Parameters:
begin
- The beginning position.end
- The end position (inclusive).
updateScreenSize
public void updateScreenSize()
Sets the screen size from Local terminal.
updateCursor
public void updateCursor(int x, int y)
The cursor position has changed from Local terminal.
dispose
public void dispose()
Disposes of the instance.
hasMark
public boolean hasMark()
Checks if a rectangle is presently marked.
getMarks
public org.eclipse.swt.graphics.Rectangle[] getMarks()
Gets the rectangle presently marked.
removeMarks
public void removeMarks()
Removes the rectangle mark.
isDisconnected
public boolean isDisconnected()
Checks if disconnected, used e.g. to paint the cursor.- Specified by:
isDisconnected
in interfaceTerminalWindowListener
- Returns:
- true if disconnected.
selectAll
public void selectAll()
Selects all in terminal window.
onMarkChange
public void onMarkChange()
Called when the mark changes.- Specified by:
onMarkChange
in interfaceTerminalWindowListener
getTerminalWindow
public TerminalWindow getTerminalWindow()
Gets the AWT TerminalWindow container.
isMarkAllowed
public boolean isMarkAllowed()
Checks if marking is allowed, i.e. connected.- Specified by:
isMarkAllowed
in interfaceTerminalWindowListener
- Returns:
- Mark allowed.
getCursorX
public int getCursorX()
Gets the cursor X.
getCursorY
public int getCursorY()
Gets the cursor X.
getInsertMode
public boolean getInsertMode()
Gets the insert mode.
getAttributes
public int[] getAttributes()
Gets the attributes for direct manipulation of underlines.