29class CodeDocumentLine;
82 int line,
int indexInLine)
noexcept;
92 int charactersFromStartOfDocument)
noexcept;
106 bool operator== (
const Position&)
const noexcept;
107 bool operator!= (
const Position&)
const noexcept;
115 void setPosition (
int charactersFromStartOfDocument);
131 void setLineAndIndex (
int newLineNumber,
int newIndexInLine);
152 void setPositionMaintained (
bool isMaintained);
158 void moveBy (
int characterDelta);
164 Position movedBy (
int characterDelta)
const;
170 Position movedByLines (
int deltaLines)
const;
180 String getLineText()
const;
184 int characterPos = 0, line = 0, indexInLine = 0;
185 bool positionMaintained =
false;
192 String getAllContent()
const;
195 String getTextBetween (
const Position& start,
const Position& end)
const;
198 String getLine (
int lineIndex)
const noexcept;
201 int getNumCharacters() const noexcept;
204 int getNumLines() const noexcept {
return lines.size(); }
207 int getMaximumLineLength() noexcept;
212 void deleteSection (const Position& startPosition, const Position& endPosition);
217 void deleteSection (
int startIndex,
int endIndex);
222 void insertText (const Position& position, const
String& text);
227 void insertText (
int insertIndex, const
String& text);
232 void replaceSection (
int startIndex,
int endIndex, const
String& newText);
239 void replaceAllContent (const
String& newContent);
244 void applyChanges (const
String& newContent);
259 String getNewLineCharacters() const noexcept {
return newLineChars; }
265 void setNewLineCharacters (
const String& newLineCharacters)
noexcept;
274 void newTransaction();
289 void clearUndoHistory();
304 void setSavePoint() noexcept;
311 bool hasChangedSinceSavePoint() const noexcept;
315 Position findWordBreakAfter (const Position& position) const noexcept;
317 Position findWordBreakBefore (const Position& position) const noexcept;
319 void findTokenContaining (const Position& pos, Position& start, Position& end) const noexcept;
321 void findLineContaining (const Position& pos, Position& start, Position& end) const noexcept;
344 void addListener (
Listener* listener);
349 void removeListener (
Listener* listener);
394 void skip()
noexcept;
400 void skipWhitespace() noexcept;
403 void skipToEndOfLine() noexcept;
406 void skipToStartOfLine() noexcept;
409 int getLine() const noexcept {
return line; }
412 bool isEOF() const noexcept;
415 bool isSOF() const noexcept;
421 bool reinitialiseCharPtr() const;
424 mutable
String::CharPointerType charPointer {
nullptr };
425 int line = 0, position = 0;
432 friend class Iterator;
433 friend class Position;
435 OwnedArray<CodeDocumentLine> lines;
436 Array<Position*> positionsToMaintain;
437 UndoManager undoManager;
438 int currentActionIndex = 0, indexOfSavedState = -1;
439 int maximumLineLength = -1;
440 ListenerList<Listener> listeners;
441 String newLineChars {
"\r\n" };
443 void insert (
const String& text,
int insertPos,
bool undoable);
444 void remove (
int startPos,
int endPos,
bool undoable);
445 void checkLastLineStatus();
Iterates the text in a CodeDocument.
int getPosition() const noexcept
Returns the position as the number of characters from the start of the document.
An object that receives callbacks from the CodeDocument when its text changes.
virtual void codeDocumentTextInserted(const String &newText, int insertIndex)=0
Called by a CodeDocument when text is added.
virtual void codeDocumentTextDeleted(int startIndex, int endIndex)=0
Called by a CodeDocument when text is deleted.
A position in a code document.
int getIndexInLine() const noexcept
Returns the number of characters from the start of the line.
int getPosition() const noexcept
Returns the position as the number of characters from the start of the document.
int getLineNumber() const noexcept
Returns the line number of this position.
A class for storing and manipulating a source code file.
UndoManager & getUndoManager() noexcept
Returns the document's UndoManager.
The base class for streams that write data to some kind of destination.
Manages a list of undo/redo commands.
wchar_t juce_wchar
A platform-independent 32-bit unicode character type.