Package org.jline.utils
Class Display
- java.lang.Object
-
- org.jline.utils.Display
-
public class Display extends java.lang.ObjectManages terminal display and efficient screen updates with cursor positioning.The Display class provides functionality for managing the display of content on the terminal screen. It handles the complexities of cursor positioning, line wrapping, and efficient screen updates to minimize the amount of data sent to the terminal.
This class supports two main modes of operation:
- Full-screen mode - Takes over the entire terminal screen
- Partial-screen mode - Updates only a portion of the screen, preserving content above
Key features include:
- Efficient screen updates using cursor positioning
- Support for multi-line content with proper wrapping
- Handling of ANSI-styled text (colors, attributes)
- Size-aware rendering that adapts to terminal dimensions
- Cursor positioning relative to the display area
This class is used by various JLine components, such as LineReader, to provide efficient terminal display management for features like command-line editing, completion menus, and status messages.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleancanScrollprotected intcolumnsprotected intcolumns1protected java.util.Map<InfoCmp.Capability,java.lang.Integer>costprotected booleancursorDownIsNewLineprotected intcursorPosprotected booleandelayedWrapAtEolprotected booleandelayLineWrapprotected booleanfullScreenprotected java.util.List<AttributedString>oldLinesprotected booleanresetprotected introwsprotected Terminalterminalprotected booleanterminalDelayedWrapAtEolprotected booleanterminalWrapAtEolprotected booleanwrapAtEol
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancan(InfoCmp.Capability single, InfoCmp.Capability multi)voidclear()Clears the whole screen.booleandelayLineWrap()If cursor is at right margin, don't wrap immediately.protected booleandeleteChars(int nb)protected booleandeleteLines(int nb)protected booleaninsertChars(int nb)protected booleaninsertLines(int nb)protected intmoveVisualCursorTo(int i1)protected voidmoveVisualCursorTo(int targetPos, java.util.List<AttributedString> newLines)protected booleanperform(InfoCmp.Capability single, InfoCmp.Capability multi, int nb)voidreset()voidresize(int rows, int columns)voidsetDelayLineWrap(boolean v)voidupdate(java.util.List<AttributedString> newLines, int targetCursorPos)Update the display according to the new lines and flushes the output.voidupdate(java.util.List<AttributedString> newLines, int targetCursorPos, boolean flush)Update the display according to the new lines.voidupdateAnsi(java.util.List<java.lang.String> newLines, int targetCursorPos)intwcwidth(java.lang.String str)
-
-
-
Field Detail
-
terminal
protected final Terminal terminal
-
fullScreen
protected final boolean fullScreen
-
oldLines
protected java.util.List<AttributedString> oldLines
-
cursorPos
protected int cursorPos
-
columns
protected int columns
-
columns1
protected int columns1
-
rows
protected int rows
-
reset
protected boolean reset
-
delayLineWrap
protected boolean delayLineWrap
-
cost
protected final java.util.Map<InfoCmp.Capability,java.lang.Integer> cost
-
canScroll
protected final boolean canScroll
-
terminalWrapAtEol
protected final boolean terminalWrapAtEol
-
terminalDelayedWrapAtEol
protected final boolean terminalDelayedWrapAtEol
-
wrapAtEol
protected boolean wrapAtEol
-
delayedWrapAtEol
protected boolean delayedWrapAtEol
-
cursorDownIsNewLine
protected final boolean cursorDownIsNewLine
-
-
Constructor Detail
-
Display
public Display(Terminal terminal, boolean fullscreen)
-
-
Method Detail
-
delayLineWrap
public boolean delayLineWrap()
If cursor is at right margin, don't wrap immediately. Seeorg.jline.reader.LineReader.Option#DELAY_LINE_WRAP.- Returns:
trueif line wrap is delayed,falseotherwise
-
setDelayLineWrap
public void setDelayLineWrap(boolean v)
-
resize
public void resize(int rows, int columns)
-
reset
public void reset()
-
clear
public void clear()
Clears the whole screen. Use this method only when using full-screen / application mode.
-
updateAnsi
public void updateAnsi(java.util.List<java.lang.String> newLines, int targetCursorPos)
-
update
public void update(java.util.List<AttributedString> newLines, int targetCursorPos)
Update the display according to the new lines and flushes the output.- Parameters:
newLines- the lines to displaytargetCursorPos- desired cursor position - see Size.cursorPos.
-
update
public void update(java.util.List<AttributedString> newLines, int targetCursorPos, boolean flush)
Update the display according to the new lines.- Parameters:
newLines- the lines to displaytargetCursorPos- desired cursor position - see Size.cursorPos.flush- whether the output should be flushed or not
-
deleteLines
protected boolean deleteLines(int nb)
-
insertLines
protected boolean insertLines(int nb)
-
insertChars
protected boolean insertChars(int nb)
-
deleteChars
protected boolean deleteChars(int nb)
-
can
protected boolean can(InfoCmp.Capability single, InfoCmp.Capability multi)
-
perform
protected boolean perform(InfoCmp.Capability single, InfoCmp.Capability multi, int nb)
-
moveVisualCursorTo
protected void moveVisualCursorTo(int targetPos, java.util.List<AttributedString> newLines)
-
moveVisualCursorTo
protected int moveVisualCursorTo(int i1)
-
wcwidth
public int wcwidth(java.lang.String str)
-
-