public class SwingTerminal extends AbstractTerminal implements InputProvider
Terminal.Color, Terminal.ResizeListener, Terminal.SGR
Constructor and Description |
---|
SwingTerminal() |
SwingTerminal(int widthInColumns,
int heightInRows) |
SwingTerminal(TerminalAppearance appearance) |
SwingTerminal(TerminalAppearance appearance,
int widthInColumns,
int heightInRows) |
SwingTerminal(TerminalSize terminalSize) |
Modifier and Type | Method and Description |
---|---|
void |
addInputProfile(KeyMappingProfile profile)
Adds a KeyMappingProfile to be used when converting raw user input bytes
to
Key objects. |
void |
applyBackgroundColor(int index)
Changes the background color for all the following characters put to the
terminal.
|
void |
applyBackgroundColor(int r,
int g,
int b)
Changes the background color for all the following characters put to the
terminal.
|
void |
applyBackgroundColor(Terminal.Color color)
Changes the background color for all the following characters put to the
terminal.
|
void |
applyForegroundColor(int index)
Changes the foreground color for all the following characters put to the
terminal.
|
void |
applyForegroundColor(int r,
int g,
int b)
Changes the foreground color for all the following characters put to the
terminal.
|
void |
applyForegroundColor(Terminal.Color color)
Changes the foreground color for all the following characters put to the
terminal.
|
void |
applySGR(Terminal.SGR... options)
Activates an
SGR code for all the following characters put to the
terminal. |
void |
clearScreen()
Removes all the characters, colors and graphics from the screep and leaves
you with a big empty space.
|
void |
enterPrivateMode()
Calling this method will, where supported, give your terminal a private
area to use, separate from what was there before.
|
void |
exitPrivateMode()
If you have previously entered private mode, this method will exit this
and, depending on implementation, maybe restore what the terminal looked
like before private mode was entered.
|
void |
flush()
Calls
flush() on the underlying OutputStream object, or
whatever other implementation this terminal is built around. |
JFrame |
getJFrame()
This method will give you the underlying JFrame for this terminal.
|
TerminalSize |
getTerminalSize()
Returns the size of the terminal, expressed as a
TerminalSize
object. |
void |
moveCursor(int x,
int y)
Moves the text cursor to a new location
|
void |
putCharacter(char c)
Prints one character to the terminal at the current cursor location.
|
TerminalSize |
queryTerminalSize()
Will ask the terminal of its current size dimensions, represented by a
TerminalSize object. |
Key |
readInput()
Returns the next
Key off the input queue or null if there is none
more input events available |
void |
setCursorVisible(boolean visible)
Hides or shows the text cursor
|
void |
setTerminalPalette(TerminalPalette palette)
Changes the current color palett to a new one supplied
|
addResizeListener, getLastKnownSize, onResized, removeResizeListener
public SwingTerminal()
public SwingTerminal(TerminalSize terminalSize)
public SwingTerminal(int widthInColumns, int heightInRows)
public SwingTerminal(TerminalAppearance appearance)
public SwingTerminal(TerminalAppearance appearance, int widthInColumns, int heightInRows)
public JFrame getJFrame()
Good uses of this method is to set the window title, window icon list and so on. If you add more logic to this JFrame, you should probably ask yourself why you are using Lanterna to begin with.
public void addInputProfile(KeyMappingProfile profile)
InputProvider
Key
objects.addInputProfile
in interface InputProvider
KeyMappingProfile
public void applyBackgroundColor(Terminal.Color color)
Terminal
applyBackgroundColor
in interface Terminal
color
- Color to use for the backgroundpublic void applyBackgroundColor(int r, int g, int b)
Terminal
applyBackgroundColor
in interface Terminal
r
- Red intensity, from 0 to 255g
- Green intensity, from 0 to 255b
- Blue intensity, from 0 to 255public void applyBackgroundColor(int index)
Terminal
For more details on this, please see this commit message to Konsole.
applyBackgroundColor
in interface Terminal
index
- Index of the color to use, from the XTerm 256 color extensionpublic void applyForegroundColor(Terminal.Color color)
Terminal
applyForegroundColor
in interface Terminal
color
- Color to use for foregroundpublic void applyForegroundColor(int r, int g, int b)
Terminal
applyForegroundColor
in interface Terminal
r
- Red intensity, from 0 to 255g
- Green intensity, from 0 to 255b
- Blue intensity, from 0 to 255public void applyForegroundColor(int index)
Terminal
For more details on this, please see this commit message to Konsole.
applyForegroundColor
in interface Terminal
index
- Color index from the XTerm 256 color spacepublic void applySGR(Terminal.SGR... options)
Terminal
SGR
code for all the following characters put to the
terminal.applySGR
in interface Terminal
options
- List of SGR codesTerminal.SGR
public void clearScreen()
Terminal
moveCursor
next.clearScreen
in interface Terminal
public void enterPrivateMode()
Terminal
enterPrivateMode
in interface Terminal
public void exitPrivateMode()
Terminal
exitPrivateMode
in interface Terminal
public void moveCursor(int x, int y)
Terminal
moveCursor
in interface Terminal
x
- The 0-indexed column to place the cursor aty
- The 0-indexed row to place the cursor atpublic void setCursorVisible(boolean visible)
Terminal
setCursorVisible
in interface Terminal
visible
- Hides the text cursor if false
and shows it if true
public void putCharacter(char c)
Terminal
putCharacter
in interface Terminal
public TerminalSize queryTerminalSize()
Terminal
TerminalSize
object. Please note that the default way of figuring
this information out is asynchorous and so you will be given the last
known dimensions. With proper resize listeners set up, this will only be
a problem for figuring out the initial size of the terminal.queryTerminalSize
in interface Terminal
TerminalSize
object representing the size of the terminalTerminalSize
public TerminalSize getTerminalSize()
Terminal
TerminalSize
object. Please bear in mind that depending on the Terminal
implementation, this may or may not be accurate. See the implementing
classes for more information.getTerminalSize
in interface Terminal
public Key readInput()
InputProvider
Key
off the input queue or null if there is none
more input events availablereadInput
in interface InputProvider
Key
off the input queue or null if there is nonepublic void flush()
Terminal
flush()
on the underlying OutputStream
object, or
whatever other implementation this terminal is built around.public void setTerminalPalette(TerminalPalette palette)
palette
- Palett to useCopyright © 2015. All Rights Reserved.