- 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 classTextGraphicsWriter.WordPart-
Nested classes/interfaces inherited from interface com.googlecode.lanterna.graphics.StyleSet
StyleSet.Set
-
-
Field Summary
Fields Modifier and Type Field Description private TextGraphicsbackendprivate TextColorbackgroundColorprivate java.util.List<TextGraphicsWriter.WordPart>chunk_queueprivate TerminalPositioncursorPositionprivate TextColorforegroundColorprivate java.util.EnumSet<SGR>styleprivate booleanstyleableprivate WrapBehaviourwrapBehaviour
-
Constructor Summary
Constructors Constructor Description TextGraphicsWriter(TextGraphics backend)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TextGraphicsWriterclearModifiers()Removes all active modifiersTextGraphicsWriterdisableModifiers(SGR... modifiers)Removes zero or more modifiers from the set of currently active modifiersTextGraphicsWriterenableModifiers(SGR... modifiers)Adds zero or more modifiers to the set of currently active modifiersprivate voidflush(java.lang.StringBuilder word, int wordlen)java.util.EnumSet<SGR>getActiveModifiers()Returns all the SGR codes that are currently activeTextColorgetBackgroundColor()Returns the current background colorTerminalPositiongetCursorPosition()TextColorgetForegroundColor()Returns the current foreground colorWrapBehaviourgetWrapBehaviour()booleanisStyleable()private voidlinefeed(int lenToFit)voidputControlChar(char ch)TextGraphicsWriterputString(java.lang.String string)TextGraphicsWritersetBackgroundColor(TextColor background)Updates the current background colorvoidsetCursorPosition(TerminalPosition cursorPosition)TextGraphicsWritersetForegroundColor(TextColor foreground)Updates the current foreground colorTextGraphicsWritersetModifiers(java.util.EnumSet<SGR> modifiers)Sets the active modifiers to exactly the set passed in to this method.voidsetStyleable(boolean styleable)TextGraphicsWritersetStyleFrom(StyleSet<?> source)copy colors and set of SGR codesvoidsetWrapBehaviour(WrapBehaviour wrapBehaviour)private voidstash(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:StyleSetReturns the current foreground color- Specified by:
getForegroundColorin interfaceStyleSet<TextGraphicsWriter>- Returns:
- the foreground color
-
setForegroundColor
public TextGraphicsWriter setForegroundColor(TextColor foreground)
Description copied from interface:StyleSetUpdates the current foreground color- Specified by:
setForegroundColorin interfaceStyleSet<TextGraphicsWriter>- Parameters:
foreground- the foreground color to set- Returns:
- Itself
-
getBackgroundColor
public TextColor getBackgroundColor()
Description copied from interface:StyleSetReturns the current background color- Specified by:
getBackgroundColorin interfaceStyleSet<TextGraphicsWriter>- Returns:
- the background color
-
setBackgroundColor
public TextGraphicsWriter setBackgroundColor(TextColor background)
Description copied from interface:StyleSetUpdates the current background color- Specified by:
setBackgroundColorin interfaceStyleSet<TextGraphicsWriter>- Parameters:
background- the background color to set- Returns:
- Itself
-
enableModifiers
public TextGraphicsWriter enableModifiers(SGR... modifiers)
Description copied from interface:StyleSetAdds zero or more modifiers to the set of currently active modifiers- Specified by:
enableModifiersin 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:StyleSetRemoves zero or more modifiers from the set of currently active modifiers- Specified by:
disableModifiersin 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:StyleSetSets 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:
setModifiersin interfaceStyleSet<TextGraphicsWriter>- Parameters:
modifiers- Modifiers to set as active- Returns:
- Itself
-
clearModifiers
public TextGraphicsWriter clearModifiers()
Description copied from interface:StyleSetRemoves all active modifiers- Specified by:
clearModifiersin interfaceStyleSet<TextGraphicsWriter>- Returns:
- Itself
-
getActiveModifiers
public java.util.EnumSet<SGR> getActiveModifiers()
Description copied from interface:StyleSetReturns all the SGR codes that are currently active- Specified by:
getActiveModifiersin interfaceStyleSet<TextGraphicsWriter>- Returns:
- Currently active SGR modifiers
-
setStyleFrom
public TextGraphicsWriter setStyleFrom(StyleSet<?> source)
Description copied from interface:StyleSetcopy colors and set of SGR codes- Specified by:
setStyleFromin 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.
-
-