Package jexer.teditor
Class Word
- java.lang.Object
-
- jexer.teditor.Word
-
public class Word extends java.lang.ObjectA Word represents text that was entered by the user. It can be either whitespace or non-whitespace. Very dumb highlighting is supported, it has no sense of parsing (not even comments). For now this only highlights some Java keywords and puctuation.
-
-
Constructor Summary
Constructors Constructor Description Word(int ch, CellAttributes defaultColor, Highlighter highlighter)Construct a word with one character.Word(CellAttributes defaultColor, Highlighter highlighter)Construct a word with an empty string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WordaddChar(int ch)Add a character to this word.voidapplyHighlight()Perform highlighting.CellAttributesgetColor()Get the color used to display this word on screen.intgetDisplayLength()Get the on-screen display length.java.lang.StringgetText()Get the text to display.booleanisWhitespace()See if this is a whitespace word.voidsetColor(CellAttributes color)Set the color used to display this word on screen.
-
-
-
Constructor Detail
-
Word
public Word(int ch, CellAttributes defaultColor, Highlighter highlighter)Construct a word with one character.- Parameters:
ch- the first character of the worddefaultColor- the color for unhighlighted texthighlighter- the highlighter to use
-
Word
public Word(CellAttributes defaultColor, Highlighter highlighter)
Construct a word with an empty string.- Parameters:
defaultColor- the color for unhighlighted texthighlighter- the highlighter to use
-
-
Method Detail
-
getColor
public CellAttributes getColor()
Get the color used to display this word on screen.- Returns:
- the color
-
setColor
public void setColor(CellAttributes color)
Set the color used to display this word on screen.- Parameters:
color- the color
-
getText
public java.lang.String getText()
Get the text to display.- Returns:
- the text
-
getDisplayLength
public int getDisplayLength()
Get the on-screen display length.- Returns:
- the number of cells needed to display this word
-
isWhitespace
public boolean isWhitespace()
See if this is a whitespace word. Note that empty string is considered whitespace.- Returns:
- true if this word is whitespace
-
applyHighlight
public void applyHighlight()
Perform highlighting.
-
addChar
public Word addChar(int ch)
Add a character to this word. If this is a whitespace character adding to a non-whitespace word, create a new word and return that; similarly if this a non-whitespace character adding to a whitespace word, create a new word and return that. Note package private access: this is only called by Line to figure out highlighting boundaries.- Parameters:
ch- the new character to add- Returns:
- either this word (if it was added), or a new word that contains ch
-
-