public class DoubleBufferedTerminal extends AbstractTerminalBuffer
The master buffer holds the most recent rendering of the terminal screen image. The current buffer is where the new rendering is performed until a sync() request comes.
Syncing means the current rendering is over. The two buffers are compared position by position and only the differing positions are transmitted to the terminal screen using bulk update. The same positions are copied to the master buffer as well. When the syncing is over, the buffers look identical.
Modifier and Type | Field and Description |
---|---|
private BasePrimitives |
directOutput
The direct terminal output driver.
|
private boolean |
dirty
Master buffer dirty flag
|
private ScreenBitmap |
mask
Mask for actually used cells.
|
private Cell[][] |
master
Master buffer.
|
private Cell[][] |
matrix
Low level call parameters array.
|
private NativeRectangle |
outer
Outer rectangle for all used cells.
|
private ChuiOutputManager |
screen
The OutputManager instance.
|
private boolean |
trapF
(Debug) trapping of refreshing is active.
|
private boolean |
trapM
(Debug) trapping in master buffer is active.
|
private NativeRectangle |
trapMast
(Debug) trapping rectangle for master buffer.
|
private boolean |
trapR
(Debug) trapping in rendering buffer is active.
|
private NativeRectangle |
trapRefr
(Debug) trapping rectangle for refreshing the master buffer.
|
private NativeRectangle |
trapRend
(Debug) trapping rectangle for rendering buffer.
|
cols, csx, csy, cx, cy, rows
cursorInvalid, EMPTY_CELL
Constructor and Description |
---|
DoubleBufferedTerminal(int height,
int width)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
append(int chr,
Color color)
Add a character to the virtual terminal at the current cursor
position.
|
void |
conditionalLineRefresh(Rectangle rect)
Special refreshing algorithm which is used for refreshing of horizontal
lines of frame border.
|
void |
conditionalRefresh()
Conditionally refresh output.
|
void |
conditionalRefresh(Rectangle rect)
Conditionally refresh specified rectangle.
|
protected void |
cursorRelocated(int csx,
int csy)
Callback method when cursor is actually relocated at given position.
|
private boolean |
flush(boolean merge)
Compare buffers and fill the matrix for update.
|
private boolean |
isSame(int r,
int c,
Cell cell)
Compare given cell with rendering buffer and return
true if
cells are equal. |
void |
refresh(NativeRectangle rect)
Mark a rectangle as needing repainting.
|
void |
refreshMask(NativeRectangle rect)
Mark a rectangle as needing repainting within the mask array.
|
private void |
refreshWorker(NativeRectangle rect,
boolean isMask)
Mark a rectangle as needing repainting in either the main bitmap
array or within the mask array.
|
void |
reset()
Reset outer rectangle.
|
void |
sync()
Synchronize the state of the physical terminal with the state of
the virtual terminal.
|
private void |
trap(NativeRectangle rect,
int row,
int col)
Debugging aid that helps in trapping the drawing operation touching
specific rectangle of the screen.
|
advanceCursor, append, box, clearArea, cursorAt, cursorStay, drawHBorder, drawLLCorner, drawLRCorner, drawULCorner, drawURCorner, drawVBorder, getScreenBitmap, getX, getY, hLine, render, screenHeight, screenWidth, setScreenBitmap, vLine
borderColor, cellAt, getWindowId, hasBoxBorderCorners, isCursorInvalid, setCursorInvalid, updateScreen, widgetColor
private ChuiOutputManager screen
private BasePrimitives directOutput
private boolean dirty
private Cell[][] master
private Cell[][] matrix
private ScreenBitmap mask
private NativeRectangle outer
private boolean trapR
private boolean trapM
private boolean trapF
private NativeRectangle trapRend
private NativeRectangle trapMast
private NativeRectangle trapRefr
public DoubleBufferedTerminal(int height, int width)
height
- The terminal's height.width
- The terminal's width.public void append(int chr, Color color)
This routine is NOT safe for use with characters that are UNICODE
encoded which are also outside of the 7-bit ASCII range. Such
characters are passed through to the native layer directly and are
not converted to a natively encoded form. This could be provided
but since one of the primary uses of this method is for drawing
characters (e.g. ACS_HLINE
) which are encoded using the
full 32-bits, any attempt to convert these into a single byte native
encoding would lose data.
Because of the above limitation, DO NOT USE THIS FOR OUTPUT OF USER DATA THAT COULD CONTAIN DATA OUTSIDE OF THE 7-bit ASCII RANGE.
append
in class BasePrimitives
chr
- The character to output.color
- The number of the color-pair (foreground + background) to
use for blanking the rectangle.protected void cursorRelocated(int csx, int csy)
cursorRelocated
in class AbstractTerminalBuffer
csx
- Cursor X.csy
- Cursor Y.public void refresh(NativeRectangle rect)
rect
- rectangle to mark for repainting in screen coordinatespublic void refreshMask(NativeRectangle rect)
rect
- rectangle to mark for repainting in screen coordinatespublic void sync()
private void refreshWorker(NativeRectangle rect, boolean isMask)
rect
- Rectangle to mark for repainting in screen coordinates.isMask
- true
to edit the mask array, false
to edit the main bitmap array.private boolean flush(boolean merge)
merge
- If true
both buffers are synchronized.true
if sync is required.private void trap(NativeRectangle rect, int row, int col)
rect
- Rectangle to watchrow
- screen position being changedcol
- screen position being changedpublic void conditionalRefresh()
public void conditionalRefresh(Rectangle rect)
rect
- Rectangle to refresh.public void conditionalLineRefresh(Rectangle rect)
rect
- Rectangle where horizontal lines should be refreshed.public void reset()
private boolean isSame(int r, int c, Cell cell)
true
if
cells are equal.r
- Row.c
- Column.cell
- Cell to compare.true
if cells are equal.