|
JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins
« « « Anklang Documentation |
A class for storing and manipulating a source code file. More...
#include "juce_CodeDocument.h"
Classes | |
| struct | DeleteAction |
| struct | InsertAction |
| class | Iterator |
| Iterates the text in a CodeDocument. More... | |
| class | Listener |
| An object that receives callbacks from the CodeDocument when its text changes. More... | |
| class | Position |
| A position in a code document. More... | |
Public Member Functions | |
| CodeDocument () | |
| Creates a new, empty document. | |
| ~CodeDocument () | |
| Destructor. | |
| String | getAllContent () const |
| Returns the full text of the document. | |
| String | getTextBetween (const Position &start, const Position &end) const |
| Returns a section of the document's text. | |
| String | getLine (int lineIndex) const noexcept |
| Returns a line from the document. | |
| int | getNumCharacters () const noexcept |
| Returns the number of characters in the document. | |
| int | getNumLines () const noexcept |
| Returns the number of lines in the document. | |
| int | getMaximumLineLength () noexcept |
| Returns the number of characters in the longest line of the document. | |
| void | deleteSection (const Position &startPosition, const Position &endPosition) |
| Deletes a section of the text. | |
| void | deleteSection (int startIndex, int endIndex) |
| Deletes a section of the text. | |
| void | insertText (const Position &position, const String &text) |
| Inserts some text into the document at a given position. | |
| void | insertText (int insertIndex, const String &text) |
| Inserts some text into the document at a given position. | |
| void | replaceSection (int startIndex, int endIndex, const String &newText) |
| Replaces a section of the text with a new string. | |
| void | replaceAllContent (const String &newContent) |
| Clears the document and replaces it with some new text. | |
| void | applyChanges (const String &newContent) |
| Analyses the changes between the current content and some new text, and applies those changes. | |
| bool | loadFromStream (InputStream &stream) |
| Replaces the editor's contents with the contents of a stream. | |
| bool | writeToStream (OutputStream &stream) |
| Writes the editor's current contents to a stream. | |
| String | getNewLineCharacters () const noexcept |
| Returns the preferred new-line characters for the document. | |
| void | setNewLineCharacters (const String &newLineCharacters) noexcept |
| Sets the new-line characters that the document should use. | |
| void | newTransaction () |
| Begins a new undo transaction. | |
| void | undo () |
| Undo the last operation. | |
| void | redo () |
| Redo the last operation. | |
| void | clearUndoHistory () |
| Clears the undo history. | |
| UndoManager & | getUndoManager () noexcept |
| Returns the document's UndoManager. | |
| void | setSavePoint () noexcept |
| Makes a note that the document's current state matches the one that is saved. | |
| bool | hasChangedSinceSavePoint () const noexcept |
| Returns true if the state of the document differs from the state it was in when setSavePoint() was last called. | |
| Position | findWordBreakAfter (const Position &position) const noexcept |
| Searches for a word-break. | |
| Position | findWordBreakBefore (const Position &position) const noexcept |
| Searches for a word-break. | |
| void | findTokenContaining (const Position &pos, Position &start, Position &end) const noexcept |
| Finds the token that contains the given position. | |
| void | findLineContaining (const Position &pos, Position &start, Position &end) const noexcept |
| Finds the line that contains the given position. | |
| void | addListener (Listener *listener) |
| Registers a listener object to receive callbacks when the document changes. | |
| void | removeListener (Listener *listener) |
| Deregisters a listener. | |
Friends | |
| class | Iterator |
| class | Position |
A class for storing and manipulating a source code file.
When using a CodeEditorComponent, it takes one of these as its source object.
The CodeDocument stores its content as an array of lines, which makes it quick to insert and delete.
@tags{GUI}
Definition at line 45 of file juce_CodeDocument.h.
| juce::CodeDocument::CodeDocument | ( | ) |
Creates a new, empty document.
Definition at line 556 of file juce_CodeDocument.cpp.
| juce::CodeDocument::~CodeDocument | ( | ) |
Destructor.
Definition at line 560 of file juce_CodeDocument.cpp.
| void juce::CodeDocument::addListener | ( | CodeDocument::Listener * | l | ) |
Registers a listener object to receive callbacks when the document changes.
If the listener is already registered, this method has no effect.
Definition at line 878 of file juce_CodeDocument.cpp.
Analyses the changes between the current content and some new text, and applies those changes.
Definition at line 670 of file juce_CodeDocument.cpp.
| void juce::CodeDocument::clearUndoHistory | ( | ) |
Clears the undo history.
Definition at line 737 of file juce_CodeDocument.cpp.
| void juce::CodeDocument::deleteSection | ( | const Position & | startPosition, |
| const Position & | endPosition | ||
| ) |
Deletes a section of the text.
This operation is undoable.
Definition at line 644 of file juce_CodeDocument.cpp.
Deletes a section of the text.
This operation is undoable.
Definition at line 649 of file juce_CodeDocument.cpp.
|
noexcept |
Finds the line that contains the given position.
Definition at line 851 of file juce_CodeDocument.cpp.
|
noexcept |
Finds the token that contains the given position.
Definition at line 837 of file juce_CodeDocument.cpp.
|
noexcept |
Searches for a word-break.
Definition at line 759 of file juce_CodeDocument.cpp.
|
noexcept |
Searches for a word-break.
Definition at line 797 of file juce_CodeDocument.cpp.
| String juce::CodeDocument::getAllContent | ( | ) | const |
Returns the full text of the document.
Definition at line 564 of file juce_CodeDocument.cpp.
Returns a line from the document.
Definition at line 623 of file juce_CodeDocument.cpp.
|
noexcept |
Returns the number of characters in the longest line of the document.
Definition at line 631 of file juce_CodeDocument.cpp.
|
noexcept |
Returns the preferred new-line characters for the document.
This will be either "\\n", "\\r\\n", or (rarely) "\\r".
Definition at line 259 of file juce_CodeDocument.h.
|
noexcept |
Returns the number of characters in the document.
Definition at line 615 of file juce_CodeDocument.cpp.
|
noexcept |
Returns the number of lines in the document.
Definition at line 204 of file juce_CodeDocument.h.
Returns a section of the document's text.
Definition at line 570 of file juce_CodeDocument.cpp.
|
noexcept |
Returns the document's UndoManager.
Definition at line 292 of file juce_CodeDocument.h.
|
noexcept |
Returns true if the state of the document differs from the state it was in when setSavePoint() was last called.
Definition at line 747 of file juce_CodeDocument.cpp.
Inserts some text into the document at a given position.
This operation is undoable.
Definition at line 654 of file juce_CodeDocument.cpp.
Inserts some text into the document at a given position.
This operation is undoable.
Definition at line 659 of file juce_CodeDocument.cpp.
| bool juce::CodeDocument::loadFromStream | ( | InputStream & | stream | ) |
Replaces the editor's contents with the contents of a stream.
This will also reset the undo history and save point marker.
Definition at line 692 of file juce_CodeDocument.cpp.
| void juce::CodeDocument::newTransaction | ( | ) |
Begins a new undo transaction.
The document itself will not call this internally, so relies on whatever is using the document to periodically call this to break up the undo sequence into sensible chunks.
Definition at line 721 of file juce_CodeDocument.cpp.
| void juce::CodeDocument::redo | ( | ) |
Redo the last operation.
Definition at line 732 of file juce_CodeDocument.cpp.
| void juce::CodeDocument::removeListener | ( | CodeDocument::Listener * | l | ) |
Clears the document and replaces it with some new text.
This operation is undoable - if you're trying to completely reset the document, you might want to also call clearUndoHistory() and setSavePoint() after using this method.
Definition at line 686 of file juce_CodeDocument.cpp.
Replaces a section of the text with a new string.
This operation is undoable.
Definition at line 664 of file juce_CodeDocument.cpp.
Sets the new-line characters that the document should use.
The string must be either "\\n", "\\r\\n", or (rarely) "\\r".
Definition at line 715 of file juce_CodeDocument.cpp.
|
noexcept |
Makes a note that the document's current state matches the one that is saved.
After this has been called, hasChangedSinceSavePoint() will return false until the document has been altered, and then it'll start returning true. If the document is altered, but then undone until it gets back to this state, hasChangedSinceSavePoint() will again return false.
Definition at line 742 of file juce_CodeDocument.cpp.
| void juce::CodeDocument::undo | ( | ) |
Undo the last operation.
Definition at line 726 of file juce_CodeDocument.cpp.
| bool juce::CodeDocument::writeToStream | ( | OutputStream & | stream | ) |
Writes the editor's current contents to a stream.
Definition at line 701 of file juce_CodeDocument.cpp.
Definition at line 432 of file juce_CodeDocument.h.
Definition at line 433 of file juce_CodeDocument.h.