com.mindbright.terminal
Interface TerminalWindow

All Known Implementing Classes:
TerminalWin

public interface TerminalWindow

Core interface for a terminal window. This is implemented by the actual implementation of the terminal window.


Method Summary
 void addAsEntropyGenerator(RandomSeed seed)
          Casuses this terminal window to send events to the specified random seed in order to extract entropy from them
 void addInputListener(TerminalInputListener listener)
          Add a input listener which listens to data from the user.
 void addOutputListener(TerminalOutputListener listener)
          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 clearScreen()
          This shortcut method clears the screen.
 int cols()
          Get the number of columns shown.
 void detachPrinter()
          Detach the previously attached printer.
 TerminalOption[] getOptions()
          Get the terminal options.
 java.util.Properties getProperties()
          Get the current terminal properties
 java.lang.String getProperty(java.lang.String key)
          Get the value of a single property.
 boolean getPropsChanged()
          Check if any properties have changed.
 java.lang.String getTitle()
          Get the title
 int hpixels()
          Get the number of horizontal pixels used to represent the terminal.
 void printScreen()
          Dump the current screen to the attached printer.
 void removeInputListener(TerminalInputListener listener)
          Removes a previously added input listener
 void removeOutputListener(TerminalOutputListener listener)
          Removes a previously added output listener
 void reset()
          Reset the terminal emulator to the default state.
 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.
 SearchContext search(SearchContext lastContext, java.lang.String key, boolean reverse, boolean caseSens)
          Search for a string in the terminal window
 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 setAttributeBold(boolean set)
          This shortcut menthod is used to enable/disable bold characters.
 void setCursorPos(int row, int col)
          This shortcut method moves the cursor to the given position.
 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 setPropsChanged(boolean value)
          Change the properties changed flag.
 void setTitle(java.lang.String title)
          Set title of terminal window.
 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
 int vpixels()
          Get the number of vertical pixels used to represent the terminal.
 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 str)
          Write a string to the terminal.
 

Method Detail

setTitle

void setTitle(java.lang.String title)
Set title of terminal window.

Parameters:
title - the title

getTitle

java.lang.String getTitle()
Get the title

Returns:
the title of the terminal window

rows

int rows()
Get the number of rows shown.

Returns:
the number of rows

cols

int cols()
Get the number of columns shown.

Returns:
the number of columns

vpixels

int vpixels()
Get the number of vertical pixels used to represent the terminal.

Returns:
the number of vertical pixels

hpixels

int hpixels()
Get the number of horizontal pixels used to represent the terminal.

Returns:
the number of horizontal pixels

write

void write(byte b)
Write a byte to the terminal. The byte will be assumed to be in the current remote encoding.

Parameters:
b - byte to write

write

void write(char c)
Write a character to the terminal.

The character is assumed to be in the java internal encoding.

Parameters:
c - character to write

write

void write(char[] c,
           int off,
           int len)
Write a bunch of characters to the terminal.

The characters are assumed to be in the java internal encoding.

Parameters:
c - array containg the characters to write
off - index in array of first character to write
len - number of characters to write

write

void write(byte[] c,
           int off,
           int len)
Write a bunch of bytes to the terminal. The bytes will be assumed to be in the current remote encoding.

Parameters:
c - array containg the characters to write
off - index in array of first character to write
len - number of characters to write

write

void write(java.lang.String str)
Write a string to the terminal. The string is assumed to be in the java internal encoding.

Parameters:
str - string to write

addInputListener

void addInputListener(TerminalInputListener listener)
Add a input listener which listens to data from the user.

Parameters:
listener - input listener to add

removeInputListener

void removeInputListener(TerminalInputListener listener)
Removes a previously added input listener

Parameters:
listener - input listener to remove

addOutputListener

void addOutputListener(TerminalOutputListener listener)
Add a output listener which listens to data from the server.

Parameters:
listener - output listener to add

removeOutputListener

void removeOutputListener(TerminalOutputListener listener)
Removes a previously added output listener

Parameters:
listener - output listener to remove

attachPrinter

void attachPrinter(TerminalPrinter printer)
Attach a printer to this terminal.

Parameters:
printer - printer to attach

detachPrinter

void detachPrinter()
Detach the previously attached printer.


typedChar

void typedChar(char c)
Called whn the user tpyes a character

Parameters:
c - typed character

sendBytes

void sendBytes(byte[] b)
May be called when the user pastes data. It may also be called by some external entity whishing to simulate multiple key presses.

Parameters:
b - array of bytes representing characters to input

sendBytesDirect

void sendBytesDirect(byte[] b)
Send some bytes directly to the host. This does not echo the characters and bypasses any line buffering. This is typically used when replying to some query from the host.

Parameters:
b - array of bytes representing characters to send

sendBreak

void sendBreak()
Send a break singal to the server.


reset

void reset()
Reset the terminal emulator to the default state.


printScreen

void printScreen()
Dump the current screen to the attached printer.


startPrinter

void startPrinter()
Start dumping a log of everything which is printed on the terminal to the attached printer.


stopPrinter

void stopPrinter()
Stop printing.


terminalType

java.lang.String terminalType()
Get the terminal type which the window currently emulates.

Returns:
the name of the emulated terminal

setProperties

void setProperties(java.util.Properties newProps,
                   boolean merge)
                   throws java.lang.IllegalArgumentException,
                          java.util.NoSuchElementException
Set a bunch of terminal properties

Parameters:
newProps - new properties
merge - if true the new properties are merged with any previous properties. If false all old properties are deleted.
Throws:
java.lang.IllegalArgumentException
java.util.NoSuchElementException

setProperty

void setProperty(java.lang.String key,
                 java.lang.String value)
                 throws java.lang.IllegalArgumentException,
                        java.util.NoSuchElementException
Set a single terminal property.

Parameters:
key - property to set
value - value to set it to
Throws:
java.lang.IllegalArgumentException
java.util.NoSuchElementException

getProperties

java.util.Properties getProperties()
Get the current terminal properties

Returns:
the current properties

getProperty

java.lang.String getProperty(java.lang.String key)
Get the value of a single property.

Parameters:
key - name of perty to get value of
Returns:
the value of the property. Null if the peroperty is not defined and there is no default value.

resetToDefaults

void resetToDefaults()
Reset all properties to their default values.


getPropsChanged

boolean getPropsChanged()
Check if any properties have changed.

Returns:
true if any properties has changed

setPropsChanged

void setPropsChanged(boolean value)
Change the properties changed flag.

Parameters:
value - new value.

getOptions

TerminalOption[] getOptions()
Get the terminal options.


search

SearchContext search(SearchContext lastContext,
                     java.lang.String key,
                     boolean reverse,
                     boolean caseSens)
Search for a string in the terminal window

Parameters:
lastContext - used as a starying point, if not null, so tha the search may continue from the last position
key - string to search for
reverse - if true the search is performed backwards
caseSens - if true the key is case sensitive
Returns:
a search context which describes where the key was found or null if the key was not found.

addAsEntropyGenerator

void addAsEntropyGenerator(RandomSeed seed)
Casuses this terminal window to send events to the specified random seed in order to extract entropy from them

Parameters:
seed - the random seed to send entropy to

setAttributeBold

void setAttributeBold(boolean set)
This shortcut menthod is used to enable/disable bold characters.

The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.

Parameters:
set - if true turn on bold for subsequent characters.

clearScreen

void clearScreen()
This shortcut method clears the screen.

The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.


ringBell

void ringBell()
This shortcut method rings the terminal bell.

The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.


setCursorPos

void setCursorPos(int row,
                  int col)
This shortcut method moves the cursor to the given position.

The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.

Parameters:
row - row to place cursor on
col - column to place cursor on

clearLine

void clearLine()
This shortcut method clears the current line.

The shortcut methods are used by local code to achieve certain effects without knowing which terminal emulation is active.