Package com.iizix.term
Class HostScreen
- java.lang.Object
- com.iizix.term.HostScreen
public class HostScreen extends java.lang.Object
This class does everything required for a host screen.- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description static int
ATTR_BLINK
Blink attribute.static int
ATTR_BOLD
Bold attribute.static int
ATTR_UNDERLINE
Underline attribute.
Constructor Summary
Constructors Constructor Description HostScreen()
Creates a new screen of size 80 x 24.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(HostScreenListener newListener)
Add an additional ownervoid
analyzePopupWindows()
Analyzes the host pop-up windows.void
append(SendTransaction trans, boolean doFields, boolean doPopupWindows)
Appends the host fields and possibly the pop-up windows.void
appendScreen(SendTransaction t)
Adds the entire host screen definition in a transaction that will cause the client to display a new terminal window.void
clear()
Clears the entire screen.int[]
getAttributes()
Gets the attribute data for the screen.char
getCharAbsolute(int pos)
Gets a character from a position.char
getCharAbsolute(int xx, int yy)
Gets a character from a X/Y position.char[]
getCharacters()
Gets the character data for the screen.int
getColorAbsolute(int pos)
Gets a CGA color from a position.int
getColorAbsolute(int xx, int yy)
Gets a CGA color from a position.int
getColorRelative(int xx, int yy)
Gets the CGA color from a relative position.Rect
getCurrentPopupWindow()
Gets the current host pop-up window.int
getCurrentPopupWindowIndex()
Gets the current index of the pop-up window.int
getCurrentPopupWindowXOffset()
Gets the current offset in X for a pop-up window.int
getCurrentPopupWindowYOffset()
Gets the current offset in Y for a pop-up window.Position
getCursorAbsolute()
Gets the current absolute cursor position on the screen, without taking into account any current host pop-up window.Position
getCursorRelative()
Gets the current relative cursor position on the screen, taking into account any current host pop-up window.HostField
getFieldAbsolute(int pos)
Gets a host field from a position.HostField
getFieldAbsolute(int x, int y)
Gets the host field from a X/Y position.HostField
getFieldRelative(int x, int y)
Gets the host field from a X/Y position relative to the current pop-up window.HostFields
getFields()
Gets all the host fields.HostField
getFirstFieldAbsolute(int pos)
Gets the first host field from a position.HostField
getFirstFieldAbsolute(int x, int y)
Gets the first host field from a X/Y position.HostField
getFirstFieldRelative(int x, int y)
Gets the first host field from a X/Y position.int
getHeight()
Gets the height of the screen.java.lang.String
getHiddenStringAbsolute(int xx, int yy, int length)
Gets a text string from host at an absolute position on the screen.java.lang.String
getHiddenStringRelative(int xx, int yy, int length)
Gets a text string from host at a relative position.int
getLengthExclusive(int beginPos, int endPos)
Calculates the length between two positions with support for screen wrapping.int
getLengthExclusive(int xBegin, int yBegin, int xEnd, int yEnd)
Calculates the length between two positions with support for screen wrapping.int
getLengthInclusive(int beginPos, int endPos)
Calculates the length between two positions with support for screen wrapping.int
getLengthInclusive(int xBegin, int yBegin, int xEnd, int yEnd)
Calculates the length between two positions with support for screen wrapping.java.lang.Object
getLockObject()
The lock object to synchronize on when processing e.g.Rect
getPopupWindow(int index)
Gets the pop-up window at an index.int
getPopupWindowCount()
Checks how many pop-up windows exist.Rect[]
getPopupWindows()
Gets the pop-up windows.int
getPosition(int x, int y)
Gets the position.java.lang.String
getScreenChars()
Gets the entire screen, blanking out hidden characters and replacing box drawing characters (to +-|) and null (to space).java.lang.String
getStringAbsolute(int xx, int yy, int length)
Gets a text string from host at an absolute position on the screen.java.lang.String
getStringAbsolute(int xx, int yy, int length, boolean doGetHidden)
Gets a text string from host at an absolute position on the screen.java.lang.String
getStringRelative(int xx, int yy, int length)
Gets a text string from host at a relative position.java.lang.String
getStringRelative(int xx, int yy, int length, boolean doGetHidden)
Gets a text string from host at a relative position.int
getWidth()
Gets the width of the screen.void
initialize(ReadTransaction trans)
Initializes the host fields and/or the pop-up windows from a transaction.boolean
isEmpty()
Checks if all characters on the screen (except the last line) are spaces.boolean
isFieldFormatted()
Checks if this host screen is field formatted.char
mapBoxChar(char ch, int pos)
Routine to map special Unicode box drawing characters to printable Ansi "+-|" characters.void
onHostScreenChange(HostSession hostSession, int beginPos, int endPos)
Gets new character and attribute data from the host session.void
removeListener(HostScreenListener oldListener)
Remove the additional ownervoid
setCurrentPopupWindow(int index)
Sets the current pop-up window.void
setCursor(int x, int y)
Changes cursor position.void
setSize(int cx, int cy)
Sets the current screen size.
Field Detail
ATTR_BOLD
public static final int ATTR_BOLD
Bold attribute.- See Also:
- Constant Field Values
ATTR_BLINK
public static final int ATTR_BLINK
Blink attribute.- See Also:
- Constant Field Values
ATTR_UNDERLINE
public static final int ATTR_UNDERLINE
Underline attribute.- See Also:
- Constant Field Values
Method Detail
getLockObject
public java.lang.Object getLockObject()
The lock object to synchronize on when processing e.g. screen identifications, used when the host session will update the screen in blocks in a separate thread.
addListener
public void addListener(HostScreenListener newListener)
Add an additional owner- Parameters:
newListener
- The listener.
removeListener
public void removeListener(HostScreenListener oldListener)
Remove the additional owner- Parameters:
oldListener
- The listener.
clear
public void clear()
Clears the entire screen.
analyzePopupWindows
public void analyzePopupWindows()
Analyzes the host pop-up windows.
getPopupWindowCount
public int getPopupWindowCount()
Checks how many pop-up windows exist.
getPopupWindows
public Rect[] getPopupWindows()
Gets the pop-up windows. Do not modify the rectangles returned!
getPopupWindow
public Rect getPopupWindow(int index)
Gets the pop-up window at an index.- Returns:
- null if index is out of range.
getCurrentPopupWindowXOffset
public int getCurrentPopupWindowXOffset()
Gets the current offset in X for a pop-up window.
getCurrentPopupWindowYOffset
public int getCurrentPopupWindowYOffset()
Gets the current offset in Y for a pop-up window.
getCurrentPopupWindow
public Rect getCurrentPopupWindow()
Gets the current host pop-up window.- Returns:
- null if none exists or none has been set.
getCurrentPopupWindowIndex
public int getCurrentPopupWindowIndex()
Gets the current index of the pop-up window.- Returns:
- The index, or -1 for none.
setCurrentPopupWindow
public void setCurrentPopupWindow(int index)
Sets the current pop-up window.
append
public void append(SendTransaction trans, boolean doFields, boolean doPopupWindows)
Appends the host fields and possibly the pop-up windows.
initialize
public void initialize(ReadTransaction trans)
Initializes the host fields and/or the pop-up windows from a transaction.- Parameters:
trans
- The transaction with the information.
setSize
public void setSize(int cx, int cy)
Sets the current screen size.
setCursor
public void setCursor(int x, int y)
Changes cursor position.
onHostScreenChange
public void onHostScreenChange(HostSession hostSession, int beginPos, int endPos)
Gets new character and attribute data from the host session.
getCharacters
public char[] getCharacters()
Gets the character data for the screen. This is mainly used by the screen identification process in order to be quicker.Note: While using the returned data, the host screen *must* be synchronized.
getAttributes
public int[] getAttributes()
Gets the attribute data for the screen. This is mainly used by the server-to-client routines to dispatch changes of screens to several listening parties.Note: While using the returned data, the host screen *must* be synchronized.
getWidth
public int getWidth()
Gets the width of the screen.
getHeight
public int getHeight()
Gets the height of the screen.
getFields
public HostFields getFields()
Gets all the host fields.
isFieldFormatted
public boolean isFieldFormatted()
Checks if this host screen is field formatted. This method is not like the one in HostSession, this one checks for presence of HostFields that the ClientSession has read from the HostSession when the worker thread has queued a host event. Use the HostSession method directly to see if any fields are present.
getFieldAbsolute
public HostField getFieldAbsolute(int pos)
Gets a host field from a position.- Returns:
- null if no host field exists in the position.
getFieldAbsolute
public HostField getFieldAbsolute(int x, int y)
Gets the host field from a X/Y position.- Returns:
- null if no host field exists in the position.
getFieldRelative
public HostField getFieldRelative(int x, int y)
Gets the host field from a X/Y position relative to the current pop-up window.- Returns:
- null if no host field exists in the position.
getFirstFieldAbsolute
public HostField getFirstFieldAbsolute(int pos)
Gets the first host field from a position.- Returns:
- null if no host field exists in the position.
getFirstFieldAbsolute
public HostField getFirstFieldAbsolute(int x, int y)
Gets the first host field from a X/Y position.- Returns:
- null if no host field exists in the position.
getFirstFieldRelative
public HostField getFirstFieldRelative(int x, int y)
Gets the first host field from a X/Y position.- Returns:
- null if no host field exists in the position.
getCharAbsolute
public char getCharAbsolute(int pos)
Gets a character from a position.
getCharAbsolute
public char getCharAbsolute(int xx, int yy)
Gets a character from a X/Y position.
getColorAbsolute
public int getColorAbsolute(int pos)
Gets a CGA color from a position.
getColorAbsolute
public int getColorAbsolute(int xx, int yy)
Gets a CGA color from a position.
getColorRelative
public int getColorRelative(int xx, int yy)
Gets the CGA color from a relative position.
getStringAbsolute
public java.lang.String getStringAbsolute(int xx, int yy, int length)
Gets a text string from host at an absolute position on the screen. No provision for host pop-up windows are made. The string returns blanks for hidden characters.
getStringAbsolute
public java.lang.String getStringAbsolute(int xx, int yy, int length, boolean doGetHidden)
Gets a text string from host at an absolute position on the screen. No provision for host pop-up windows are made. The string returns blanks for hidden characters depending on the flag.
getHiddenStringAbsolute
public java.lang.String getHiddenStringAbsolute(int xx, int yy, int length)
Gets a text string from host at an absolute position on the screen. No provision for host pop-up windows are made.
getStringRelative
public java.lang.String getStringRelative(int xx, int yy, int length)
Gets a text string from host at a relative position. This position is relative to the current host pop-up window offset. The string returns blanks for hidden characters.
getStringRelative
public java.lang.String getStringRelative(int xx, int yy, int length, boolean doGetHidden)
Gets a text string from host at a relative position. This position is relative to the current host pop-up window offset. The string returns blanks for hidden characters.
getHiddenStringRelative
public java.lang.String getHiddenStringRelative(int xx, int yy, int length)
Gets a text string from host at a relative position. This position is relative to the current host pop-up window offset. The string returns blanks for hidden characters.
isEmpty
public boolean isEmpty()
Checks if all characters on the screen (except the last line) are spaces. This is useful during connect to a host session in order to inhibit all panel processing until the connection is done and has a non-empty screen.
getCursorAbsolute
public Position getCursorAbsolute()
Gets the current absolute cursor position on the screen, without taking into account any current host pop-up window.
getCursorRelative
public Position getCursorRelative()
Gets the current relative cursor position on the screen, taking into account any current host pop-up window. If no host pop-up window exists, the cursor position will be the same as the absolute cursor position.
appendScreen
public void appendScreen(SendTransaction t)
Adds the entire host screen definition in a transaction that will cause the client to display a new terminal window.
mapBoxChar
public char mapBoxChar(char ch, int pos)
Routine to map special Unicode box drawing characters to printable Ansi "+-|" characters.
getScreenChars
public java.lang.String getScreenChars()
Gets the entire screen, blanking out hidden characters and replacing box drawing characters (to +-|) and null (to space).
getLengthExclusive
public int getLengthExclusive(int xBegin, int yBegin, int xEnd, int yEnd)
Calculates the length between two positions with support for screen wrapping. The positions are excluding the ending position.
getLengthExclusive
public int getLengthExclusive(int beginPos, int endPos)
Calculates the length between two positions with support for screen wrapping. The positions are excluding the ending position.
getLengthInclusive
public int getLengthInclusive(int xBegin, int yBegin, int xEnd, int yEnd)
Calculates the length between two positions with support for screen wrapping. The positions are excluding the ending position.
getLengthInclusive
public int getLengthInclusive(int beginPos, int endPos)
Calculates the length between two positions with support for screen wrapping. The positions are including the ending position.
getPosition
public int getPosition(int x, int y)
Gets the position.