public class Line
extends java.lang.Object
Constructor and Description |
---|
Line(java.lang.String str,
CellAttributes defaultColor)
Construct a new Line from an existing text string.
|
Line(java.lang.String str,
CellAttributes defaultColor,
Highlighter highlighter)
Construct a new Line from an existing text string, and highlight
certain strings.
|
Modifier and Type | Method and Description |
---|---|
void |
addChar(int ch)
Insert a character at the cursor.
|
void |
backspace()
Delete the character immediately preceeding the cursor.
|
void |
del()
Delete the character under the cursor.
|
boolean |
end()
Go to the last column of this line.
|
int |
getChar()
Get the character at the current cursor position in the text.
|
int |
getCursor()
Get the current cursor position on screen.
|
int |
getDisplayLength()
Get the on-screen display length.
|
int |
getRawCursor()
Get the current cursor position in the text.
|
java.lang.String |
getRawString()
Get the raw string that matches this line.
|
java.util.List<Word> |
getWords()
Get a (shallow) copy of the words in this line.
|
boolean |
home()
Go to the first column of this line.
|
boolean |
left()
Decrement the cursor by one.
|
void |
replaceChar(int ch)
Replace a character at the cursor.
|
boolean |
right()
Increment the cursor by one.
|
protected int |
screenToTextPosition(int screenPosition)
Determine string position from screen position.
|
void |
setCursor(int cursor)
Set the current cursor position.
|
public Line(java.lang.String str, CellAttributes defaultColor, Highlighter highlighter)
str
- the text stringdefaultColor
- the color for unhighlighted texthighlighter
- the highlighter to usepublic Line(java.lang.String str, CellAttributes defaultColor)
str
- the text stringdefaultColor
- the color for unhighlighted textpublic java.util.List<Word> getWords()
public int getRawCursor()
public int getCursor()
public void setCursor(int cursor)
cursor
- the new cursor positionpublic int getChar()
public int getDisplayLength()
public java.lang.String getRawString()
public boolean left()
public boolean right()
public boolean home()
public boolean end()
public void del()
public void backspace()
public void addChar(int ch)
ch
- the character to insertpublic void replaceChar(int ch)
ch
- the character to replaceprotected int screenToTextPosition(int screenPosition)
screenPosition
- the position on screenCopyright © 2019 Kevin Lamonte. Licensed MIT.