1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-16 00:34:19 +00:00

CodeDocument new method + internal tweaks.

This commit is contained in:
jules 2012-08-17 20:24:19 +01:00
parent b4fe06fb81
commit 331e102663
2 changed files with 15 additions and 3 deletions

View file

@ -552,7 +552,7 @@ void CodeDocument::deleteSection (const Position& startPosition, const Position&
deleteSection (startPosition.getPosition(), endPosition.getPosition());
}
void CodeDocument::deleteSection (int start, int end)
void CodeDocument::deleteSection (const int start, const int end)
{
remove (start, end, true);
}
@ -562,11 +562,18 @@ void CodeDocument::insertText (const Position& position, const String& text)
insertText (position.getPosition(), text);
}
void CodeDocument::insertText (int insertIndex, const String& text)
void CodeDocument::insertText (const int insertIndex, const String& text)
{
insert (text, insertIndex, true);
}
void CodeDocument::replaceSection (const int start, const int end, const String& newText)
{
insertText (start, newText);
const int newTextLen = newText.length();
deleteSection (start + newTextLen, end + newTextLen);
}
void CodeDocument::replaceAllContent (const String& newContent)
{
TextDiff diff (getAllContent(), newContent);
@ -864,7 +871,7 @@ void CodeDocument::insert (const String& text, const int insertPos, const bool u
{
CodeDocument::Position& p = *positionsToMaintain.getUnchecked(i);
if (p.getPosition() >= insertPos)
if (p.getPosition() > insertPos)
p.setPosition (p.getPosition() + newTextLength);
}

View file

@ -222,6 +222,11 @@ public:
*/
void insertText (int insertIndex, const String& text);
/** Replaces a section of the text with a new string.
This operation is undoable.
*/
void replaceSection (int startIndex, int endIndex, const String& newText);
/** Clears the document and replaces it with some new text.
This operation is undoable - if you're trying to completely reset the document, you