public class Screen extends Object
Constructor and Description |
---|
Screen(Terminal terminal)
Creates a new Screen on top of a supplied terminal, will query the terminal
for its size.
|
Screen(Terminal terminal,
int terminalWidth,
int terminalHeight)
Creates a new Screen on top of a supplied terminal and will set the size
of the screen to a supplied value.
|
Screen(Terminal terminal,
TerminalSize terminalSize)
Creates a new Screen on top of a supplied terminal and will set the size
of the screen to a supplied value.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Erases all the characters on the screen, effectively giving you a blank
area.
|
void |
completeRefresh()
Clears the terminal and repaints with the whole content of the Screen.
|
TerminalPosition |
getCursorPosition() |
TabBehaviour |
getTabBehaviour()
Gets the behaviour for what to do about tab characters.
|
Terminal |
getTerminal() |
TerminalSize |
getTerminalSize() |
void |
putString(int x,
int y,
String string,
Terminal.Color foregroundColor,
Terminal.Color backgroundColor,
ScreenCharacterStyle... styles)
Draws a string on the screen at a particular position
|
void |
putString(int x,
int y,
String string,
Terminal.Color foregroundColor,
Terminal.Color backgroundColor,
Set<ScreenCharacterStyle> styles)
Draws a string on the screen at a particular position
|
Key |
readInput()
Reads the next
Key from the input queue, or returns null if there
is nothing on the queue. |
void |
refresh()
Call this method to make changes done through
putCharacter(...) ,
putString(...) visible on the terminal. |
boolean |
resizePending()
This method will check if there are any resize commands pending.
|
void |
setCursorPosition(int column,
int row)
Moves the current cursor position, and if the cursor was hidden it will be visible after this
call
|
void |
setCursorPosition(TerminalPosition position)
Moves the current cursor position or hides it.
|
void |
setPaddingCharacter(char character,
Terminal.Color foregroundColor,
Terminal.Color backgroundColor,
ScreenCharacterStyle... style) |
void |
setTabBehaviour(TabBehaviour tabBehaviour)
Sets the behaviour for what to do about tab characters.
|
void |
startScreen()
Calling this method will put the underlying terminal in private mode,
clear the screen, move the cursor and refresh.
|
void |
stopScreen()
Calling this method will make the underlying terminal leave private mode,
effectively going back to whatever state the terminal was in before
calling
startScreen() |
boolean |
updateScreenSize()
Calling this method will check if the terminal has changed since and in that case update the dimensions of this
Screen to match.
|
public Screen(Terminal terminal)
terminal
- LanternaException
public Screen(Terminal terminal, TerminalSize terminalSize)
terminal
- terminalSize
- public Screen(Terminal terminal, int terminalWidth, int terminalHeight)
terminal
- terminalWidth
- Width (number of columns) of the terminalterminalHeight
- Height (number of rows) of the terminalpublic Terminal getTerminal()
public TerminalPosition getCursorPosition()
null
if the cursor is not visiblepublic void setCursorPosition(TerminalPosition position)
position
- 0-indexed column and row numbers of the new position, or if null
,
hides the cursorpublic void setCursorPosition(int column, int row)
column
- 0-indexed column number of the new positionrow
- 0-indexed row number of the new positionpublic void setTabBehaviour(TabBehaviour tabBehaviour)
TabBehaviour
public void setPaddingCharacter(char character, Terminal.Color foregroundColor, Terminal.Color backgroundColor, ScreenCharacterStyle... style)
public TabBehaviour getTabBehaviour()
TabBehaviour
public Key readInput()
Key
from the input queue, or returns null if there
is nothing on the queue.public TerminalSize getTerminalSize()
public void startScreen()
LanternaException
public void stopScreen()
startScreen()
LanternaException
public void clear()
public void putString(int x, int y, String string, Terminal.Color foregroundColor, Terminal.Color backgroundColor, ScreenCharacterStyle... styles)
x
- 0-indexed column number of where to put the first character in the stringy
- 0-indexed row number of where to put the first character in the stringstring
- Text to put on the screenforegroundColor
- What color to use for the textbackgroundColor
- What color to use for the backgroundstyles
- Additional styles to apply to the textpublic void putString(int x, int y, String string, Terminal.Color foregroundColor, Terminal.Color backgroundColor, Set<ScreenCharacterStyle> styles)
x
- 0-indexed column number of where to put the first character in the stringy
- 0-indexed row number of where to put the first character in the stringstring
- Text to put on the screenforegroundColor
- What color to use for the textbackgroundColor
- What color to use for the backgroundstyles
- Additional styles to apply to the textpublic boolean resizePending()
public boolean updateScreenSize()
public void completeRefresh()
public void refresh()
putCharacter(...)
,
putString(...)
visible on the terminal. The screen will calculate
the changes that are required and send the necessary characters and
control sequences to make it so.Copyright © 2015. All Rights Reserved.