public class PreserveStateAddon extends Object implements ITerminal, ITerminalOptions
XTerm server-side component is detached from the UI, the xterm.js client-side
component is destroyed along with its state. When the XTerm component
is later re-attached to the UI, a new unconfigured xterm.js is created on the
client-side.
To use this addon, simply create the addon then make sure to call all ITerminal
and ITerminalOptions methods via this addon:
final XTerm xterm = new XTerm();
final PreserveStateAddon addon = new PreserveStateAddon(xterm);
addon.writeln("Hello!");
addon.setPrompt("$ ");
addon.writePrompt();
ITerminalOptions.BellStyle, ITerminalOptions.CursorStyle, ITerminalOptions.FastScrollModifier, ITerminalOptions.RendererType| Constructor and Description |
|---|
PreserveStateAddon(XTerm xterm) |
| Modifier and Type | Method and Description |
|---|---|
void |
blur()
Unfocus the terminal.
|
void |
clear()
Clear the entire buffer, making the prompt line the new first line.
|
void |
clearSelection()
Clears the current terminal selection.
|
void |
focus()
Focus the terminal.
|
String |
getPrompt()
|
String |
getScrollbackBuffer() |
CompletableFuture<String> |
getSelection()
Gets the terminal's current selection, this is useful for implementing copy behavior outside of
xterm.js.
|
XTerm |
getXTerm() |
CompletableFuture<Boolean> |
hasSelection()
Gets whether the terminal has an active selection.
|
void |
paste(String data)
Writes text to the terminal, performing the necessary transformations for pasted text.
|
void |
refresh(int start,
int end)
Tells the renderer to refresh terminal content between two rows (inclusive) at the next
opportunity.
|
void |
reset()
Perform a full reset (RIS, aka '\x1bc').
|
void |
resize(int columns,
int rows)
Resizes the terminal.
|
void |
scrollLines(int amount)
Scroll the display of the terminal
|
void |
scrollPages(int pageCount)
Scroll the display of the terminal by a number of pages.
|
void |
scrollToBottom()
Scrolls the display of the terminal to the bottom.
|
void |
scrollToLine(int line)
Scrolls to a line within the buffer.
|
void |
scrollToTop()
Scrolls the display of the terminal to the top.
|
void |
select(int column,
int row,
int length)
Selects text within the terminal.
|
void |
selectAll()
Selects all text within the terminal.
|
void |
selectLines(int start,
int end)
Selects text in the buffer between 2 lines.
|
void |
setPrompt(String prompt)
|
void |
write(String data)
Write data to the terminal.
|
void |
writeln(String data)
Writes data to the terminal, followed by a break line character (\n).
|
void |
writePrompt() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetBellSound, setBellStyle, setCursorBlink, setCursorStyle, setCursorWidth, setDrawBoldTextInBrightColors, setFastScrollModifier, setFastScrollSensitivity, setFontFamily, setFontSize, setFontWeight, setFontWeightBold, setLetterSpacing, setLineHeight, setMacOptionClickForcesSelection, setMacOptionIsMeta, setMinimumContrastRatio, setRendererType, setRightClickSelectsWord, setScreenReaderMode, setScrollback, setScrollSensitivity, setTabStopWidth, setTheme, setWordSeparatorpublic PreserveStateAddon(XTerm xterm)
public void blur()
ITerminalpublic void focus()
ITerminalpublic CompletableFuture<Boolean> hasSelection()
ITerminalhasSelection in interface ITerminalpublic CompletableFuture<String> getSelection()
ITerminalgetSelection in interface ITerminalpublic void clearSelection()
ITerminalclearSelection in interface ITerminalpublic void select(int column,
int row,
int length)
ITerminalpublic void selectAll()
ITerminalpublic void selectLines(int start,
int end)
ITerminalselectLines in interface ITerminalstart - The 0-based line index to select from (inclusive).end - The 0-based line index to select to (inclusive).public void scrollLines(int amount)
ITerminalscrollLines in interface ITerminalamount - The number of lines to scroll down (negative scroll up).public void scrollPages(int pageCount)
ITerminalscrollPages in interface ITerminalpageCount - The number of pages to scroll (negative scrolls up).public void scrollToTop()
ITerminalscrollToTop in interface ITerminalpublic void scrollToBottom()
ITerminalscrollToBottom in interface ITerminalpublic void scrollToLine(int line)
ITerminalscrollToLine in interface ITerminalline - The 0-based line index to scroll to.public void clear()
ITerminalpublic void write(String data)
ITerminalpublic void writeln(String data)
ITerminalpublic void paste(String data)
ITerminalpublic void refresh(int start,
int end)
ITerminalpublic void reset()
ITerminalpublic void resize(int columns,
int rows)
ITerminalpublic void setPrompt(String prompt)
public String getPrompt()
public void writePrompt()
public String getScrollbackBuffer()
public XTerm getXTerm()
Copyright © 2020–2021 Flowing Code. All rights reserved.