de.mud.terminal
Class VDUBuffer

java.lang.Object
  |
  +--de.mud.terminal.VDUBuffer
Direct Known Subclasses:
vt320

public class VDUBuffer
extends java.lang.Object

Implementation of a Video Display Unit (VDU) buffer. This class contains all methods to manipulate the buffer that stores characters and their attributes as well as the regions displayed.

Version:
$Id: VDUBuffer.java,v 1.3 2003/04/27 16:36:45 marcus Exp $
Author:
Matthias L. Jugel, Marcus Meißner

Field Summary
static int BOLD
          Make character bold.
 int bufSize
           
 char[][] charArray
           
 int[][] charAttributes
           
static int COLOR
          color mask
static int COLOR_BG
          background color mask
static int COLOR_BG_SHIFT
          how much to left shift the background color
static int COLOR_FG
          foreground color mask
static int COLOR_FG_SHIFT
          how much to left shift the foreground color
protected  int cursorX
           
protected  int cursorY
           
static int debug
          Enable debug messages.
protected  VDUDisplay display
          a generic display that should redraw on demand
 int height
           
static java.lang.String ID
          The current version id tag
static int INVERT
          Invert character.
static int INVISIBLE
          Invisible character.
static int LOW
          Lower intensity character.
 int maxBufSize
           
static int NORMAL
          Make character normal.
 int screenBase
           
static boolean SCROLL_DOWN
          Scroll down when inserting a line.
static boolean SCROLL_UP
          Scroll up when inserting a line.
 int scrollMarker
           
protected  boolean showcursor
           
static int UNDERLINE
          Underline character.
 boolean[] update
           
 int width
           
 int windowBase
           
 
Constructor Summary
VDUBuffer()
          Create a standard video display buffer with 80 columns and 24 lines.
VDUBuffer(int width, int height)
          Create a new video display buffer with the passed width and height in characters.
 
Method Summary
 void deleteArea(int c, int l, int w, int h)
          Delete a rectangular portion of the screen.
 void deleteArea(int c, int l, int w, int h, int curAttr)
          Delete a rectangular portion of the screen.
 void deleteChar(int c, int l)
          Delete a character at a given position on the screen.
 void deleteLine(int l)
          Delete a line at a specific position.
 int getAttributes(int c, int l)
          Get the attributes for the specified position.
 int getBottomMargin()
          Get the bottom scroll margin.
 int getBufferSize()
          Retrieve current scrollback buffer size.
 char getChar(int c, int l)
          Get the character at the specified position.
 int getColumns()
          Get amount of columns on the screen.
 int getCursorColumn()
          Get the current column of the cursor position.
 int getCursorRow()
          Get the current line of the cursor position.
 int getMaxBufferSize()
          Retrieve maximum buffer Size.
 int getRows()
          Get amount of rows on the screen.
 int getTopMargin()
          Get the top scroll margin.
 int getWindowBase()
          Get the current window base.
 void insertChar(int c, int l, char ch, int attributes)
          Insert a character at a specific position on the screen.
 void insertLine(int l)
          Insert a blank line at a specific position.
 void insertLine(int l, boolean scrollDown)
          Insert a blank line at a specific position.
 void insertLine(int l, int n)
          Insert blank lines at a specific position.
 void insertLine(int l, int n, boolean scrollDown)
          Insert blank lines at a specific position.
 void markLine(int l, int n)
          Mark lines to be updated with redraw().
 void putChar(int c, int l, char ch)
          Put a character on the screen with normal font and outline.
 void putChar(int c, int l, char ch, int attributes)
          Put a character on the screen with specific font and outline.
 void putString(int c, int l, java.lang.String s)
          Put a String at a specific position.
 void putString(int c, int l, java.lang.String s, int attributes)
          Put a String at a specific position giving all characters the same attributes.
protected  void redraw()
          Trigger a redraw on the display.
 void setBottomMargin(int l)
          Set the bottom scroll margin for the screen.
 void setBufferSize(int amount)
          Set scrollback buffer size.
 void setCursorPosition(int c, int l)
          Puts the cursor at the specified position.
 void setDisplay(VDUDisplay display)
           
 void setScreenSize(int w, int h)
          Change the size of the screen.
 void setTopMargin(int l)
          Set the top scroll margin for the screen.
 void setWindowBase(int line)
          Set the current window base.
 void showCursor(boolean doshow)
          Sets whether the cursor is visible or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final java.lang.String ID
The current version id tag

See Also:
Constant Field Values

debug

public static final int debug
Enable debug messages.

See Also:
Constant Field Values

height

public int height

width

public int width

update

public boolean[] update

charArray

public char[][] charArray

charAttributes

public int[][] charAttributes

bufSize

public int bufSize

maxBufSize

public int maxBufSize

screenBase

public int screenBase

windowBase

public int windowBase

scrollMarker

public int scrollMarker

showcursor

protected boolean showcursor

cursorX

protected int cursorX

cursorY

protected int cursorY

SCROLL_UP

public static final boolean SCROLL_UP
Scroll up when inserting a line.

See Also:
Constant Field Values

SCROLL_DOWN

public static final boolean SCROLL_DOWN
Scroll down when inserting a line.

See Also:
Constant Field Values

NORMAL

public static final int NORMAL
Make character normal.

See Also:
Constant Field Values

BOLD

public static final int BOLD
Make character bold.

See Also:
Constant Field Values

UNDERLINE

public static final int UNDERLINE
Underline character.

See Also:
Constant Field Values

INVERT

public static final int INVERT
Invert character.

See Also:
Constant Field Values

LOW

public static final int LOW
Lower intensity character.

See Also:
Constant Field Values

INVISIBLE

public static final int INVISIBLE
Invisible character.

See Also:
Constant Field Values

COLOR_FG_SHIFT

public static final int COLOR_FG_SHIFT
how much to left shift the foreground color

See Also:
Constant Field Values

COLOR_BG_SHIFT

public static final int COLOR_BG_SHIFT
how much to left shift the background color

See Also:
Constant Field Values

COLOR

public static final int COLOR
color mask

See Also:
Constant Field Values

COLOR_FG

public static final int COLOR_FG
foreground color mask

See Also:
Constant Field Values

COLOR_BG

public static final int COLOR_BG
background color mask

See Also:
Constant Field Values

display

protected VDUDisplay display
a generic display that should redraw on demand

Constructor Detail

VDUBuffer

public VDUBuffer(int width,
                 int height)
Create a new video display buffer with the passed width and height in characters.

Parameters:
width - the length of the character lines
height - the amount of lines on the screen

VDUBuffer

public VDUBuffer()
Create a standard video display buffer with 80 columns and 24 lines.

Method Detail

putChar

public void putChar(int c,
                    int l,
                    char ch)
Put a character on the screen with normal font and outline. The character previously on that position will be overwritten. You need to call redraw() to update the screen.

Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
ch - the character to show on the screen
See Also:
insertChar(int, int, char, int), deleteChar(int, int), redraw()

putChar

public void putChar(int c,
                    int l,
                    char ch,
                    int attributes)
Put a character on the screen with specific font and outline. The character previously on that position will be overwritten. You need to call redraw() to update the screen.

Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
ch - the character to show on the screen
attributes - the character attributes
See Also:
BOLD, UNDERLINE, INVERT, INVISIBLE, NORMAL, LOW, insertChar(int, int, char, int), deleteChar(int, int), redraw()

getChar

public char getChar(int c,
                    int l)
Get the character at the specified position.

Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
See Also:
putChar(int, int, char)

getAttributes

public int getAttributes(int c,
                         int l)
Get the attributes for the specified position.

Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
See Also:
putChar(int, int, char)

insertChar

public void insertChar(int c,
                       int l,
                       char ch,
                       int attributes)
Insert a character at a specific position on the screen. All character right to from this position will be moved one to the right. You need to call redraw() to update the screen.

Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
ch - the character to insert
attributes - the character attributes
See Also:
BOLD, UNDERLINE, INVERT, INVISIBLE, NORMAL, LOW, putChar(int, int, char), deleteChar(int, int), redraw()

deleteChar

public void deleteChar(int c,
                       int l)
Delete a character at a given position on the screen. All characters right to the position will be moved one to the left. You need to call redraw() to update the screen.

Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
See Also:
putChar(int, int, char), insertChar(int, int, char, int), redraw()

putString

public void putString(int c,
                      int l,
                      java.lang.String s)
Put a String at a specific position. Any characters previously on that position will be overwritten. You need to call redraw() for screen update.

Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
s - the string to be shown on the screen
See Also:
BOLD, UNDERLINE, INVERT, INVISIBLE, NORMAL, LOW, putChar(int, int, char), insertLine(int), deleteLine(int), redraw()

putString

public void putString(int c,
                      int l,
                      java.lang.String s,
                      int attributes)
Put a String at a specific position giving all characters the same attributes. Any characters previously on that position will be overwritten. You need to call redraw() to update the screen.

Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
s - the string to be shown on the screen
attributes - character attributes
See Also:
BOLD, UNDERLINE, INVERT, INVISIBLE, NORMAL, LOW, putChar(int, int, char), insertLine(int), deleteLine(int), redraw()

insertLine

public void insertLine(int l)
Insert a blank line at a specific position. The current line and all previous lines are scrolled one line up. The top line is lost. You need to call redraw() to update the screen.

Parameters:
l - the y-coordinate to insert the line
See Also:
deleteLine(int), redraw()

insertLine

public void insertLine(int l,
                       int n)
Insert blank lines at a specific position. You need to call redraw() to update the screen

Parameters:
l - the y-coordinate to insert the line
n - amount of lines to be inserted
See Also:
deleteLine(int), redraw()

insertLine

public void insertLine(int l,
                       boolean scrollDown)
Insert a blank line at a specific position. Scroll text according to the argument. You need to call redraw() to update the screen

Parameters:
l - the y-coordinate to insert the line
scrollDown - scroll down
See Also:
deleteLine(int), SCROLL_UP, SCROLL_DOWN, redraw()

insertLine

public void insertLine(int l,
                       int n,
                       boolean scrollDown)
Insert blank lines at a specific position. The current line and all previous lines are scrolled one line up. The top line is lost. You need to call redraw() to update the screen.

Parameters:
l - the y-coordinate to insert the line
n - number of lines to be inserted
scrollDown - scroll down
See Also:
deleteLine(int), SCROLL_UP, SCROLL_DOWN, redraw()

deleteLine

public void deleteLine(int l)
Delete a line at a specific position. Subsequent lines will be scrolled up to fill the space and a blank line is inserted at the end of the screen.

Parameters:
l - the y-coordinate to insert the line
See Also:
deleteLine(int)

deleteArea

public void deleteArea(int c,
                       int l,
                       int w,
                       int h,
                       int curAttr)
Delete a rectangular portion of the screen. You need to call redraw() to update the screen.

Parameters:
c - x-coordinate (column)
l - y-coordinate (row)
w - with of the area in characters
h - height of the area in characters
curAttr - attribute to fill
See Also:
deleteChar(int, int), deleteLine(int), redraw()

deleteArea

public void deleteArea(int c,
                       int l,
                       int w,
                       int h)
Delete a rectangular portion of the screen. You need to call redraw() to update the screen.

Parameters:
c - x-coordinate (column)
l - y-coordinate (row)
w - with of the area in characters
h - height of the area in characters
See Also:
deleteChar(int, int), deleteLine(int), redraw()

showCursor

public void showCursor(boolean doshow)
Sets whether the cursor is visible or not.

Parameters:
doshow -

setCursorPosition

public void setCursorPosition(int c,
                              int l)
Puts the cursor at the specified position.

Parameters:
c - column
l - line

getCursorColumn

public int getCursorColumn()
Get the current column of the cursor position.


getCursorRow

public int getCursorRow()
Get the current line of the cursor position.


setWindowBase

public void setWindowBase(int line)
Set the current window base. This allows to view the scrollback buffer.

Parameters:
line - the line where the screen window starts
See Also:
setBufferSize(int), getBufferSize()

getWindowBase

public int getWindowBase()
Get the current window base.

See Also:
setWindowBase(int)

setTopMargin

public void setTopMargin(int l)
Set the top scroll margin for the screen. If the current bottom margin is smaller it will become the top margin and the line will become the bottom margin.

Parameters:
l - line that is the margin

getTopMargin

public int getTopMargin()
Get the top scroll margin.


setBottomMargin

public void setBottomMargin(int l)
Set the bottom scroll margin for the screen. If the current top margin is bigger it will become the bottom margin and the line will become the top margin.

Parameters:
l - line that is the margin

getBottomMargin

public int getBottomMargin()
Get the bottom scroll margin.


setBufferSize

public void setBufferSize(int amount)
Set scrollback buffer size.

Parameters:
amount - new size of the buffer

getBufferSize

public int getBufferSize()
Retrieve current scrollback buffer size.

See Also:
setBufferSize(int)

getMaxBufferSize

public int getMaxBufferSize()
Retrieve maximum buffer Size.

See Also:
getBufferSize()

setScreenSize

public void setScreenSize(int w,
                          int h)
Change the size of the screen. This will include adjustment of the scrollback buffer.

Parameters:
w - of the screen
h - of the screen

getRows

public int getRows()
Get amount of rows on the screen.


getColumns

public int getColumns()
Get amount of columns on the screen.


markLine

public void markLine(int l,
                     int n)
Mark lines to be updated with redraw().

Parameters:
l - starting line
n - amount of lines to be updated
See Also:
redraw()

setDisplay

public void setDisplay(VDUDisplay display)

redraw

protected void redraw()
Trigger a redraw on the display.