public class ConsolePrimitives extends DriverPrimitives
This implementation uses text console-based native driver for terminal access. The specific of this implementation is that native API in many cases exposes or is affected by NCURSES-specific details, such as key processing and special handling of pseudo-graphics characters.
Modifier and Type | Field and Description |
---|---|
private int |
A_BLINK
Blink attribute
|
private int |
A_BOLD
Bold attribute
|
private int |
A_NORMAL
Normal attribute.
|
private int |
A_REVERSE
Reverse attribute
|
private int |
A_UNDERLINE
Underline attribute
|
private static int |
ACS_CKBOARD
Checker board char for scrollbars body.
|
private static int |
ACS_DARROW
Down arrow char for vertical scrollbars.
|
private static int |
ACS_HLINE
Horizontal line drawing char.
|
private static int |
ACS_LARROW
Left arrow char for horizontal scrollbars.
|
private static int |
ACS_LLCORNER
Lower left corner drawing char.
|
private static int |
ACS_LRCORNER
Lower right corner drawing char.
|
private static int |
ACS_RARROW
Right arrow char for horizontal scrollbars.
|
private static int |
ACS_SELECT
Current selection char for selection lists.
|
private static int |
ACS_UARROW
Up arrow char for vertical scrollbars.
|
private static int |
ACS_ULCORNER
Upper left corner drawing char.
|
private static int |
ACS_URCORNER
Upper right corner drawing char.
|
private static int |
ACS_VLINE
Vertical line drawing char.
|
private ConsoleHelper |
helper
Reference to console low-level driver.
|
private boolean |
useColor
Flag which controls use of colors.
|
cursorInvalid, EMPTY_CELL
Constructor and Description |
---|
ConsolePrimitives()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
append(java.lang.String str,
Color color)
Add a string to the virtual terminal at the current cursor position.
|
private int |
attribute(Color color)
Extract attributes from given
Color instance. |
private int |
character(char character)
Convert source character into form recognized by native driver.
|
private int |
color(Color color)
Extract color from given
Color instance. |
private int[] |
convertToAttributeBuffer(ScreenData screen)
Convert screen data into array of attributes recognized by native driver.
|
private int[] |
convertToCharBuffer(ScreenData screen)
Convert screen data into array of characters recognized by native driver.
|
private int[] |
convertToColorBuffer(ScreenData screen)
Convert screen data into array of colors recognized by native driver.
|
boolean |
cursorAt(int x,
int y)
Position the virtual cursor during the drawing.
|
boolean |
cursorStay(int x,
int y)
Position the real cursor.
|
int |
getX()
Get absolute X position of the cursor.
|
int |
getY()
Get absolute Y position of the cursor.
|
void |
init(ConsoleHelper helper)
Initialize the class, which must be done only after the
ConsoleHelper
instance is initialized. |
int |
screenHeight()
Gets the number of rows on the screen.
|
int |
screenWidth()
Gets the number of columns on the screen.
|
void |
sync()
Synchronize the state of the physical terminal with the state of
the virtual terminal.
|
void |
updateScreen(ScreenData screen)
Perform a bulk output operation for the whole screen at once with
output masking when desired.
|
append, borderColor, box, clearArea, drawHBorder, drawLLCorner, drawLRCorner, drawULCorner, drawURCorner, drawVBorder, getScreenBitmap, hLine, refresh, setScreenBitmap, vLine, widgetColor
cellAt, getWindowId, hasBoxBorderCorners, isCursorInvalid, setCursorInvalid
private static int ACS_HLINE
private static int ACS_VLINE
private static int ACS_ULCORNER
private static int ACS_URCORNER
private static int ACS_LRCORNER
private static int ACS_LLCORNER
private static int ACS_UARROW
private static int ACS_DARROW
private static int ACS_LARROW
private static int ACS_RARROW
private static int ACS_CKBOARD
private static int ACS_SELECT
private ConsoleHelper helper
private int A_NORMAL
private int A_UNDERLINE
private int A_REVERSE
private int A_BLINK
private int A_BOLD
private boolean useColor
public void init(ConsoleHelper helper)
ConsoleHelper
instance is initialized.helper
- ConsoleHelper instance used for direct drawing.public void append(java.lang.String str, Color color)
append
in class BasePrimitives
str
- The text to output.color
- The Color instance used to draw characters. Mapping into native
colors is performed internally.public boolean cursorAt(int x, int y)
cursorAt
in class BasePrimitives
x
- New cursor X.y
- New cursor Y.true
if cursor positioning succeeded.public boolean cursorStay(int x, int y)
cursorStay
in class BasePrimitives
x
- New cursor X.y
- New cursor Y.true
if cursor positioning succeeded.public int getX()
getX
in class BasePrimitives
public int getY()
getY
in class BasePrimitives
public int screenHeight()
public int screenWidth()
public void sync()
public void updateScreen(ScreenData screen)
The screen container is 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.
updateScreen
in class BasePrimitives
screen
- Container for whole screen content and cursor position.private int attribute(Color color)
Color
instance.color
- Color.private int character(char character)
character
- Input character.private int color(Color color)
Color
instance.
The method returns -1 if useColor
is false,
the color parameter is null or the color instance
contains unsupported color (@see ColorPalette).color
- Color.private int[] convertToCharBuffer(ScreenData screen)
screen
- Screen data.private int[] convertToColorBuffer(ScreenData screen)
screen
- Screen data.private int[] convertToAttributeBuffer(ScreenData screen)
screen
- Screen data.