public class Document
extends java.lang.Object
Constructor and Description |
---|
Document(java.lang.String str,
CellAttributes defaultColor)
Construct a new Document from an existing text string.
|
Modifier and Type | Method and Description |
---|---|
void |
addChar(int ch)
Replace or insert a character at the cursor, depending on overwrite
flag.
|
void |
backspace()
Delete the character immediately preceeding the cursor.
|
void |
backwardsWord()
Go back to the beginning of this word if in the middle, or the
beginning of the previous word.
|
void |
del()
Delete the character under the cursor.
|
boolean |
down()
Increment the line number by one.
|
boolean |
down(int n)
Increment the line number by n.
|
boolean |
end()
Go to the last column of this line.
|
void |
enter()
Split the current line into two, like pressing the enter key.
|
void |
forwardsWord()
Go to the beginning of the next word.
|
int |
getChar()
Get the character at the current cursor position in the text.
|
Line |
getCurrentLine()
Get the current editing line.
|
int |
getCursor()
Get the current cursor position of the editing line.
|
Line |
getLine(int lineNumber)
Get a specific line by number.
|
int |
getLineCount()
Get the number of lines.
|
int |
getLineLength()
Get the current line length.
|
int |
getLineLengthMax()
Compute the maximum line length for this document.
|
int |
getLineNumber()
Get the current line number being edited.
|
java.util.List<Line> |
getLines()
Get a (shallow) copy of the list of lines.
|
boolean |
getOverwrite()
Get the overwrite flag.
|
java.lang.String |
getRawLine()
Get the raw string that matches this line.
|
boolean |
home()
Go to the first column of this line.
|
boolean |
isDirty()
Get the dirty value.
|
boolean |
left()
Decrement the cursor by one.
|
boolean |
right()
Increment the cursor by one.
|
void |
saveToFilename(java.lang.String filename)
Save contents to file.
|
void |
setCursor(int cursor)
Set the current cursor position of the editing line.
|
void |
setLineNumber(int n)
Set the current line number being edited.
|
void |
setOverwrite(boolean overwrite)
Set the overwrite flag.
|
boolean |
up()
Decrement the line number by one.
|
boolean |
up(int n)
Decrement the line number by n.
|
public Document(java.lang.String str, CellAttributes defaultColor)
str
- the text stringdefaultColor
- the color for unhighlighted textpublic boolean getOverwrite()
public boolean isDirty()
public void saveToFilename(java.lang.String filename) throws java.io.IOException
filename
- file to save tojava.io.IOException
- if a java.io operation throwspublic void setOverwrite(boolean overwrite)
overwrite
- true if addChar() should overwrite data, false if it
should insertpublic int getLineNumber()
public Line getCurrentLine()
public Line getLine(int lineNumber)
lineNumber
- the line number. Note that this is 0-based: 0 is
the first line.public void setLineNumber(int n)
n
- the line number. Note that this is 0-based: 0 is the first
line.public int getCursor()
public int getChar()
public void setCursor(int cursor)
cursor
- the new cursor positionpublic boolean down()
public boolean down(int n)
n
- the number of lines to increment bypublic boolean up()
public boolean up(int n)
n
- the number of lines to decrement bypublic boolean left()
public boolean right()
public void backwardsWord()
public void forwardsWord()
public java.lang.String getRawLine()
public boolean home()
public boolean end()
public void del()
public void backspace()
public void enter()
public void addChar(int ch)
ch
- the character to replace or insertpublic java.util.List<Line> getLines()
public int getLineCount()
public int getLineLengthMax()
public int getLineLength()
Copyright © 2019 Kevin Lamonte. Licensed MIT.