public class SwingTextTerminal extends AbstractTextTerminal<SwingTextTerminal>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_FONT_SIZE |
static java.awt.Color |
DEFAULT_INPUT_COLOR |
static java.awt.Color |
DEFAULT_PANE_BACKGROUND |
static java.awt.Color |
DEFAULT_PROMPT_COLOR |
DEFAULT_USER_INTERRUPT_KEY, SYSPROP_PROPERTIES_FILE_LOCATION
Constructor and Description |
---|
SwingTextTerminal() |
Modifier and Type | Method and Description |
---|---|
boolean |
bindHandler(java.lang.String keyStroke,
java.util.function.Function<SwingTextTerminal,ReadHandlerData> handler)
Associates a key combination to a handler.
|
void |
display() |
void |
dispose(java.lang.String resultData)
This method is typically called at the end of a text-based input/output session in order to allow the terminal to release its screen resources.
|
int |
getBookmarkOffset(java.lang.String bookmark) |
static java.util.Optional<java.awt.Color> |
getColor(java.lang.String colorName) |
javax.swing.JFrame |
getFrame() |
javax.swing.JScrollPane |
getScrollPane() |
java.lang.String |
getStyle(org.beryx.textio.swing.SwingTextTerminal.StyleData styleData) |
javax.swing.JTextPane |
getTextPane() |
boolean |
moveToLineStart()
Moves the cursor to the start of the current line of text in order to allow overwriting the current line.
|
void |
println()
Terminates the current line by writing the line separator string.
|
void |
rawPrint(java.lang.String message)
Prints the message in its raw form.
|
java.lang.String |
read(boolean masking)
Reads a line of text
|
boolean |
registerUserInterruptHandler(java.util.function.Consumer<SwingTextTerminal> handler,
boolean abortRead)
Registers a handler that will be called in response to a user interrupt.
|
boolean |
resetLine()
Clears the current line of text.
|
boolean |
resetToBookmark(java.lang.String bookmark)
Clears the text after the given bookmark.
|
boolean |
resetToOffset(int offset) |
boolean |
setBookmark(java.lang.String bookmark)
Sets a bookmark with the given name at the current position.
|
void |
setInputBackgroundColor(java.lang.String colorName) |
void |
setInputBold(boolean bold) |
void |
setInputColor(java.lang.String colorName) |
void |
setInputFontFamily(java.lang.String fontFamily) |
void |
setInputFontSize(int fontSize) |
void |
setInputItalic(boolean italic) |
void |
setInputSubscript(boolean subscript) |
void |
setInputSuperscript(boolean superscript) |
void |
setInputUnderline(boolean underline) |
void |
setPaneBackgroundColor(java.lang.String colorName) |
void |
setPaneIconFile(java.lang.String filePath) |
void |
setPaneIconResource(java.lang.String res) |
void |
setPaneIconUrl(java.lang.String url) |
void |
setPaneTitle(java.lang.String newTitle) |
void |
setPromptBackgroundColor(java.lang.String colorName) |
void |
setPromptBold(boolean bold) |
void |
setPromptColor(java.lang.String colorName) |
void |
setPromptFontFamily(java.lang.String fontFamily) |
void |
setPromptFontSize(int fontSize) |
void |
setPromptItalic(boolean italic) |
void |
setPromptSubscript(boolean subscript) |
void |
setPromptSuperscript(boolean superscript) |
void |
setPromptUnderline(boolean underline) |
void |
setUserInterruptKey(javax.swing.KeyStroke keyStroke) |
void |
setUserInterruptKey(java.lang.String keyStroke) |
protected void |
updateScrollPaneSize(boolean pack) |
addDefaultProperty, getDefaultProperties, getProperties, getPropertiesPrefixes, getPropertiesReader, init, initProperties, initProperties, initProperties
public static final int DEFAULT_FONT_SIZE
public static final java.awt.Color DEFAULT_PANE_BACKGROUND
public static final java.awt.Color DEFAULT_PROMPT_COLOR
public static final java.awt.Color DEFAULT_INPUT_COLOR
public javax.swing.JFrame getFrame()
public javax.swing.JTextPane getTextPane()
public javax.swing.JScrollPane getScrollPane()
public java.lang.String read(boolean masking)
TextTerminal
masking
- true, if the input should be masked (for example to enter a password)public void println()
TextTerminal
public void rawPrint(java.lang.String message)
TextTerminal
public boolean resetLine()
TextTerminal
TextTerminal.println()
and returns false.public boolean moveToLineStart()
TextTerminal
TextTerminal.println()
and returns false.public boolean setBookmark(java.lang.String bookmark)
TextTerminal
TextTerminal.resetToBookmark(String)
in order to clear the text after this bookmark.
If a bookmark with this name already exists, it will be overwritten.
Since not all terminals support this feature, the default implementation does nothing and returns false.public boolean resetToBookmark(java.lang.String bookmark)
TextTerminal
TextTerminal.resetToBookmark(String)
in order to clear the text after this bookmark.
Since not all terminals support this feature, the default implementation calls TextTerminal.println()
and returns false.public int getBookmarkOffset(java.lang.String bookmark)
public boolean resetToOffset(int offset)
public void display()
public void dispose(java.lang.String resultData)
TextTerminal
resultData
- stringified information about the outcome of the input/output session; may be null,public boolean registerUserInterruptHandler(java.util.function.Consumer<SwingTextTerminal> handler, boolean abortRead)
TextTerminal
handler
- the action to be performed in response to a user interrupt.abortRead
- true, if the current read operation should be aborted on user interrupt.public void setUserInterruptKey(javax.swing.KeyStroke keyStroke)
public void setUserInterruptKey(java.lang.String keyStroke)
public boolean bindHandler(java.lang.String keyStroke, java.util.function.Function<SwingTextTerminal,ReadHandlerData> handler)
TextTerminal
keyStroke
- the key combination associated with the handler.
It should have the same format as the argument of KeyStroke.getKeyStroke(String)
.handler
- the action to be performed when the keyStroke
is detected during a read operation.public java.lang.String getStyle(org.beryx.textio.swing.SwingTextTerminal.StyleData styleData)
public void setPromptColor(java.lang.String colorName)
public void setPromptBackgroundColor(java.lang.String colorName)
public void setPromptFontFamily(java.lang.String fontFamily)
public void setPromptFontSize(int fontSize)
public void setPromptBold(boolean bold)
public void setPromptItalic(boolean italic)
public void setPromptUnderline(boolean underline)
public void setPromptSubscript(boolean subscript)
public void setPromptSuperscript(boolean superscript)
public void setInputColor(java.lang.String colorName)
public void setInputBackgroundColor(java.lang.String colorName)
public void setInputFontFamily(java.lang.String fontFamily)
public void setInputFontSize(int fontSize)
public void setInputBold(boolean bold)
public void setInputItalic(boolean italic)
public void setInputUnderline(boolean underline)
public void setInputSubscript(boolean subscript)
public void setInputSuperscript(boolean superscript)
public void setPaneBackgroundColor(java.lang.String colorName)
public void setPaneTitle(java.lang.String newTitle)
public void setPaneIconUrl(java.lang.String url)
public void setPaneIconFile(java.lang.String filePath)
public void setPaneIconResource(java.lang.String res)
protected void updateScrollPaneSize(boolean pack)
public static java.util.Optional<java.awt.Color> getColor(java.lang.String colorName)