Package com.simsilica.lemur.text
Class DefaultDocumentModel
java.lang.Object
com.simsilica.lemur.text.DefaultDocumentModel
- All Implemented Interfaces:
VersionedObject<DocumentModel>,DocumentModel,Cloneable
A default implementation of the DocumentModel interface.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes the character immediately before the current carat position.clone()Deep clones this document model.Returns a VersionedReference that can be watched for changes to the carat position.protected voidCreates a new VersionedReference that can be used to monitor when this object changes.voiddelete()Deletes the character immediately after the current carat position.voiddeleteCharAt(int pos) Deletes the character at the specified position.intdown()Moves the carat position to the next line if there is one.intend(boolean currentLine) Moves the carat to the document's end position or the current line's end position depending on the specified 'currentLine' value.protected voidfindPosition(int pos, int[] location) Find the line and column of the specified text position.intDuring text selection, this is one end of the selection where the other end is the carat position.intReturns the column number of the current anchor position in the line returned by getAnchorLine().intReturns the line number containing the current anchor position.intgetCarat()Returns the current 'carat' position.intReturns the column number of the current carat position in the line returned by getCaratLine().intReturns the line number containing the current carat position.getLine(int line) Returns the string representing just the specified line of text.intReturns the current number of lines in this document.Returns the object that is being versioned.getText()Returns the current text value contained in this DocumentModel.longReturns the current version of the versioned object.inthome(boolean currentLine) Moves the carat to the document's home position or the current line's home position depending on the specified 'currentLine' value.voidinsert(char c) Inserts a character at the current carat position.voidBulk inserts a string of text.voidInserts a new line at the current carat position.intleft()Moves the carat one position to the left, potentially moving it to the previous line depending on the actual DocumentModel implementation.protected voidintright()Moves the carat one position to the right, potentially moving it to the next line depending on the actual DocumentModel implementation.voidReplaces the text contained in this DocumentModel.toString()intup()Moves the carat position to the previous line if there is one.
-
Constructor Details
-
DefaultDocumentModel
public DefaultDocumentModel() -
DefaultDocumentModel
-
-
Method Details
-
clone
Description copied from interface:DocumentModelDeep clones this document model.- Specified by:
clonein interfaceDocumentModel- Overrides:
clonein classObject
-
setText
Description copied from interface:DocumentModelReplaces the text contained in this DocumentModel.- Specified by:
setTextin interfaceDocumentModel
-
getText
Description copied from interface:DocumentModelReturns the current text value contained in this DocumentModel.- Specified by:
getTextin interfaceDocumentModel
-
getLine
Description copied from interface:DocumentModelReturns the string representing just the specified line of text.- Specified by:
getLinein interfaceDocumentModel
-
getLineCount
public int getLineCount()Description copied from interface:DocumentModelReturns the current number of lines in this document.- Specified by:
getLineCountin interfaceDocumentModel
-
getCarat
public int getCarat()Description copied from interface:DocumentModelReturns the current 'carat' position. The 'carat' is where new text characters will be inserted. It's the current edit position.- Specified by:
getCaratin interfaceDocumentModel
-
getCaratLine
public int getCaratLine()Description copied from interface:DocumentModelReturns the line number containing the current carat position.- Specified by:
getCaratLinein interfaceDocumentModel
-
getCaratColumn
public int getCaratColumn()Description copied from interface:DocumentModelReturns the column number of the current carat position in the line returned by getCaratLine().- Specified by:
getCaratColumnin interfaceDocumentModel
-
getAnchorLine
public int getAnchorLine()Description copied from interface:DocumentModelReturns the line number containing the current anchor position.- Specified by:
getAnchorLinein interfaceDocumentModel
-
getAnchorColumn
public int getAnchorColumn()Description copied from interface:DocumentModelReturns the column number of the current anchor position in the line returned by getAnchorLine().- Specified by:
getAnchorColumnin interfaceDocumentModel
-
getAnchor
public int getAnchor()Description copied from interface:DocumentModelDuring text selection, this is one end of the selection where the other end is the carat position.- Specified by:
getAnchorin interfaceDocumentModel
-
home
public int home(boolean currentLine) Description copied from interface:DocumentModelMoves the carat to the document's home position or the current line's home position depending on the specified 'currentLine' value. If currentLine is true then the home position is just before the first character in the current line. If the currentLine parameter is false then the home position is just before the first character in the whole document.- Specified by:
homein interfaceDocumentModel
-
end
public int end(boolean currentLine) Description copied from interface:DocumentModelMoves the carat to the document's end position or the current line's end position depending on the specified 'currentLine' value. If currentLine is true then the end position is just after the last character in the current line. If the currentLine parameter is false then the end position is just after the last character in the whole document.- Specified by:
endin interfaceDocumentModel
-
up
public int up()Description copied from interface:DocumentModelMoves the carat position to the previous line if there is one. After this call, the new column position is implementation dependent.- Specified by:
upin interfaceDocumentModel
-
down
public int down()Description copied from interface:DocumentModelMoves the carat position to the next line if there is one. After this call, the new column position is implementation dependent.- Specified by:
downin interfaceDocumentModel
-
left
public int left()Description copied from interface:DocumentModelMoves the carat one position to the left, potentially moving it to the previous line depending on the actual DocumentModel implementation.- Specified by:
leftin interfaceDocumentModel
-
right
public int right()Description copied from interface:DocumentModelMoves the carat one position to the right, potentially moving it to the next line depending on the actual DocumentModel implementation.- Specified by:
rightin interfaceDocumentModel
-
insertNewLine
public void insertNewLine()Description copied from interface:DocumentModelInserts a new line at the current carat position.- Specified by:
insertNewLinein interfaceDocumentModel
-
deleteCharAt
public void deleteCharAt(int pos) Description copied from interface:DocumentModelDeletes the character at the specified position.- Specified by:
deleteCharAtin interfaceDocumentModel
-
backspace
public void backspace()Description copied from interface:DocumentModelDeletes the character immediately before the current carat position. This may move the carat to the previous line if the carat was previously at the beginning of a line.- Specified by:
backspacein interfaceDocumentModel
-
delete
public void delete()Description copied from interface:DocumentModelDeletes the character immediately after the current carat position.- Specified by:
deletein interfaceDocumentModel
-
findPosition
protected void findPosition(int pos, int[] location) Find the line and column of the specified text position. -
insert
public void insert(char c) Description copied from interface:DocumentModelInserts a character at the current carat position.- Specified by:
insertin interfaceDocumentModel
-
insert
Description copied from interface:DocumentModelBulk inserts a string of text.- Specified by:
insertin interfaceDocumentModel
-
getVersion
public long getVersion()Description copied from interface:VersionedObjectReturns the current version of the versioned object.- Specified by:
getVersionin interfaceVersionedObject<DocumentModel>
-
getObject
Description copied from interface:VersionedObjectReturns the object that is being versioned.- Specified by:
getObjectin interfaceVersionedObject<DocumentModel>
-
createReference
Description copied from interface:VersionedObjectCreates a new VersionedReference that can be used to monitor when this object changes.- Specified by:
createReferencein interfaceVersionedObject<DocumentModel>
-
createCaratReference
Description copied from interface:DocumentModelReturns a VersionedReference that can be watched for changes to the carat position.- Specified by:
createCaratReferencein interfaceDocumentModel
-
parseText
-
createComposite
protected void createComposite() -
toString
-