- java.lang.Object
-
- com.googlecode.lanterna.graphics.TextGraphicsWriter
-
- All Implemented Interfaces:
StyleSet<TextGraphicsWriter>
public class TextGraphicsWriter extends java.lang.Object implements StyleSet<TextGraphicsWriter>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TextGraphicsWriter.WordPart
-
Nested classes/interfaces inherited from interface com.googlecode.lanterna.graphics.StyleSet
StyleSet.Set
-
-
Field Summary
Fields Modifier and Type Field Description private TextGraphics
backend
private TextColor
backgroundColor
private java.util.List<TextGraphicsWriter.WordPart>
chunk_queue
private TerminalPosition
cursorPosition
private TextColor
foregroundColor
private java.util.EnumSet<SGR>
style
private boolean
styleable
private WrapBehaviour
wrapBehaviour
-
Constructor Summary
Constructors Constructor Description TextGraphicsWriter(TextGraphics backend)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TextGraphicsWriter
clearModifiers()
Removes all active modifiersTextGraphicsWriter
disableModifiers(SGR... modifiers)
Removes zero or more modifiers from the set of currently active modifiersTextGraphicsWriter
enableModifiers(SGR... modifiers)
Adds zero or more modifiers to the set of currently active modifiersprivate void
flush(java.lang.StringBuilder word, int wordlen)
java.util.EnumSet<SGR>
getActiveModifiers()
Returns all the SGR codes that are currently activeTextColor
getBackgroundColor()
Returns the current background colorTerminalPosition
getCursorPosition()
TextColor
getForegroundColor()
Returns the current foreground colorWrapBehaviour
getWrapBehaviour()
boolean
isStyleable()
private void
linefeed(int lenToFit)
void
putControlChar(char ch)
TextGraphicsWriter
putString(java.lang.String string)
TextGraphicsWriter
setBackgroundColor(TextColor background)
Updates the current background colorvoid
setCursorPosition(TerminalPosition cursorPosition)
TextGraphicsWriter
setForegroundColor(TextColor foreground)
Updates the current foreground colorTextGraphicsWriter
setModifiers(java.util.EnumSet<SGR> modifiers)
Sets the active modifiers to exactly the set passed in to this method.void
setStyleable(boolean styleable)
TextGraphicsWriter
setStyleFrom(StyleSet<?> source)
copy colors and set of SGR codesvoid
setWrapBehaviour(WrapBehaviour wrapBehaviour)
private void
stash(java.lang.StringBuilder word, int wordlen)
-
-
-
Field Detail
-
backend
private final TextGraphics backend
-
cursorPosition
private TerminalPosition cursorPosition
-
foregroundColor
private TextColor foregroundColor
-
backgroundColor
private TextColor backgroundColor
-
style
private final java.util.EnumSet<SGR> style
-
wrapBehaviour
private WrapBehaviour wrapBehaviour
-
styleable
private boolean styleable
-
chunk_queue
private final java.util.List<TextGraphicsWriter.WordPart> chunk_queue
-
-
Constructor Detail
-
TextGraphicsWriter
public TextGraphicsWriter(TextGraphics backend)
-
-
Method Detail
-
putString
public TextGraphicsWriter putString(java.lang.String string)
-
linefeed
private void linefeed(int lenToFit)
-
putControlChar
public void putControlChar(char ch)
-
stash
private void stash(java.lang.StringBuilder word, int wordlen)
-
flush
private void flush(java.lang.StringBuilder word, int wordlen)
-
getCursorPosition
public TerminalPosition getCursorPosition()
- Returns:
- the cursor position
-
setCursorPosition
public void setCursorPosition(TerminalPosition cursorPosition)
- Parameters:
cursorPosition
- the cursor position to set
-
getForegroundColor
public TextColor getForegroundColor()
Description copied from interface:StyleSet
Returns the current foreground color- Specified by:
getForegroundColor
in interfaceStyleSet<TextGraphicsWriter>
- Returns:
- the foreground color
-
setForegroundColor
public TextGraphicsWriter setForegroundColor(TextColor foreground)
Description copied from interface:StyleSet
Updates the current foreground color- Specified by:
setForegroundColor
in interfaceStyleSet<TextGraphicsWriter>
- Parameters:
foreground
- the foreground color to set- Returns:
- Itself
-
getBackgroundColor
public TextColor getBackgroundColor()
Description copied from interface:StyleSet
Returns the current background color- Specified by:
getBackgroundColor
in interfaceStyleSet<TextGraphicsWriter>
- Returns:
- the background color
-
setBackgroundColor
public TextGraphicsWriter setBackgroundColor(TextColor background)
Description copied from interface:StyleSet
Updates the current background color- Specified by:
setBackgroundColor
in interfaceStyleSet<TextGraphicsWriter>
- Parameters:
background
- the background color to set- Returns:
- Itself
-
enableModifiers
public TextGraphicsWriter enableModifiers(SGR... modifiers)
Description copied from interface:StyleSet
Adds zero or more modifiers to the set of currently active modifiers- Specified by:
enableModifiers
in interfaceStyleSet<TextGraphicsWriter>
- Parameters:
modifiers
- Modifiers to add to the set of currently active modifiers- Returns:
- Itself
-
disableModifiers
public TextGraphicsWriter disableModifiers(SGR... modifiers)
Description copied from interface:StyleSet
Removes zero or more modifiers from the set of currently active modifiers- Specified by:
disableModifiers
in interfaceStyleSet<TextGraphicsWriter>
- Parameters:
modifiers
- Modifiers to remove from the set of currently active modifiers- Returns:
- Itself
-
setModifiers
public TextGraphicsWriter setModifiers(java.util.EnumSet<SGR> modifiers)
Description copied from interface:StyleSet
Sets the active modifiers to exactly the set passed in to this method. Any previous state of which modifiers are enabled doesn't matter.- Specified by:
setModifiers
in interfaceStyleSet<TextGraphicsWriter>
- Parameters:
modifiers
- Modifiers to set as active- Returns:
- Itself
-
clearModifiers
public TextGraphicsWriter clearModifiers()
Description copied from interface:StyleSet
Removes all active modifiers- Specified by:
clearModifiers
in interfaceStyleSet<TextGraphicsWriter>
- Returns:
- Itself
-
getActiveModifiers
public java.util.EnumSet<SGR> getActiveModifiers()
Description copied from interface:StyleSet
Returns all the SGR codes that are currently active- Specified by:
getActiveModifiers
in interfaceStyleSet<TextGraphicsWriter>
- Returns:
- Currently active SGR modifiers
-
setStyleFrom
public TextGraphicsWriter setStyleFrom(StyleSet<?> source)
Description copied from interface:StyleSet
copy colors and set of SGR codes- Specified by:
setStyleFrom
in interfaceStyleSet<TextGraphicsWriter>
- Parameters:
source
- Modifiers to set as active- Returns:
- Itself
-
getWrapBehaviour
public WrapBehaviour getWrapBehaviour()
- Returns:
- the wrapBehaviour
-
setWrapBehaviour
public void setWrapBehaviour(WrapBehaviour wrapBehaviour)
- Parameters:
wrapBehaviour
- the wrapBehaviour to set
-
isStyleable
public boolean isStyleable()
- Returns:
- whether styles in strings are handled.
-
setStyleable
public void setStyleable(boolean styleable)
- Parameters:
styleable
- whether styles in strings should be handled.
-
-