TelnetD at SF

net.wimpi.telnetd.io.terminal
Interface Terminal

All Known Implementing Classes:
BasicTerminal

public interface Terminal

On top of the telnet protocol communication layer there is a layer for terminal communication. This layer is represented by so called escape sequences that are filtered and interpreted.
This interface defines abstracts filtering and translation methods so that the TerminalIO is independent of a specific terminal implementation.

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

Field Summary
static byte A
          A (UP)
The byte code of A, as used in escape sequences for cursor up.
static byte B
          B (DOWN)
The byte code of B, as used in escape sequences for cursor down.
static byte BS
          BackSpace
The ANSI defined byte code of backspace.
static byte C
          C (RIGHT)
The byte code of C, as used in escape sequences for cursor right.
static byte CAN
          Cancel
The ANSI defined byte code for cancelling an escape sequence.
static byte D
          D (LEFT)
The byte code of D, as used in escape sequences for cursor left.
static byte DEL
          Delete
The ANSI defined byte code of delete.
static byte E
          Other characters used in escape sequences.
static byte EOT
          End of transmission
Ctrl-d, which flags end of transmission, or better said a client logout request.
static byte ESC
          Escape
The ANSI definde byte code of escape.
static byte f
           
static byte FF
          FormFeed
The ANSI defined byte code of a form feed.
static byte H
           
static byte HT
          Horizontal Tab
The ANSI defined byte code of a horizontal tabulator.
static byte LE
          Characters needed for erase sequences.
static byte LSB
          [ Left Square Bracket
The ANSI defined byte code of a left square bracket, as used in escape sequences.
static byte r
           
static byte SE
           
static byte SEMICOLON
          ; Semicolon
The ANSI defined byte code of a semicolon, as used in escape sequences.
static byte SGR
          SGR Input Key
Ctrl-a as defined byte code.
 
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 dir, 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 sequence)
          Returns the terminal dependent escape sequence for a given defined special function.
 boolean supportsScrolling()
          Returns if the terminal implementation supports scrolling (i.e. setting scroll margins).
 boolean supportsSGR()
          Returns if the terminal implementation supports graphics rendition (i.e. colors and styles).
 int translateControlCharacter(int byteread)
          Translates a control character into terminal independent representation.
 int translateEscapeSequence(int[] buffer)
          Translates an escape sequence into a terminal independent representation.
 

Field Detail

EOT

public static final byte EOT
End of transmission
Ctrl-d, which flags end of transmission, or better said a client logout request.

See Also:
Constant Field Values

BS

public static final byte BS
BackSpace
The ANSI defined byte code of backspace.

See Also:
Constant Field Values

DEL

public static final byte DEL
Delete
The ANSI defined byte code of delete.

See Also:
Constant Field Values

HT

public static final byte HT
Horizontal Tab
The ANSI defined byte code of a horizontal tabulator.

See Also:
Constant Field Values

FF

public static final byte FF
FormFeed
The ANSI defined byte code of a form feed.

See Also:
Constant Field Values

SGR

public static final byte SGR
SGR Input Key
Ctrl-a as defined byte code. It might be of interest to support graphics rendition in edit mode, for the user to create marked up (i.e. formatted) input for the application context.

See Also:
Constant Field Values

CAN

public static final byte CAN
Cancel
The ANSI defined byte code for cancelling an escape sequence.

See Also:
Constant Field Values

ESC

public static final byte ESC
Escape
The ANSI definde byte code of escape.

See Also:
Constant Field Values

LSB

public static final byte LSB
[ Left Square Bracket
The ANSI defined byte code of a left square bracket, as used in escape sequences.

See Also:
Constant Field Values

SEMICOLON

public static final byte SEMICOLON
; Semicolon
The ANSI defined byte code of a semicolon, as used in escape sequences.

See Also:
Constant Field Values

A

public static final byte A
A (UP)
The byte code of A, as used in escape sequences for cursor up.

See Also:
Constant Field Values

B

public static final byte B
B (DOWN)
The byte code of B, as used in escape sequences for cursor down.

See Also:
Constant Field Values

C

public static final byte C
C (RIGHT)
The byte code of C, as used in escape sequences for cursor right.

See Also:
Constant Field Values

D

public static final byte D
D (LEFT)
The byte code of D, as used in escape sequences for cursor left.

See Also:
Constant Field Values

E

public static final byte E
Other characters used in escape sequences.

See Also:
Constant Field Values

H

public static final byte H
See Also:
Constant Field Values

f

public static final byte f
See Also:
Constant Field Values

r

public static final byte r
See Also:
Constant Field Values

LE

public static final byte LE
Characters needed for erase sequences.

See Also:
Constant Field Values

SE

public static final byte SE
See Also:
Constant Field Values
Method Detail

translateControlCharacter

public int translateControlCharacter(int byteread)
Translates a control character into terminal independent representation.

Parameters:
byteread - int read from the input stream.
Returns:
the read int or the internal control character definition.

translateEscapeSequence

public int translateEscapeSequence(int[] buffer)
Translates an escape sequence into a terminal independent representation.

Parameters:
buffer - array of integers containing a escape sequence.
Returns:
the terminal independent representation.

getEraseSequence

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

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

getCursorMoveSequence

public byte[] getCursorMoveSequence(int dir,
                                    int times)
Returns a terminal dependent escape sequence for a given cursor movement.
The directions available are:

Parameters:
dir - 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)
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.

Parameters:
pos - Position to move the cursor to.
Returns:
the byte sequence representing the terminal dependent escape sequence.
See Also:
TerminalIO.HOME

getSpecialSequence

public byte[] getSpecialSequence(int sequence)
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)

Parameters:
sequence - the special sequence defined as int in TerminalIO.
Returns:
the byte sequence representing the terminal dependent escape sequence.
See Also:
TerminalIO.STORECURSOR, TerminalIO.RESTORECURSOR

getScrollMarginsSequence

public byte[] getScrollMarginsSequence(int topmargin,
                                       int bottommargin)
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.

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.

getGRSequence

public byte[] getGRSequence(int type,
                            int param)
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.

Parameters:
type - Type of graphics rendition request.
param - Parameter to the type requested.
Returns:
the byte sequence representing the terminal dependent escape sequence.

format

public java.lang.String format(java.lang.String str)
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.

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)
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.

Parameters:
str - String to be formatted.
Returns:
the string with sequences that will render properly on the terminal.

getInitSequence

public byte[] getInitSequence()
Returns the byte sequence that will init the terminal.

Returns:
the byte sequence representing the terminal dependent init escape sequence.

supportsSGR

public boolean supportsSGR()
Returns if the terminal implementation supports graphics rendition (i.e. colors and styles).

Returns:
a boolean that flags if the terminal supports GR (true) or not (false).

supportsScrolling

public boolean supportsScrolling()
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).

Returns:
a boolean that flags if the terminal supports scrolling (true) or not (false).

getAtomicSequenceLength

public int getAtomicSequenceLength()
Returns the atomic escape sequence length of the terminal implementation as integer (without counting the escape itself).

Returns:
the atomic escape sequence length.

TelnetD at SF

Copyright 2000-2005 Dieter Wimberger.