TelnetD at SF

net.wimpi.telnetd.io.terminal
Class BasicTerminal

java.lang.Object
  extended bynet.wimpi.telnetd.io.terminal.BasicTerminal
All Implemented Interfaces:
Terminal
Direct Known Subclasses:
ansi, vt100, Windoof, xterm

public abstract class BasicTerminal
extends java.lang.Object
implements Terminal

A basic terminal implementation with the focus on vt100 related sequences. This terminal type is most common out there, with sequences that are normally also understood by its successors.

Version:
2.0 (13/03/2005)
Author:
Dieter Wimberger

Field Summary
protected  Colorizer m_Colorizer
           
 
Fields inherited from interface net.wimpi.telnetd.io.terminal.Terminal
A, B, BS, C, CAN, D, DEL, E, EOT, ESC, f, FF, H, HT, LE, LSB, r, SE, SEMICOLON, SGR
 
Constructor Summary
BasicTerminal()
          Constructs an instance with an associated colorizer.
 
Method Summary
 java.lang.String format(java.lang.String str)
          Returns a "formatted" string containing terminal dependent GR escape sequences (i.e. colors and style).
 java.lang.String formatBold(java.lang.String str)
          Returns a "bold formatted" string containing terminal dependent GR escape sequences (i.e. colors and style).
 int getAtomicSequenceLength()
          Returns the atomic escape sequence length of the terminal implementation as integer (without counting the escape itself).
 byte[] getCursorMoveSequence(int direction, int times)
          Returns a terminal dependent escape sequence for a given cursor movement.
 byte[] getCursorPositioningSequence(int[] pos)
          Returns a terminal dependent escape sequence for positioning the cursor to a given position: index 0: row coordinate index 1: column coordinate Note that home is a special positioning sequence.
 byte[] getEraseSequence(int eraseFunc)
          Returns a terminal dependent escape sequence for a given defined erase function: erase to end of line (EEOL) erase to begin of line (EBOL) erase entire line (EEL) erase to end of screen (EEOS) erase to beginning of screen (EBOS) erase entire screen (EES)
 byte[] getGRSequence(int type, int param)
          Returns the terminal dependent escape sequence for a given graphics rendition request.
 byte[] getInitSequence()
          Returns the byte sequence that will init the terminal.
 byte[] getScrollMarginsSequence(int topmargin, int bottommargin)
          Returns the terminal dependent escape sequence for establishing the given scrollmargins.
 byte[] getSpecialSequence(int function)
          Returns the terminal dependent escape sequence for a given defined special function.
abstract  boolean supportsScrolling()
          Returns if the terminal implementation supports scrolling (i.e. setting scroll margins).
abstract  boolean supportsSGR()
          Returns if the terminal implementation supports graphics rendition (i.e. colors and styles).
 int translateControlCharacter(int c)
          Translates a control character into terminal independent representation.
 int translateEscapeSequence(int[] buffer)
          Translates an escape sequence into a terminal independent representation.
 byte[] translateIntToDigitCodes(int in)
          Translates an integer to a byte sequence of its digits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Colorizer

protected Colorizer m_Colorizer
Constructor Detail

BasicTerminal

public BasicTerminal()
Constructs an instance with an associated colorizer.

Method Detail

translateControlCharacter

public int translateControlCharacter(int c)
Description copied from interface: Terminal
Translates a control character into terminal independent representation.

Specified by:
translateControlCharacter in interface Terminal
Parameters:
c - int read from the input stream.
Returns:
the read int or the internal control character definition.

translateEscapeSequence

public int translateEscapeSequence(int[] buffer)
Description copied from interface: Terminal
Translates an escape sequence into a terminal independent representation.

Specified by:
translateEscapeSequence in interface Terminal
Parameters:
buffer - array of integers containing a escape sequence.
Returns:
the terminal independent representation.

getCursorMoveSequence

public byte[] getCursorMoveSequence(int direction,
                                    int times)
Description copied from interface: Terminal
Returns a terminal dependent escape sequence for a given cursor movement.
The directions available are:

Specified by:
getCursorMoveSequence in interface Terminal
Parameters:
direction - Direction of movement.
times - Number of movements into given direction.
Returns:
the byte sequence representing the terminal dependent escape sequence.

getCursorPositioningSequence

public byte[] getCursorPositioningSequence(int[] pos)
Description copied from interface: Terminal
Returns a terminal dependent escape sequence for positioning the cursor to a given position: Note that home is a special positioning sequence. It could result in a special sequence different from the positioning sequence to 0,0 coordinates.

Specified by:
getCursorPositioningSequence in interface Terminal
Parameters:
pos - Position to move the cursor to.
Returns:
the byte sequence representing the terminal dependent escape sequence.
See Also:
TerminalIO.HOME

getEraseSequence

public byte[] getEraseSequence(int eraseFunc)
Description copied from interface: Terminal
Returns a terminal dependent escape sequence for a given defined erase function:

Specified by:
getEraseSequence in interface Terminal
Parameters:
eraseFunc - representing one of the specified erase functions.
Returns:
the byte sequence representing the terminal dependent escape sequence.
See Also:
TerminalIO.EEOL, TerminalIO.EBOL, TerminalIO.EEL, TerminalIO.EEOS, TerminalIO.EBOS, TerminalIO.EES

getSpecialSequence

public byte[] getSpecialSequence(int function)
Description copied from interface: Terminal
Returns the terminal dependent escape sequence for a given defined special function.
There are two special functions that should be implemented:
  1. store current cursor position (STORECURSOR)
  2. restore previously stored cursor position (RESTORECURSOR)

Specified by:
getSpecialSequence in interface Terminal
Parameters:
function - the special sequence defined as int in TerminalIO.
Returns:
the byte sequence representing the terminal dependent escape sequence.
See Also:
TerminalIO.STORECURSOR, TerminalIO.RESTORECURSOR

getGRSequence

public byte[] getGRSequence(int type,
                            int param)
Description copied from interface: Terminal
Returns the terminal dependent escape sequence for a given graphics rendition request.
Defined are following types: Note that by no means, all terminals will support this. Display might differ widely from implementation to implementation. Yet this is a more or less complete abstraction of what could be possible.

Specified by:
getGRSequence in interface Terminal
Parameters:
type - Type of graphics rendition request.
param - Parameter to the type requested.
Returns:
the byte sequence representing the terminal dependent escape sequence.

getScrollMarginsSequence

public byte[] getScrollMarginsSequence(int topmargin,
                                       int bottommargin)
Description copied from interface: Terminal
Returns the terminal dependent escape sequence for establishing the given scrollmargins.
Note that this method is experimental and not available through the BasicTerminalIO interface yet.

Specified by:
getScrollMarginsSequence in interface Terminal
Parameters:
topmargin - upper border of the scrolling area as row coordinate.
bottommargin - lower border of the scrolling area as row coordinate.
Returns:
the byte sequence representing the terminal dependent escape sequence.

format

public java.lang.String format(java.lang.String str)
Description copied from interface: Terminal
Returns a "formatted" string containing terminal dependent GR escape sequences (i.e. colors and style).
The string passed as a parameter should contain the internal markup based upon - inited sequences.
If the terminal does not support graphics rendition, then the markup will be parsed out. Its strongly recommended not to send escape sequences a client is unable to understand, even if some clients filter themselves.

Specified by:
format in interface Terminal
Parameters:
str - String to be formatted.
Returns:
the string with sequences that will render properly on the terminal.

formatBold

public java.lang.String formatBold(java.lang.String str)
Description copied from interface: Terminal
Returns a "bold formatted" string containing terminal dependent GR escape sequences (i.e. colors and style).
The string passed as a parameter should contain the internal markup based upon - inited sequences.
If the terminal does not support graphics rendition, then the markup will be parsed out. Its strongly recommended not to send escape sequences a client is unable to understand, even if some clients filter themselves.

Specified by:
formatBold in interface Terminal
Parameters:
str - String to be formatted.
Returns:
the string with sequences that will render properly on the terminal.

getInitSequence

public byte[] getInitSequence()
Description copied from interface: Terminal
Returns the byte sequence that will init the terminal.

Specified by:
getInitSequence in interface Terminal
Returns:
the byte sequence representing the terminal dependent init escape sequence.

getAtomicSequenceLength

public int getAtomicSequenceLength()
Description copied from interface: Terminal
Returns the atomic escape sequence length of the terminal implementation as integer (without counting the escape itself).

Specified by:
getAtomicSequenceLength in interface Terminal
Returns:
the atomic escape sequence length.

translateIntToDigitCodes

public byte[] translateIntToDigitCodes(int in)
Translates an integer to a byte sequence of its digits.

Parameters:
in - integer to be translated.
Returns:
the byte sequence representing the digits.

supportsSGR

public abstract boolean supportsSGR()
Description copied from interface: Terminal
Returns if the terminal implementation supports graphics rendition (i.e. colors and styles).

Specified by:
supportsSGR in interface Terminal
Returns:
a boolean that flags if the terminal supports GR (true) or not (false).

supportsScrolling

public abstract boolean supportsScrolling()
Description copied from interface: Terminal
Returns if the terminal implementation supports scrolling (i.e. setting scroll margins).
Note that this method is addenum to the experimental and not available getScrollMarginsSequence(int,int).

Specified by:
supportsScrolling in interface Terminal
Returns:
a boolean that flags if the terminal supports scrolling (true) or not (false).

TelnetD at SF

Copyright © 2000-2005 Dieter Wimberger.