public class LineID extends Object implements DocumentListener
Document. Registered LineListeners are notified
of changes to the line number.| Modifier and Type | Field and Description |
|---|---|
protected Document |
doc |
protected String |
fileName |
protected int |
lineIdx |
protected Set<LineHighlight> |
listeners |
protected Position |
pos |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(LineHighlight l)
Add listener to be notified when the line number changes.
|
void |
changedUpdate(DocumentEvent de)
DocumentListener callback. |
protected void |
editEvent(DocumentEvent de)
Called when the
Document registered using startTracking(javax.swing.text.Document)
is edited. |
boolean |
equals(Object obj)
Test whether this
LineID is equal to another object. |
String |
fileName()
Get the file name of this line.
|
int |
hashCode() |
void |
insertUpdate(DocumentEvent de)
DocumentListener callback. |
int |
lineIdx()
Get the (0-based) line number of this line.
|
protected static int |
nonWhiteSpaceOffset(String str)
Calculate the offset of the first non-whitespace character in a string.
|
void |
removeListener(LineHighlight l)
Remove a listener for line number changes.
|
void |
removeUpdate(DocumentEvent de)
DocumentListener callback. |
void |
startTracking(Document doc)
Attach a
Document to enable line number tracking when editing. |
void |
stopTracking()
Notify this
LineID that it is no longer in use. |
String |
toString()
Output a string representation in the form fileName:lineIdx+1.
|
protected void |
updatePosition()
Update the tracked position.
|
protected String fileName
protected int lineIdx
protected Document doc
protected Position pos
protected Set<LineHighlight> listeners
public LineID(String fileName, int lineIdx)
public String fileName()
public int lineIdx()
public boolean equals(Object obj)
public String toString()
public void startTracking(Document doc)
Document to enable line number tracking when editing.
The position to track is before the first non-whitespace character on the
line. Edits happening before that position will cause the line number to
update accordingly. Multiple startTracking(javax.swing.text.Document) calls will replace
the tracked document. Whoever wants a tracked line should track it and
add itself as listener if necessary.
(LineHighlight, LineBreakpoint)doc - the Document to use for line number trackingpublic void stopTracking()
protected void updatePosition()
public void addListener(LineHighlight l)
l - the listener to addpublic void removeListener(LineHighlight l)
l - the listener to removeprotected static int nonWhiteSpaceOffset(String str)
str - the string to examineprotected void editEvent(DocumentEvent de)
Document registered using startTracking(javax.swing.text.Document)
is edited. This happens when text is inserted or removed.public void insertUpdate(DocumentEvent de)
DocumentListener callback. Called when text is inserted.insertUpdate in interface DocumentListenerpublic void removeUpdate(DocumentEvent de)
DocumentListener callback. Called when text is removed.removeUpdate in interface DocumentListenerpublic void changedUpdate(DocumentEvent de)
DocumentListener callback. Called when attributes are changed.
Not used.changedUpdate in interface DocumentListenerCopyright © 2001–2017 Processing Foundation. All rights reserved.