public final class DefaultNTextCursorTracker extends Object implements NTextCursorTracker
Memory footprint: 1 bit per rewindable special char (maxRewindDepth). Example: maxRewindDepth=1024 → ~128 bytes history buffer.
| Constructor and Description |
|---|
DefaultNTextCursorTracker()
Creates cursor with unlimited rewind depth (use cautiously for huge files).
|
DefaultNTextCursorTracker(int tabSize,
int maxRewindDepth)
Creates cursor with bounded rewind depth.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearHistory()
Discards all rewind history.
|
void |
consume(char c) |
void |
consume(char[] buffer,
int offset,
int len) |
void |
consume(String s) |
int |
line() |
int |
maxRewindDepth()
Returns maximum configured rewind depth (0 = unlimited).
|
int |
physicalColumn() |
void |
reset() |
void |
rewind(char c)
Rewinds the effect of consuming
c. |
int |
rewindDepth()
Returns current rewind depth (number of operations that can be rewound).
|
int |
visualColumn() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitof, ofpublic DefaultNTextCursorTracker()
public DefaultNTextCursorTracker(int tabSize,
int maxRewindDepth)
tabSize - number of visual columns per tab stop (>0)maxRewindDepth - maximum number of rewindable operations (0 = unlimited)public void consume(char c)
consume in interface NTextCursorTrackerpublic void consume(String s)
consume in interface NTextCursorTrackerpublic void consume(char[] buffer,
int offset,
int len)
consume in interface NTextCursorTrackerpublic void rewind(char c)
c.
MUST be called in strict reverse (LIFO) order of consumption.rewind in interface NTextCursorTrackerIllegalStateException - if insufficient history exists to rewindpublic void clearHistory()
Example pattern: cursor.consume("public class Foo {\n"); cursor.clearHistory(); // Won't rewind past class declaration // ... generate method bodies with conditional rewinds ...
clearHistory in interface NTextCursorTrackerpublic int rewindDepth()
rewindDepth in interface NTextCursorTrackerpublic int maxRewindDepth()
maxRewindDepth in interface NTextCursorTrackerpublic int line()
line in interface NTextCursorTrackerpublic int physicalColumn()
physicalColumn in interface NTextCursorTrackerpublic int visualColumn()
visualColumn in interface NTextCursorTrackerpublic void reset()
reset in interface NTextCursorTrackerCopyright © 2026 vpc open source initiative. All rights reserved.