de.mud.terminal

Class VDUBuffer

Known Direct 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 503 2005-10-24 07:34:13Z marcus $
Author:
Matthias L. Jugel, Marcus Mei???ner

Field Summary

static int
BOLD
Make character bold.
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
static String
ID
The current version id tag
static int
INVERT
Invert character.
static int
INVISIBLE
Invisible character.
static int
LOW
Lower intensity character.
static int
NORMAL
Make character normal.
static boolean
SCROLL_DOWN
Scroll down when inserting a line.
static boolean
SCROLL_UP
Scroll up when inserting a line.
static int
UNDERLINE
Underline character.
int
bufSize
char[][]
charArray
int[][]
charAttributes
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
int
maxBufSize
int
screenBase
int
scrollMarker
protected boolean
showcursor
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, String s)
Put a String at a specific position.
void
putString(int c, int l, 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, boolean broadcast)
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.

Field Details

BOLD

public static final int BOLD
Make character bold.
Field Value:
1

COLOR

public static final int COLOR
color mask
Field Value:
8160

COLOR_BG

public static final int COLOR_BG
background color mask
Field Value:
7680

COLOR_BG_SHIFT

public static final int COLOR_BG_SHIFT
how much to left shift the background color
Field Value:
9

COLOR_FG

public static final int COLOR_FG
foreground color mask
Field Value:
480

COLOR_FG_SHIFT

public static final int COLOR_FG_SHIFT
how much to left shift the foreground color
Field Value:
5

ID

public static final String ID
The current version id tag

INVERT

public static final int INVERT
Invert character.
Field Value:
4

INVISIBLE

public static final int INVISIBLE
Invisible character.
Field Value:
16

LOW

public static final int LOW
Lower intensity character.
Field Value:
8

NORMAL

public static final int NORMAL
Make character normal.
Field Value:
0

UNDERLINE

public static final int UNDERLINE
Underline character.
Field Value:
2

bufSize

public int bufSize

charArray

public char[][] charArray

charAttributes

public int[][] charAttributes

cursorX

protected int cursorX

cursorY

protected int cursorY

debug

public static final int debug
Enable debug messages.
Field Value:
0

display

protected VDUDisplay display
a generic display that should redraw on demand

height

public int height

maxBufSize

public int maxBufSize

screenBase

public int screenBase

scrollMarker

public int scrollMarker

showcursor

protected boolean showcursor

update

public boolean[] update

width

public int width

windowBase

public int windowBase

Constructor Details

VDUBuffer

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

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

Method Details

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

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

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)

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

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

getBottomMargin

public int getBottomMargin()
Get the bottom scroll margin.

getBufferSize

public int getBufferSize()
Retrieve current scrollback buffer size.

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

getColumns

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

getCursorColumn

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

getCursorRow

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

getMaxBufferSize

public int getMaxBufferSize()
Retrieve maximum buffer Size.

getRows

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

getTopMargin

public int getTopMargin()
Get the top scroll margin.

getWindowBase

public int getWindowBase()
Get the current window base.

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

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

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

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

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

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

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

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

putString

public void putString(int c,
                      int l,
                      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

putString

public void putString(int c,
                      int l,
                      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

redraw

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

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

setBufferSize

public void setBufferSize(int amount)
Set scrollback buffer size.
Parameters:
amount - new size of the buffer

setCursorPosition

public void setCursorPosition(int c,
                              int l)
Puts the cursor at the specified position.
Parameters:
c - column
l - line

setDisplay

public void setDisplay(VDUDisplay display)

setScreenSize

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

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

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

showCursor

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